Skip to main content
On EVM networks, call_data is the hex-encoded transaction data. Submit it with the returned to_address and exact amount_in_base_units.

How the action differs by token

  • For a native token, to_address is the deposit recipient, amount_in_base_units is the transaction value, and call_data contains the matching memo.
  • For an ERC-20 token, to_address is the token contract, amount_in_base_units is normally 0, and call_data contains the encoded transfer(address,uint256) call plus Layerswap’s matching data. The token amount is already encoded in the calldata.
  • For manual_transfer, call_data is null; send the exact source asset to the generated address.
Do not replace the recipient, token amount, or memo encoded in call_data.

Transaction construction

1

Parse the deposit action

Extract call_data, to_address, amount_in_base_units, and network.chain_id from the deposit action.
2

Build the transaction

Construct a transaction object with the deposit action fields mapped to standard EVM transaction parameters.
3

Estimate gas (optional)

Call eth_estimateGas for a more accurate gas limit. If estimation fails, the transaction can still be sent without an explicit gas limit — the wallet or node will estimate it.
4

Send the transaction

Sign and broadcast the transaction, then return the hash.

Full example

Pick the library that fits your stack. The viem and ethers.js tabs cover server-side or Node.js use; the wagmi tab is for browser use with a connected wallet.
Using the integer amount_in_base_units avoids float rounding and works for both native-token actions and ERC-20 actions whose native transaction value is zero. When using a browser wallet, confirm the user is connected to action.network.chain_id and prompt a network switch before sending. For a manual ERC-20 action, call the token contract’s transfer function as in the viem and ethers.js examples instead of sending a transaction with empty data.

Funding via the Depository

The examples above cover the direct-transfer and deposit-address methods. If the swap was created with use_depository: true, the deposit action targets the on-chain Depository contract instead — submit its call_data, and for ERC-20 approve the contract first:
viem
See Funding methods for when to use each. After broadcasting, store the transaction hash and track the swap.