Skip to main content
This flow bridges ERC-20 tokens through Layerswap using a Privy server wallet. It creates a swap with use_depository: true, batches the token approval with the bridge call, and submits everything through Privy’s gas sponsorship — so the wallet doesn’t need native tokens for gas. See the full example on GitHub.

Prerequisites

Testnets are supported — use a testnet API key from the dashboard and get testnet funds from the Circle faucet.

Integration

1

Create a Layerswap swap

Create the swap with use_depository: true for the Privy wallet address:
use_depository: true is recommended when using Layerswap from a contract or a server wallet.
The response includes deposit_actions with everything needed for the on-chain calls:
2

Check allowance and build the call batch

For ERC-20 transfers, the wallet needs to approve the depository contract before the bridge call:
If allowance is already sufficient the approve call is skipped. Otherwise both calls are batched into a single sponsored wallet_sendCalls request.
3

Submit the sponsored transaction

Submit the batched calls with Privy wallet_sendCalls and sponsor: true:
Privy returns a transaction_id — poll privyClient.transactions().get(transactionId) until transaction_hash is available, then use it in the next step.
4

Check the swap status

After Privy returns the final chain transaction hash, look it up through Layerswap:
This maps the final transaction back to the Layerswap swap record. See the Swap Lifecycle for all possible statuses.