Enable Tokens - SOL
Enable Solana SPL tokens on a wallet using the BitGo SDK. See the Guide.
-
Enable one or more Solana SPL tokens on your wallet using
sendTokenEnablements. Pass an array of token names (e.g.,tsol:usdc) and your wallet passphrase. Once the transaction confirms on chain, you can send and receive those tokens.Solana requires an Associated Token Account (ATA) for each token. This call creates the ATAs and deducts a small SOL rent fee (~0.00203928 SOL per token) from the wallet balance.
Prerequisites: Complete Get Started and Create Wallets.
// 1. Enable Tokens
// Use the JavaScript SDK for this step (see JavaScript tab)
// 1. Enable Tokens
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 = 'tsol';
async function main() {
bitgo.authenticateWithAccessToken({ accessToken });
const wallet = await bitgo.coin(coin).wallets().get({ id: walletId });
const enableTokens = await wallet.sendTokenEnablements({
enableTokens: [
{ name: 'tsol:usdc' },
{ name: 'tsol:usdt' },
],
walletPassphrase: passphrase,
});
console.log(JSON.stringify(enableTokens, undefined, 2));
}
main().catch((e) => console.error(e));
Response
// 1. Enable Tokens 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"
}
}