swap
swap tokens
/bsc/pcs/swap
POST https://cryptotalk-public-gateway-byeii62k.de.gateway.dev/bsc/pcs/swap
Support all swap requests : token to token, token to BNB, BNB to token.
Sample code is given below.
Request body
1. addr : Wallet address
2. frm_tkn_addr : Token to be swapped from
3. to_tkn_addr: Token to be swapped to
4. amt_float: input amount as floating point (keep max decimals to 7)
5. slippage: desired slippage (0.01 for 1%, 0.03 for 3% and so on)
6. path: Path that should be taken to swap tokens (ex: BNB > BUSD > USDC)
7. min_output_amt: Minimum acceptable returned amount
8. isInputFixed: send true if input amount is fixed, send false is output amount is fixed
Query Parameters
key
string
API Key
Request Body
params
object
{
"to_tkn_addr" "0xbb4cdb9..c095c",
"frm_tkn_addr" : "0xeeee..eeeeeeee", "amt_float" : 0.1,
"min_output_amt" : 0.1,
"gas" : "10",
"isInputFixed" : true,
"slippage" : 0.01,
"addr" : "0xaaaa..4",
"path" : []
}
{
isError: false,
errorMsg: 'NA',
methodName: 'swapExactTokensForTokens',
rawTx: {
from: '0x5585d5365f37671eecc0fdcac5a06bd1d176408e',
value: '0x0',
to: '0x05ff2b0db69458a0750badebc4f9e13add608c7f',
data: '0x38ed173900000000000000000000000000000000000000000000000000b03006698f2000000000000000000000000000000000000000000000000000c21f642a306e780000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000005585d5365f37671eecc0fdcac5a06bd1d176408e00000000000000000000000000000000000000000000000000000000605059200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000a184088a740c695e156f91f5cc086a06bb78b827000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d560000000000000000000000000e09fabb73bd3ade0a17ecc321fd13a19e81ce82',
nonce: '0xf24',
gasLimit: '0x7a120',
gasPrice: '0x2540be400'
}
}Sample code to swap 0.05 AUTO token to BUSD through pancake swap
Last updated
Was this helpful?