Get Unsigned Swap PSBT
Last updated
Last updated
export interface SwapPsbtBody {
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;
fee_rate: number;
user_public_key: string;
token: string; // swap-info拿到的token
}
{
"receive_amount": "0.004",
"receive_coin_type": "runes",
"receive_tick": "BEVMRUNESTONET",
"send_amount": "100000",
"send_coin_type": "btc",
"send_tick": "BTC",
"slipper": 9,
"fee_rate": 57,
"ins": [],
"token": "d7eb91e4f000000:0",
"user_public_key": "02d3ac7452920b1cc4653516dd4f4381a2df0a8c0aac6e3446e633a73ea63eee81:02d3ac7452920b1cc4653516dd4f4381a2df0a8c0aac6e3446e633a73ea63eee81",
"address": "tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e",
"btc_address": "tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e"
}
curl 'https://test-api-proxy.ddpurse.com/brc20swap/get_swap_psbt2' \
-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/124.0.0.0 Safari/537.36' \
-H 'sec-ch-ua: "Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw '{"receive_amount":"0.004","receive_coin_type":"runes","receive_tick":"BEVMRUNESTONET","send_amount":"100000","send_coin_type":"btc","send_tick":"BTC","slipper":9,"fee_rate":57,"ins":[],"token":"d7eb91e4f000000:0","user_public_key":"02d3ac7452920b1cc4653516dd4f4381a2df0a8c0aac6e3446e633a73ea63eee81:02d3ac7452920b1cc4653516dd4f4381a2df0a8c0aac6e3446e633a73ea63eee81","address":"tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e","btc_address":"tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e"}'
After obtaining the unsigned PSBT, the user must sign it within 30 seconds.
Use the same address for both btc_address
and address
.
For user_public_key
, provide the parameter as public_key:public_key
for a wallet with one address, or btc_public_key:ordi_public_key
for a wallet with two addresses.
The token
must be retrieved from the /swap-info
endpoint and can only be used once.
token
Use swap for non-routing, pools_swap for routing. Default pools_swap
curl -L \
--request POST \
--url '/brc20swap/get_swap_psbt2' \
--header 'Content-Type: application/json' \
--data '{
"receive_amount": "9074",
"receive_coin_type": "runes",
"receive_tick": "SHE•SHE•SHE•SHE•SHE",
"send_amount": "100000",
"send_coin_type": "btc",
"send_tick": "BTC",
"slipper": 9,
"fee_rate": 2,
"token": "ee1fbac24400000:0",
"user_public_key": "02d3ac7452920b1cc4653516dd4f4381a2df0a8c0aac6e3446e633a73ea63eee81:02d3ac7452920b1cc4653516dd4f4381a2df0a8c0aac6e3446e633a73ea63eee81",
"address": "tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e",
"btc_address": "tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e"
}'
{
"code": 0,
"msg": "",
"data": {
"order_id": "swap_1072414914196275200",
"psbt": "cHNidP8BAP3kAQIAAAAGY7oaL8gccUMryZKGtrngwmB/X560uaP4UbuD75PQxlMBAAAAAP/////8IMVNQszZOrx8TR8VyYjZQLY11iIi4jAka6zAI59z7wUAAAAA//////wgxU1CzNk6vHxNHxXJiNlAtjXWIiLiMCRrrMAjn3PvAgAAAAD//////CDFTULM2Tq8fE0fFcmI2UC2NdYiIuIwJGuswCOfc+8BAAAAAP/////8IMVNQszZOrx8TR8VyYjZQLY11iIi4jAka6zAI59z7wQAAAAA//////wgxU1CzNk6vHxNHxXJiNlAtjXWIiLiMCRrrMAjn3PvAwAAAAD/////B0oBAAAAAAAAFgAUAYlgdU80lDqo/6jMzcVuGodfoSdKAQAAAAAAABYAFAGJYHVPNJQ6qP+ozM3FbhqHX6EnSgEAAAAAAAAWABQBiWB1TzSUOqj/qMzNxW4ah1+hJ0oBAAAAAAAAFgAURk7zdZ/Pses9dvMxnvWOwgMBxlgAAAAAAAAAABVqXRIAspoEDfJGAwAAtAIBAAC0AgLIiwEAAAAAACJRIAYWGj9nocZ7GjlVDA5sFWhS8i6cm/xnqpUQEKJ83DJKRWw3AAAAAAAWABRGTvN1n8+x6z128zGe9Y7CAwHGWAAAAAAAAQEf0Ps4AAAAAAAWABRGTvN1n8+x6z128zGe9Y7CAwHGWAEDBAEAAAAAAQEfSgEAAAAAAAAWABQBiWB1TzSUOqj/qMzNxW4ah1+hJwEDBAEAAAAAAQEfSgEAAAAAAAAWABQBiWB1TzSUOqj/qMzNxW4ah1+hJwEDBAEAAAAAAQEfSgEAAAAAAAAWABQBiWB1TzSUOqj/qMzNxW4ah1+hJwEDBAEAAAAAAQEfSgEAAAAAAAAWABQBiWB1TzSUOqj/qMzNxW4ah1+hJwEDBAEAAAAAAQEfSgEAAAAAAAAWABQBiWB1TzSUOqj/qMzNxW4ah1+hJwEDBAEAAAAAAAAAAAAAAA==",
"check_sign_only": false
},
"req_id": "1887761713347338240"
}
Success