description |
---|
Integrate Swap seamlessly into your dApp |
- If from token is ERC20 token, need to check if user has approved enough amount for the swap contract to use by calling
particle_swap_checkApprove
- (Optional) Sign, send and wait for the approve tx confirmed
- Get quote by calling
particle_swap_getQuote
- Get swap by calling
particle_swap_getSwap
- Sign, send and wait for the swap tx confirmed
📢 For Native token like ETH, use this address
0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- Ethereum Mainnet
- BNB Chain Mainnet
- Polygon Mainnet
- Optimism Mainnet
- Arbitrum One
- Avalanche C-Chain Mainnet
- Fantom Mainnet
- Aurora Mainnet
- Gnosis Mainnet
- Klaytn Mainet
- zkSync Era Mainnet
- Mantle Mainnet
- OKTC Mainnet
- Moonriver Mainnet
- Moonbeam Mainnet
- Celo Mainnet
- Cronos Mainnet
- 1inch: https://1inch.io/
- izi-swap: https://izumi.finance/
- lifi: https://li.fi/
Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "particle_swap_checkApprove",
"params": [
"0x369aa8a7a7BE683E1a46d9A056806B2B3FD778C8", // wallet address
{
"tokenAddress": "0x111111111117dc0aa78b770fa6a738034120c302", // from token address
"amount": "1000000000"
}
]
}
Response
{
"jsonrpc": "2.0",
"id": 0,
"result": {
"approved": true
},
"chainId": 1
}
{
"jsonrpc": "2.0",
"id": 0,
"result": {
"approved": false,
"tx": { // Construct a complete transaction on the client side.
"to": "0x111111111117dC0aa78b770fA6A738034120C302",
"data": "0x095ea7b30000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d000000000000000000000000000000000000000000000000000000003b9aca00",
"value": "0x0",
}
},
"chainId": 1
}
Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "particle_swap_getQuote",
"params": [
"0x369aa8a7a7BE683E1a46d9A056806B2B3FD778C8", // wallet address
{
"fromTokenAddress": "0x111111111117dc0aa78b770fa6a738034120c302",
"toTokenAddress": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"amount": "1000000000"
}
]
}
Response
{
"jsonrpc": "2.0",
"id": 0,
"result": {
"fromToken": {
"chainId": 1,
"address": "0x111111111117dC0aa78b770fA6A738034120C302",
"symbol": "1INCH",
"name": "1INCHToken",
"decimals": 18,
"logoURI": "https://static.particle.network/token-list/ethereum/0x111111111117dC0aa78b770fA6A738034120C302.png"
},
"toToken": {
"chainId": 1,
"address": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"symbol": "DAI",
"name": "DaiStablecoin",
"decimals": 18,
"logoURI": "https://static.particle.network/token-list/ethereum/0x6B175474E89094C44Da98b954EedeAC495271d0F.png"
},
"toTokenAmount": "781970036",
"fromTokenAmount": "1000000000",
"estimatedGas": "0x4079f"
},
"chainId": 1
}
Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "particle_swap_getSwap",
"params": [
"0x369aa8a7a7BE683E1a46d9A056806B2B3FD778C8",
{
"fromTokenAddress": "0x111111111117dc0aa78b770fa6a738034120c302",
"toTokenAddress": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"amount": "1000000000",
"slippage": 1
}
]
}
Response
{
"jsonrpc": "2.0",
"id": 0,
"result": {
"fromToken": {
"chainId": 1,
"address": "0x111111111117dC0aa78b770fA6A738034120C302",
"symbol": "1INCH",
"name": "1INCHToken",
"decimals": 18,
"logoURI": "https://static.particle.network/token-list/ethereum/0x111111111117dC0aa78b770fA6A738034120C302.png"
},
"toToken": {
"chainId": 1,
"address": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"symbol": "DAI",
"name": "DaiStablecoin",
"decimals": 18,
"logoURI": "https://static.particle.network/token-list/ethereum/0x6B175474E89094C44Da98b954EedeAC495271d0F.png"
},
"toTokenAmount": "781970036",
"fromTokenAmount": "1000000000",
"tx": { // Construct a complete transaction on the client side.
"to": "0x1111111254fb6c44bAC0beD2854e76F90643097d",
"data": "0x000",
"value": "0x0",
}
},
"chainId": 1
}