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

Operator approvals

How to approve another address to act on your confidential tokens.

Operator approval lets another address (a DEX contract, multisig, or automated service) transfer confidential tokens on your behalf. This is the FHE equivalent of ERC-20's approve / transferFrom pattern.

Steps

1. Approve an operator

Call setOperator on a token instance. By default, the approval is valid for 1 hour:

const token = sdk.createToken("0xEncryptedERC20");

// Approve with the default 1-hour duration
await token.setOperator("0xOperator");

The SDK sends a single on-chain transaction. The operator can call confidentialTransferFrom until the approval expires.

2. Approve with a custom expiry

Pass a Unix timestamp (in seconds) as the second argument to set a longer or shorter approval window:

// Approve until a specific timestamp (e.g. 24 hours from now)
const expiry = Math.floor(Date.now() / 1000) + 86400;
await token.setOperator("0xOperator", expiry);

3. Check operator status

Query whether a spender is currently an approved operator:

4. Use operator transfer

Once approved, the operator can transfer tokens from the owner's confidential balance:

The amount is encrypted before submission, just like a regular confidentialTransfer. On-chain observers see the transaction but not the value.

5. React: use the operator hooks

The React SDK provides hooks that wrap these operations with loading states and error handling:

6. Finalize-unwrap operator approval

Operator approval also applies to the unshield (unwrap + finalize) flow. If an operator needs to unshield tokens on the owner's behalf, the owner must approve the operator separately for this action. The approval mechanism is the same -- token.setOperator("0xOperator") -- and the operator can then call unshield or unshieldAll on the owner's tokens.

This is a distinct concern from transfer approval: approving an operator for transfers does not automatically allow them to unshield.

Next steps

Last updated