Skip to main content

Overview

When you create a swap via POST /api/v2/swaps, the response includes a deposit_actions array. Each transfer action contains the destination address, amount, and a blockchain-specific call_data payload — everything you need to construct and submit a transaction on the source chain. After broadcasting the transaction, you notify Layerswap with the transaction hash via the speedup endpoint so it can match the deposit and complete the swap.

Transfer Action Schema

Each item in the deposit_actions array has the following structure:
type
string
required
Either transfer (wallet transaction) or manual_transfer (manual deposit to an address). Use the action with type: "transfer" for programmatic transfers.
to_address
string
The deposit address to send funds to.
amount
number
required
The amount to transfer in human-readable units (e.g. 0.1 ETH, not wei).
amount_in_base_units
string
required
The amount in the token’s smallest unit (e.g. wei for ETH, satoshi for BTC).
call_data
string
required
Blockchain-specific payload used to construct the transaction. The format varies by chain — see the chain-specific guides below.
network
object
required
The source network object, including name, type, chain_id, and node_url.
token
object
required
The token being transferred, including symbol, decimals, and contract (null for native tokens).
fee_token
object
required
The token used to pay transaction fees on this network.
order
number
required
Execution order if there are multiple transfer actions.

Step-by-Step Flow

1

Create a Swap

Call POST /api/v2/swaps with use_deposit_address: false and include the source_address parameter. The response will contain deposit_actions.
curl -X POST https://api.layerswap.io/api/v2/swaps \
  -H "X-LS-APIKEY: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "source_network": "ETHEREUM_MAINNET",
    "source_token": "ETH",
    "destination_network": "ARBITRUM_MAINNET",
    "destination_token": "ETH",
    "destination_address": "0xRecipient...",
    "source_address": "0xSender...",
    "amount": "0.1",
    "use_deposit_address": false
  }'
2

Extract the Transfer Action

From the response, find the transfer action with type: "transfer":
const response = await createSwap(/* ... */);
const depositAction = response.deposit_actions.find(
  action => action.type === "transfer"
);

const { call_data, to_address, amount, network, token } = depositAction;
3

Execute the Transaction

Use the call_data, to_address, and amount to construct and send a blockchain-specific transaction. See the chain guides below for implementation details.
4

Notify Layerswap

After the transaction is submitted, call the speedup endpoint so Layerswap can match it faster:
curl -X POST https://api.layerswap.io/api/v2/swaps/{swap_id}/deposit_speedup \
  -H "X-LS-APIKEY: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{ "transaction_id": "0xYourTransactionHash..." }'
5

Monitor Status

Poll GET /api/v2/swaps/{swap_id} or use webhooks to track the swap through its lifecycle.

call_data Format by Chain

The call_data field is the key piece — its format depends on the source blockchain:
Blockchaincall_data FormatGuide
EVM (Ethereum, Arbitrum, Base, etc.)Hex-encoded transaction data (0x...)EVM Guide
BitcoinNumeric memo (encoded as OP_RETURN)Bitcoin Guide
SolanaBase64-encoded serialized transactionSolana Guide
StarknetJSON array of Starknet callsStarknet Guide
TONJSON object with comment (and amount for Jettons)TON Guide
TronString memo (hex-encoded into transaction data)Tron Guide
FuelJSON object with script and quantitiesFuel Guide