Swaps (Alpha)
Swap any token across networks. Integrate in minutes. Built natively into Smart Wallets.
- 1-click Swap + Action (ex: send, deposit, borrow, pay)
- Gasless swaps
- [Coming soon] Cross-chain swaps
Swaps are in early access. The service is production ready, however there may be changes in the future to simplify the endpoint. We will let you know if/when that happens.
The Swap flow
Flow
- Request a swap quote
- Sign the prepared calls (swap + post swap action)
- Send prepared calls (swap + post swap action)
- Poll for confirmation
Swap options
Prerequisites
Before you begin, ensure you have:
- An Alchemy API Key
- A Gas Manager policy
- A small amount of USDC for testing (~$1 worth is enough!)
- Important: You’ll need to send these tokens to your smart wallet address in Step 3 of the Implementation!
- A signer to own the account and sign messages
Note that Swaps are currently only supported via direct APIs. React and other JS options are coming (very) soon!
APIs
JavaScript
React
You will need to fill in values wrapped in curly braces like {SIGNER_ADDRESS}
.
Request a swap quote
Note that postCalls
are optional and allow you to batch an array of calls after the swap.
This returns:
Note the signatureRequest
! This is what you now have to sign, and the returned data
field is what you will need to send the transaction!
Sign the signature request
To sign the signature request, you should sign the raw
field (note, this is not a string! You need to pass it to your signer as raw bytes, generally like so: { raw: "0x..." }
) with your signer of choice.
This should use the personal_sign
RPC method, as noted by the type
in the signatureRequest
.
Alternatively, you can sign the raw payload with a simple eth_sign
but this RPC method is not favored due to security concerns.
Send the prepared call
This returns:
Note the PREPARED_CALL_ID
! You need this to track call status in the next step.
For other potential responses, check out the API reference!
Track the prepared call
You can use the wallet_getCallsStatus
endpoint to check up on the transaction’s status.
This returns:
Note that the status codes match the following:
To get your transaction hash, you can access result.receipts[0].transactionHash
.
For more details, check out the API reference!
FAQs
What chains are supported?
Chains supported (for now) are: Ethereum, Arbitrum, Base, Berachain, BSC/BNB, Ink, Monad, Optimism, Polygon, Unichain and World Chain mainnets.
Does the Swap API support cross-chain swaps?
Currently, the Swap API supports only single-chain swaps. Cross-chain swaps are coming soon!
How do you encode values?
Values are simply passed as hexadecimal strings. The Swap API doesn’t add complexity to consider decimals, so 0x01 is always the smallest amount of a given asset.
1 ETH, or DAI (18 decimals) is 0xDE0B6B3A7640000
1 USDC (6 decimals) is 0xF4240
This removes any ambiguity— if it’s numerical, it’s a hex.
What is the expiry?
The expiry is an informational indicator of when you can expect to be able to process the swap request. If you’re at/near the expiry, it might be a good time to request a new quote.
What if I’m using React?
Use the @account-kit/react
package to access a smartWalletClient
. This package automatically uses the Signer for user authentication & signing. Check out the docs for getting started with React to learn more.