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. 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.
const tx = await client.depositWithApproval({
  token: "0xTokenAddress",
  amount: "1000000000000000000",
});

const confirmed = await tx.wait();
console.log(confirmed.confirmationStatus); // "confirmed" | "processed" | "failed"

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:
const approval = await client.ensureErc20Approval({
  token: "0xTokenAddress",
  amount: "1000000000000000000",
});

if (approval.status === "submitted") {
  // Wait for tx to be mined before depositing
  console.log("Approval tx:", approval.txHash);
}
// If approval.status === "already-approved", no transaction was needed

const tx = await client.deposit({
  token: "0xTokenAddress",
  amount: "1000000000000000000",
});

await tx.wait(); // resolves at user-facing confirmation by default
You can also inspect approval state or build the approval transaction manually:
const state = await client.getApprovalState({ token, amount });
// state.isApproved: boolean

const approvalTx = await client.buildApprovalTx({ token, amount });
// approvalTx: { to: string; data: string; value?: bigint }
Approval methods require an EVM provider with getErc20Allowance. ensureErc20Approval and depositWithApproval also require sendTransaction. See Quickstart for a compact browser setup.