Skip to main content
Get your API key at hackathon-apikey.vercel.app.
Deposit ERC-20 tokens into the unlink contract. The deposit goes into the account bound to your unlink client (set via createUnlink(), see Quickstart). Lazily registers the account on first call.
const result = await unlink.deposit({
  token: "0xTokenAddress",
  amount: "1000000000000000000",
});

const confirmed = await unlink.pollTransactionStatus(result.txId);

Parameters

ParameterTypeRequiredDescription
tokenstringYesERC-20 token address
amountstringYesAmount in wei
deadlinenumberNoPermit2 deadline (unix seconds). Defaults to 1 hour from now.
noncestringNoOverride Permit2 nonce (auto-managed by default)
evmUnlinkEvmProviderNoOverride the EVM provider for this call
Returns: { txId: string; status: string }

Approvals

Before the first deposit of a given token, the token must be approved for Permit2 on-chain. The SDK provides helpers:
const result = await unlink.ensureErc20Approval({
  token: "0xTokenAddress",
  amount: "1000000000000000000",
});

if (result.status === "submitted") {
  // Wait for tx to be mined before depositing
  console.log("Approval tx:", result.txHash);
}
// If result.status === "already-approved", no transaction was needed
This is a one-time step per token. After approval, all future deposits use gasless Permit2 signatures. You can also check the approval state or build the transaction manually:
const state = await unlink.getApprovalState({ token, amount });
// state.isApproved: boolean

const tx = await unlink.buildApprovalTx({ token, amount });
// tx: { to: string; data: string; value?: bigint }
Approval methods require an EVM provider with getErc20Allowance. ensureErc20Approval also requires sendTransaction.