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

Withdrawing Stuck Tokens

If unsupported tokens are sent to a smart routing address, the owner can recover them. getWithdrawTokensCalls returns the calls to send from the owner on each chain.

import { getWithdrawTokensCalls } from "@zerodev/smart-routing-address";

const { data, receiver } = await getWithdrawTokensCalls({
  smartRoutingAddress: "0x...", // your smart routing address
  tokens: [
    { chainId: 42161, token: "0xaf88d065e77c8cc2239327c5edb3a432268e5831" }, // USDC on Arbitrum
    { chainId: 8453, token: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913" }, // USDC on Base
  ],
});

for (const { chainId, calls } of data) {
  // send `calls` from the owner of the smart routing address on `chainId`
}

Parameters

NameTypeDescription
smartRoutingAddressAddressThe smart routing address holding the stuck tokens.
tokens{ chainId: number; token: Address }[]The tokens to withdraw, one entry per token per chain.

Return value

type GetWithdrawTokensCallReturns = {
  data: {
    chainId: number;
    calls: Call[]; // viem `Call`: { to: Address; data?: Hex; value?: bigint }
  }[];
  receiver: Address;
};
  • data — one entry per chain, with the calls to send from the owner on that chain. value is already a bigint, so the calls can be passed straight to sendCalls or sendTransaction.
  • receiver — the address the withdrawn tokens are sent to.

On this page