query_fees_and_calldata
/query_fees_and_calldata
查詢代幣路徑、需要多少 sell_token 以購買 buy_amount 的 buy_token,估計將使用多少 gas,此交易需要多少本地代幣,以及閘道器合約的 calldata。
對於 sell_token,gateway 可以接受在 DEX 上有流動性的任何代幣,對於 buy_token,請參考這個代幣列表
參數
| 類型 | 名稱 | 詳細說明 |
|---|---|---|
| str(限用 EVM 地址) | token_from | 用戶將要支付的代幣地址 |
| str(限用 EVM 地址) | token_to | 收件人希望接收的代幣地址 |
| Networks | network_from | 交易的來源網路 |
| Networks | network_to | 交易的目的網路 |
| int | buy_amount | 要購買多少 token_to |
| str(限用 EVM 地址) | sender | 將要發送交易的地址 |
| str(限用 EVM 地址) | recipient | 將要接收代幣的地址 |
請求
curl --location '127.0.0.1:8000/query_fees_and_calldata' \
--header 'Content-Type: application/json' \
--data '{
"token_from": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
"token_to": "0x07865c6E87B9F70255377e024ace6630C1Eaa37F",
"network_from": "Goerli",
"network_to": "Mumbai",
"buy_amount": 1000000000,
"sender": "0xC2f3FB1200cDe5723b502F307899b8eeC8231FE5",
"recipient": "0xC2f3FB1200cDe5723b502F307899b8eeC8231FE5"
}'
回應
{
"gas": 3000000,
"value": 5880062368050,
"gasPrice": 19,
"nonce": 302,
"chainId": 5,
"to": "0xd27D8BE950aCA62efCD0Ef83eB148305D39225EB",
"data": "0xbf47814a0000000000000000000000000000000000000000000000000000000000000...",
"sell_amount": 21705054,
"path": {
"Goerli": [
{
"name": null,
"address": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6"
},
{
"name": "usdc",
"address": "0xDf0360Ad8C5ccf25095Aa97ee5F2785c8d848620"
}
],
"Mumbai": [
{
"name": "usdc",
"address": "0x742DfA5Aa70a8212857966D491D67B09Ce7D6ec7"
},
{
"name": null,
"address": "0x07865c6E87B9F70255377e024ace6630C1Eaa37F"
}
]
}
}