Swap RPC
getSwap
Learn how to use the getSwap JSON-RPC method.
POST
/
#particle_swap_getSwap
Understanding getSwap
getSwap
returns a detailed object containing swap information, a price quote, and a complete transaction object to have the user sign for swap execution. It takes:address
- string.- Swap information object:
fromTokenAddress
- string.toTokenAddress
- string.amount
- string.slippage
- integer.
Query example
JSON
{
"id": 1,
"jsonrpc": "2.0",
"method": "particle_swap_getSwap",
"params": [
"0x369aa8a7a7BE683E1a46d9A056806B2B3FD778C8",
{
"fromTokenAddress": "0x111111111117dc0aa78b770fa6a738034120c302",
"toTokenAddress": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"amount": "1000000000",
"slippage": 1
}
]
}
Authorizations
Authorization
string
headerrequiredBasic authentication header of the form Basic <encoded-value>
, where <encoded-value>
is the base64-encoded string username:password
.
Body
application/json
jsonrpc
string
default: 2.0requiredVersion of the JSON-RPC protocol, should be 2.0.
id
integer
default: 1requiredThe request identifier.
method
enum<string>
requiredAPI method being called.
Available options:
particle_swap_getSwap
params
array
requiredParameters for executing a swap.
chainId
integer
The blockchain chain ID.
Response
200 - application/json
jsonrpc
string
default: 2.0requiredVersion of the JSON-RPC protocol, should be 2.0.
id
integer
default: 1requiredThe request identifier.
result
object
requiredSwap transaction details.
chainId
integer
The blockchain chain ID.
Was this page helpful?