预兑换请求
选择完币对,点击兑换时,如果是 BRC20,需要先请求预兑换接口
POST
/brc20swap/get_swap_psbt_txsize
export interface SwapPsbtTxsizeBody {
send_coin_type: string;
send_tick: string;
send_amount: string;
receive_coin_type: string;
receive_tick: string;
receive_amount: string;
address: string;
btc_address: string;
slipper: string; // 最大值为12
fee_rate: number;
ins: string[]; //铭文块id即inscription_id数组。当使用btc兑换brc20代币时,直接给空数据即可
}
// btc-brc20
{
"receive_amount": "941.34826088",
"receive_coin_type": "brc20",
"receive_tick": "yydd",
"send_amount": "1000",
"send_coin_type": "btc",
"send_tick": "BTC",
"slipper": 9,
"fee_rate": 11,
"ins": [],
"address": "tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e",
"btc_address": "tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e"
}
// brc20-btc
{
"receive_amount": "864",
"receive_coin_type": "btc",
"receive_tick": "BTC",
"send_amount": "100",
"send_coin_type": "brc20",
"send_tick": "bqbq",
"slipper": 9,
"fee_rate": 11,
"ins": [
"22d16b84841c73a8e44db501b3e397aa6031e8a6e7092e2165e588c389ff9e8ci0"
],
"address": "tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e",
"btc_address": "tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e"
}
# btc-brc20
curl 'https://test-api-proxy.ddpurse.com/brc20swap/get_swap_psbt_txsize' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Accept-Language: en' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Origin: http://localhost:56651' \
-H 'Pragma: no-cache' \
-H 'Referer: http://localhost:56651/' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: cross-site' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
-H 'sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw '{"receive_amount":"941.34826088","receive_coin_type":"brc20","receive_tick":"yydd","send_amount":"1000","send_coin_type":"btc","send_tick":"BTC","slipper":9,"fee_rate":11,"ins":[],"address":"tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e","btc_address":"tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e"}' \
--compressed
# brc20-btc
curl 'https://test-api-proxy.ddpurse.com/brc20swap/get_swap_psbt_txsize' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Accept-Language: en' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Origin: http://localhost:56651' \
-H 'Pragma: no-cache' \
-H 'Referer: http://localhost:56651/' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: cross-site' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
-H 'sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw '{"receive_amount":"864","receive_coin_type":"btc","receive_tick":"BTC","send_amount":"100","send_coin_type":"brc20","send_tick":"bqbq","slipper":9,"fee_rate":11,"ins":["22d16b84841c73a8e44db501b3e397aa6031e8a6e7092e2165e588c389ff9e8ci0"],"address":"tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e","btc_address":"tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e"}' \
--compressed
1、这个接口中的 address
,btc_address
传同一个地址即可
2、这个接口返回的结果,原值传到 get_swap_psbt
接口
3、注意当前 slipper
(滑点)的限制为,不超过 12%
Last updated