Enable Tokens - ALGO
Enable Algorand tokens on a wallet using the BitGo SDK. See the Guide.
-
Enable an Algorand Standard Asset (ASA) token on your wallet using
wallet.sendManywithtype: 'enabletoken'. Set thecointo the token asset ID format (e.g.,talgo:KAL-16026733). Therecipientsarray must include the wallet address with an amount of'0'.Unlock your account with
bitgo.unlockbefore callingsendMany. 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 BitGoJS = require('bitgo');
const Promise = require('bluebird');
const bitgo = new BitGoJS.BitGo({ env: 'test' });
const coin = 'talgo:KAL-16026733';
// Set your wallet id
const walletId = 'your wallet id';
// Set your wallet passphrase
const walletPassphrase = 'set your wallet passphrase here';
// Set your OTP
const otp = '000000';
// Set your access token
const accessToken = 'insert access token string here';
const address = 'your base address or address of same wallet';
Promise.coroutine(function* () {
bitgo.authenticateWithAccessToken({ accessToken });
const wallet = yield bitgo.coin(coin).wallets().get({ id: walletId });
console.log('Wallet ID:', wallet.id());
console.log('Base Address:', wallet.coinSpecific().rootAddress);
console.log('Balance:', wallet.balanceString());
console.log('Confirmed Balance:', wallet.confirmedBalanceString());
console.log('Spendable Balance:', wallet.spendableBalanceString());
const unlock = yield bitgo.unlock({ otp, duration: 3600 });
if (!unlock) {
throw new Error('We did not unlock.');
}
try {
const txEnableToken = yield wallet.sendMany({
type: 'enabletoken',
recipients: [
{
amount: '0',
address: address,
},
],
feeRate: 1,
walletPassphrase,
});
console.dir(txEnableToken, { depth: 6 });
} catch (e) {
console.error(e);
}
})().catch((e) => console.error(e));
Response
// 1. Enable Token Response
{
"transfer": {
"id": "64b6e6ae54dbbf0007004719b943a64f",
"coin": "tsol",
"wallet": "64b586faf9070d00079036fd748c0f3e",
"walletType": "hot",
"txid": "LH6XRYgheXWgBKM169Txi2eWhUtsmumo324wipz7iNwoaFCHjh33pTJo1fF7GE9G9uq5iwWaCuoMvsZNUuNT4GK",
"type": "send",
"value": -4083560,
"valueString": "-4083560",
"feeString": "4083560",
"usd": -0.1050699988,
"usdRate": 25.73,
"state": "signed"
}
}