Skip to main content

Overview

The Depository is a Layerswap-operated smart contract that acts as an on-chain entry point for funding a swap. Your wallet calls a single method on the Depository contract; it records the deposit, tags it with the identifier of your swap, and forwards the funds to the solver that fills it. Layerswap watches for the resulting Deposited event and progresses your swap automatically. This is the recommended funding path when you are integrating Layerswap as an aggregator, or when funding from a smart-contract wallet, server wallet, or any programmable wallet (e.g. Privy, Safe, account-abstraction wallets).
Layerswap encodes the call for you. When you create a swap with use_depository: true, the deposit action includes the contract address (to_address) and the fully encoded call_data — so the simplest path is to submit call_data as-is (plus a token approval for ERC20). The individual arguments, including the swap id and receiver that Layerswap assigns, are also returned in encoded_args if you’d rather build or verify the call yourself.
The Depository is one of three ways to fund a swap — see Choosing a method for how it compares to a deposit address or a direct transfer, and when to use each. The Depository and deposit-address methods are mutually exclusive — setting both use_depository: true and use_deposit_address: true is rejected.

Supported networks

  • EVM chains where a Depository contract is deployed. Native and ERC20 deposits are both supported.
  • TronTRC20 tokens only. Native TRX deposits via the Depository are not supported.
If you request use_depository: true on a network that does not have a Depository deployed, swap creation fails with an “unsupported depository” error. The set of enabled networks grows over time — always rely on the to_address returned by the API rather than hard-coding addresses (see Contract addresses).

How it works

  1. Create the swap with use_depository: true.
  2. Fetch the deposit actions (returned inline on swap creation, or via GET /swaps/{swapId}/deposit_actions). The action’s to_address is the Depository contract and call_data is the encoded deposit call.
  3. For ERC20 only: approve the Depository contract (to_address) to spend the token amount.
  4. Submit the transaction to to_address with the returned call_data (and value for native deposits — see below).
  5. Layerswap detects the on-chain Deposited event, correlates it to your swap via the embedded id, and completes delivery on the destination chain.

The contract

The Depository exposes two deposit methods:
On a successful deposit the contract emits:

Using the Depository via the API

1. Create the swap

See the Create Swap endpoint for the full request schema.

2. Read the deposit action

The response includes a deposit_actions array. For a Depository swap the relevant fields are:
For ERC20 the top-level amount is 0 (no native value is sent). The token and amount live inside call_data / encoded_args, so you must approve first — see below.

3. Approve (ERC20 only)

Before calling depositERC20, approve the Depository contract (to_address) to spend the deposit amount. Native deposits skip this step.

4. Submit the deposit transaction

viem
The swap id and the receiver are assigned by Layerswap — use the exact values from the deposit action. Submitting call_data as-is is the safest option; if you instead rebuild the call from encoded_args, don’t alter those two values, or Layerswap won’t be able to match the on-chain deposit to your swap.

Deposit detection

The id argument encoded in call_data ties your on-chain deposit to your swap. Layerswap monitors the Deposited event and matches its id back to your swap, then fills the destination side. From this point the swap follows the normal swap lifecycle.

Contract addresses

The authoritative Depository address for a given swap is always the to_address returned in the deposit action — read it per swap rather than caching a global value, since deployments are added over time and a few chains use a different address. Most EVM chains share a single deterministically-deployed Depository address. A small number of chains (e.g. those where deterministic deployment wasn’t possible) use a chain-specific address. In all cases, trust the API response.

Common errors