Skip to main content
Deposit ERC-20 tokens into the unlink contract. The deposit goes into the account bound to your user client. See Quickstart. Call client.ensureRegistered() once before depositing. A deposit’s amount, token, and source wallet are public; see How Unlink works. Before opening the EVM wallet signature prompt, the SDK verifies that the prepared note belongs to the client’s bound Unlink address, matches the requested token and amount, and reconstructs the notes_hash included in the Permit2 witness. A malformed or redirected prepare response is rejected without being signed.
The SDK currently hash-binds the Engine-returned ciphertext but does not decrypt and validate its plaintext. Invalid ciphertext cannot redirect the note after the recipient NPK check, but it can make the deposited note undiscoverable. The SDK also currently trusts the Engine’s reported chain, pool, and Permit2 addresses; see Trust model.
The prepare response must include prepared_artifacts. An SDK with deposit verification fails closed against an older Engine that omits them. Operators must deploy the compatible Engine to every tier before publishing or adopting the protected SDK release. Older SDK versions remain unprotected until the integrator upgrades them. The recommended path is depositWithApproval(). It runs the Permit2 approval when needed, waits for confirmation, and then runs the deposit in one call. It requires an EVM provider. See EVM provider setup. Use deposit() directly only when the token is already approved or when you want raw control over the approval flow.

Parameters (depositWithApproval)

Required fields:
  • token: ERC-20 token address.
  • amount: amount in wei.
Optional fields:
  • deadline: Permit2 deadline. Defaults to one hour from now.
  • nonce: override Permit2 nonce. The SDK manages this by default.
  • evm: override the EVM provider for this call.
  • waitForApproval: override the approval-confirmation wait.
Returns: a TransactionHandle. See Transaction status.

Advanced: separate approval + deposit

If you’ve already arranged Permit2 approval out of band, or you want to integrate the approval into a custom receipt-polling pipeline, use the lower-level helpers:
You can also inspect approval state or build the approval transaction manually:
Approval methods require an EVM provider with getErc20Allowance. ensureErc20Approval and depositWithApproval also require sendTransaction. See Quickstart for a compact browser setup.