Burn Stablecoins
Burn stablecoins by creating a redemption order, transferring tokens to BitGo, and receiving fiat. See the Guide.
-
List the stablecoins available for burning and save the fiat, stablecoin, and treasury wallet identifiers.
-
Use the
treasuryAccountWalletIdfrom the selected stablecoin asset as the destination for the burn transfer. -
Calculate the integer token base-unit amount by multiplying the full-unit redemption amount by 10 raised to the token decimals.
-
Create a pending burn order that converts the stablecoin into the selected fiat asset. Save the order ID for the transfer and status request.
-
Transfer the stablecoin to the treasury wallet with the order ID as the sequence ID so BitGo can process the burn.
-
Retrieve the order until its status is fulfilled and confirm the fiat amount returned after processing.
// 1. List Available Stablecoins
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X GET https://app.bitgo-test.com/api/stablecoin/v1/assets \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN"
// 2. Get Treasury Wallet ID
# Use the treasuryAccountWalletId returned by the previous request.
// 3. Calculate Redeem Amount
export AMOUNT_IN_FULL_UNITS="<YOUR_AMOUNT>"
export DECIMALS="<ASSET_DECIMALS>"
AMOUNT_BASE_UNITS=$(($AMOUNT_IN_FULL_UNITS * 10**$DECIMALS))
echo "Amount in base units: $AMOUNT_BASE_UNITS"
// 4. Create Burn Order
export ENTERPRISE_ID="<YOUR_ENTERPRISE_ID>"
export SOURCE_WALLET_ID="<SOURCE_WALLET_ID>"
export DESTINATION_WALLET_ID="<DESTINATION_WALLET_ID>"
export FROM_ASSET_ID="<FROM_ASSET_ID>"
export TO_ASSET_ID="<TO_ASSET_ID>"
export FROM_AMOUNT="$AMOUNT_BASE_UNITS"
curl -X POST https://app.bitgo-test.com/api/stablecoin/v1/enterprise/$ENTERPRISE_ID/order \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"sourceWalletId": "'"$SOURCE_WALLET_ID"'",
"destinationWalletId": "'"$DESTINATION_WALLET_ID"'",
"destinationType": "go_account",
"fromAssetId": "'"$FROM_ASSET_ID"'",
"toAssetId": "'"$TO_ASSET_ID"'",
"fromAmount": "'"$FROM_AMOUNT"'",
"type": "burn"
}'
// 5. Transfer Stablecoin to BitGo
export BITGO_EXPRESS_HOST="<YOUR_LOCAL_HOST>"
export COIN="<ASSET_ID>"
export WALLET_ID="<YOUR_WALLET_ID>"
export ADDRESS="<DESTINATION_ADDRESS>"
export AMOUNT="$FROM_AMOUNT"
export WALLET_PASSPHRASE="<YOUR_WALLET_PASSPHRASE>"
export SEQUENCE_ID="<ORDER_ID>"
curl -X POST http://$BITGO_EXPRESS_HOST/api/v2/$COIN/wallet/$WALLET_ID/sendcoins \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"address": "'"$ADDRESS"'",
"amount": "'"$AMOUNT"'",
"walletPassphrase": "'"$WALLET_PASSPHRASE"'",
"sequenceId": "'"$SEQUENCE_ID"'"
}'
// 6. Check Order Status
export ORDER_ID="<YOUR_ORDER_ID>"
curl -X GET https://app.bitgo-test.com/api/stablecoin/v1/enterprise/$ENTERPRISE_ID/orders/$ORDER_ID \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN"
// 1. List Available Stablecoins
import * as BitGoJS from 'bitgo';
import { common } from '@bitgo/sdk-core';
const accessToken = '<YOUR_ACCESS_TOKEN>';
const enterpriseId = '<YOUR_ENTERPRISE_ID>';
const walletId = '<YOUR_WALLET_ID>';
const walletPassphrase = '<YOUR_WALLET_PASSPHRASE>';
const bitgo = new BitGoJS.BitGo({ env: 'test' });
bitgo.authenticateWithAccessToken({ accessToken });
const baseUrl = common.Environments[bitgo.getEnv()].uri + '/api/stablecoin/v1';
const assets = (await bitgo.get(`${baseUrl}/assets`)).body;
const usdAsset = assets.find((a: any) => a.token === 'tfiatusd');
const stablecoinAsset = assets.find((a: any) => a.token === 'tbsc:usd1');
const treasuryWalletId = stablecoinAsset.treasuryAccountWalletId;
// 2. Get Treasury Wallet ID
// The treasuryWalletId value comes from the selected stablecoin asset.
// 3. Calculate Redeem Amount
const fromAmount = (100 * Math.pow(10, stablecoinAsset.decimals)).toString();
// 4. Create Burn Order
const order = (await bitgo.post(`${baseUrl}/enterprise/${enterpriseId}/order`).send({
sourceWalletId: walletId,
destinationWalletId: walletId,
destinationType: 'go_account',
fromAssetId: stablecoinAsset.id,
toAssetId: usdAsset.id,
fromAmount,
type: 'burn',
})).body;
console.log('Order created:', order.id);
// 5. Transfer Stablecoin to BitGo
const wallet = await bitgo.coin('ofctbsc:usd1').wallets().get({ id: walletId });
await wallet.sendMany({
recipients: [{ address: treasuryWalletId, amount: fromAmount }],
sequenceId: order.id,
walletPassphrase,
});
// 6. Check Order Status
const finalOrder = (await bitgo.get(`${baseUrl}/enterprise/${enterpriseId}/orders/${order.id}`).send()).body;
console.log('Order status:', finalOrder.status);
// 1. List Available Stablecoins Response
[
{ "id": "08c1271e-b15d-4af8-8929-f75383903da4", "token": "tfiatusd", "name": "Testnet US Dollar", "decimals": 2 },
{ "id": "bfd0daec-f849-4b96-bdb6-6373bffeb9b6", "token": "tbsc:usd1", "name": "Testnet BSC USD1", "decimals": 18, "chain": "tbsc", "backingAsset": "tfiatusd", "treasuryAccountWalletId": "67c1a025f9999f485f7a71aa26a1da4c" }
]
// 4. Create Burn Order Response
{ "id": "order_id_12345", "type": "burn", "status": "pending_funding", "fromAssetId": "stablecoin_asset_id", "toAssetId": "usd_asset_id", "fromAmount": "100000000" }
// 5. Transfer Stablecoin to BitGo Response
{ "coin": "ofctbsc:usd1", "transfers": [{ "id": "transfer_id_12345", "coin": "ofctbsc:usd1", "wallet": "source_wallet_id", "value": -100000000, "state": "unconfirmed", "type": "send" }] }
// 6. Check Order Status Response
{ "id": "order_id_12345", "type": "burn", "status": "fulfilled", "fromAssetId": "stablecoin_asset_id", "toAssetId": "usd_asset_id", "fromAmount": "100000000", "toAmount": "10000" }