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
- A Layerswap API key
- A Privy app with server wallets and gas sponsorship enabled
- Source-token funds on the Privy wallet address
Integration
Create a Layerswap swap
Create the swap with The response includes
use_depository: true for the Privy wallet address:use_depository: true is recommended when using Layerswap from a contract or a server wallet.deposit_actions with everything needed for the on-chain calls:Check allowance and build the call batch
For ERC-20 transfers, the wallet needs to approve the depository contract before the bridge call:
Submit the sponsored transaction
Submit the batched calls with Privy Privy returns a
wallet_sendCalls and sponsor: true:transaction_id — poll privyClient.transactions().get(transactionId) until transaction_hash is available, then use it in the next step.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.