Overview
This guide covers all EVM-compatible networks supported by Layerswap, including Ethereum, Arbitrum, Optimism, Base, Polygon, Linea, zkSync Era, Scroll, and others. Prerequisites:call_data Format
For EVM chains,call_data is a hex-encoded string (0x...) representing the transaction’s data field. It always carries a Layerswap memo (a fixed prefix followed by a sequence number) that the backend uses to match the deposit:
- Native token transfers (ETH, MATIC, etc.):
call_datais the memo hex.to_addressis the deposit address andamount/amount_in_base_unitscarry the value to send. - ERC-20 token transfers:
call_datais the encodedtransfer(address,uint256)function call with the memo hex appended.to_addressis the token contract, andamount/amount_in_base_unitsare0— the actual transfer value is encoded insidecall_data.
to: to_address, value: amount, and data: call_data and the wallet will route it correctly.
Transaction Construction
1
Parse the deposit action
Extract
call_data, to_address, amount, 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. Theviem and ethers.js tabs cover server-side or Node.js usage. The wagmi tab is for browser-side use with a connected wallet.
When using a browser wallet (wagmi), ensure the user is connected to the correct chain (
network.chain_id). If not, prompt them to switch networks before sending the transaction.Funding via the Depository
The example above covers the direct transfer and deposit address methods. If you created the swap withuse_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
Next Step
After the transaction is submitted, notify Layerswap so it can match your deposit faster:use_depository).