Enable Tokens - HBAR
Enable Hedera tokens on a wallet using the BitGo SDK. See the Guide.
-
Enable a Hedera token on your wallet using
sendTokenEnablements. Pass the token name (e.g.,thbar:usdc) in theenableTokensarray. Once the transaction confirms on chain, you can send and receive that token.Prerequisites: Complete Get Started and Create Wallets.
// 1. Enable Token
// Use the JavaScript SDK for this step (see JavaScript tab)
// 1. Enable Token
const BitGo = require("bitgo");
const bitgo = new BitGo.BitGo({
env: "custom",
customRootURI: "",
});
// Set your access token
const accessToken = "";
// Set your wallet id
const walletId = "";
// Set your wallet passphrase
const passphrase = "test_wallet_passphrase";
const coin = "thbar";
async function enableToken(walletId) {
const wallet = await bitgo.coin(coin).wallets().getWallet({ id: walletId });
const result = await wallet.sendTokenEnablements({
enableTokens: [{ name: "thbar:usdc" }],
});
console.log(JSON.stringify(result, undefined, 2));
}
enableToken(walletId).catch((e) => console.error(e));
Response
// 1. Enable Token Response
{
"transfer": {
"id": "64b6e6ae54dbbf0007004719b943a64f",
"coin": "thbar",
"wallet": "64b586faf9070d00079036fd748c0f3e",
"walletType": "hot",
"txid": "LH6XRYgheXWgBKM169Txi2eWhUtsmumo324wipz7iNwoaFCHjh33pTJo1fF7GE9G9uq5iwWaCuoMvsZNUuNT4GK",
"type": "send",
"value": -4083560,
"valueString": "-4083560",
"feeString": "4083560",
"usd": -0.1050699988,
"usdRate": 25.73,
"state": "signed"
}
}