Step 3: Get token approval
This section is only applicable to transfers of non-native tokens. Non-native tokens include governance tokens, wrapped tokens, stablecoins, and oracle tokens.
The full API reference for our /approve endpoint can be found in the API reference section.
If you are performing a transfer with a non-native token, our Swing Contract requires the right allowance limit to spend/withdraw funds (denominated in non-native tokens) from the designated wallet address.
Depending on the non-native token amount you are looking to transfer, you want to call our /approve
endpoint with a limit greater than or equal to the amount you are transferring.
You can use the /allowance
endpoint to determine if you have already approved a sufficient limit to allow your non-native token transfer. Importantly, the allowance limit is specific to the token, chain and bridge. So you must approve an allowance limit every time for every unique transfer combination of token, chain or bridge.
Allowance Endpoint
We can query our /allowance
endpoint in the following manner to get the allowance limit:
This will always only return the allowance limit for that specific token, on the specific chain for that specific bridge:
Approve Endpoint
If you need to approve a higher allowance limit, you can query our /approve
endpoint in the following manner:
Since approve is a contract-level function, Swing only returns the necessary call-data that will need to be signed and executed by the local wallet (ie. Metamask, Coinbase Wallet, WalletConnect, etc).