Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Private Send

This page walks through each step of a private zERC20 transfer using the SDK.

How It Works

A private send follows three on/off-chain phases:

  1. Derive a burn address -- The sender computes a deterministic burn address from the recipient's address and a random secret using Poseidon hashing (with a 16-bit proof-of-work check).

  2. Transfer zERC20 to the burn address -- A standard ERC-20 transfer moves tokens into the burn address. The indexer records the transfer leaf.

  3. Submit an encrypted announcement -- The sender encrypts transfer metadata (secret, amount, etc.) via the ICP canister so that only the recipient can decrypt and later claim the funds.

The recipient can then scan the ICP storage canister, decrypt their announcements, and generate a ZKP to mint the equivalent zERC20 via Verifier.teleport().

Optional: Pre-flight Blocklist Check

zERC20 tokens enforce the on-chain Blocklist at transfer time. Any transfer to a blocked recipient will revert with AddressIsBlocked, and because the private-send path sends to a burn address derived from the recipient, the funds would be unrecoverable if the recipient later turned out to be sanctioned.

Call isBlockedAddress() before preparing a send to fail fast with a user-friendly error instead of a reverted transaction:

import { isBlockedAddress } from "@zerc20/client-sdk";

const blocked = await isBlockedAddress(readProvider, blocklistAddress, recipientAddress);
if (blocked) {
  throw new Error("Recipient is on the OFAC sanctions blocklist");
}

The blocklist contract address is shared across all zERC20 tokens on the same chain; see Addresses for deployed addresses.

Step 1: Derive Seed

Every private send starts with a seed -- a 32-byte value deterministically derived from a wallet-signed message that seeds the stealth keys.

Use the SDK's deriveSeed() helper. It fetches the seed message, has your wallet sign it, and hashes the signature into the 32-byte seedHex:

deriveSeed() canonicalizes the signature (low-s, 27/28 recovery byte) before hashing, so equivalent high/low-s and 0/1 versus 27/28 encodings of the same signature produce the same seed. Stable derivation still requires deterministic signing. The returned seedHex is a 32-byte hex string.

Do not hash the raw signature yourself (e.g. keccak256(toBytes(signature))). A raw hash is sensitive to ECDSA signature malleability -- a wallet that returns a high-s value or a 0/1 recovery byte would produce a different, unstable seed. The canonicalizing deriveSeed() removes this footgun. If you have invoice funds created under a pre-canonicalization seed (a manual hash or an older deriveSeed()), see Recovering Funds After a Seed Change.

Step 2: Prepare the Private Send

Call preparePrivateSend() to derive the burn address, generate the secret, and build the encrypted announcement payload.

Parameters

preparePrivateSend accepts a single PreparePrivateSendParams object:

Field
Type
Required
Description

client

StealthCanisterClient

Yes

ICP stealth client from sdk.createStealthClient()

recipientAddress

string

Yes

Recipient's EVM address

recipientChainId

number | bigint

Yes

Chain ID the recipient will claim on

seedHex

string

Yes

Canonical 32-byte hex seed returned by deriveSeed() in Step 1

paymentAdviceIdHex

string

No

Optional payment-advice identifier

vetkdKeyIdName

string

No

Override VetKD key ID name

Return Value

preparePrivateSend returns a PreparedPrivateSend object:

Field
Type
Description

burnAddress

string

Deterministic address to send zERC20 to

burnPayload

Uint8Array

Serialized burn data

secret

bigint

Random secret bound to the burn address

tweak

bigint

Poseidon-derived tweak value

generalRecipient

string

Generalized recipient identifier

announcement

object

Encrypted announcement ready for submission

sessionKey

Uint8Array

Ephemeral session key

paymentAdviceId

string

Resolved payment-advice identifier

paymentAdviceIdBytes

Uint8Array

Payment-advice identifier as bytes

Signature

Step 3: Transfer zERC20 to the Burn Address

Use the SDK's submitPrivateSendTransfer() to execute the ERC-20 transfer to the burn address. This helper encapsulates the transfer call using the library-agnostic EvmWriteProvider interface.

Parameters

Field
Type
Required
Description

writeProvider

EvmWriteProvider

Yes

Wallet provider to sign and send the transaction

tokenAddress

string

Yes

zERC20 contract address on the sender's chain

burnAddress

string

Yes

Burn address from preparePrivateSend()

amount

bigint

Yes

Amount to transfer in the token's smallest unit

feeOverrides

FeeOverrides

No

Optional gas-price overrides from buildFeeOverrides

readProvider

EvmReadProvider

No

Provider for receipt polling; falls back to writeProvider

Return Value

Field
Type
Description

transactionHash

Hex

Confirmed transaction hash

Note: You can also execute the transfer manually using any EVM library -- submitPrivateSendTransfer is a convenience wrapper. The important thing is that a standard ERC-20 transfer(burnAddress, amount) call reaches the zERC20 contract.

Signature

Step 4: Submit the Announcement

After the on-chain transfer is confirmed, submit the encrypted announcement to the ICP storage canister so the recipient can discover the transfer.

Parameters

submitPrivateSendAnnouncement accepts a SubmitPrivateSendParams object:

Field
Type
Required
Description

client

StealthCanisterClient

Yes

ICP stealth client

preparation

PreparedPrivateSend

Yes

The object returned by preparePrivateSend()

tag

string

No

Optional tag for filtering announcements

Return Value

Returns a PrivateSendResult confirming that the announcement was persisted.

Signature

Complete Example

Error Handling

Error
Cause
Resolution

SeedSignatureRejected

User rejected the wallet signature prompt

Prompt the user to sign again; the seed message is deterministic and safe to sign

BurnAddressPoWFailed

Proof-of-work check on the derived burn address did not pass

Retry preparePrivateSend() -- a new secret will be sampled

StealthClientNotConnected

createStealthClient() was not called or the ICP agent is unreachable

Verify the ICP agent host and canister IDs

AnnouncementSubmissionFailed

The ICP storage canister rejected the announcement

Check that the canister is available and the announcement payload is well-formed

InsufficientBalance

The sender does not hold enough zERC20 on the source chain

Wrap more underlying tokens via LiquidityManager.wrap() or bridge from another chain

TransactionReverted

The ERC-20 transfer call reverted on-chain

Verify token approval, balance, and that the burn address is valid

See Also

Last updated