Skip to main content

Tokens

Connect to your Token program by providing the on-chain address of the program:

import { ThirdwebSDK } from "@thirdweb-dev/sdk/solana";

const sdk = ThirdwebSDK.fromNetwork("devnet");
sdk.wallet.connect(signer);

// Get the interface for your token program
const program = await sdk.getProgram("{{program_address}}", "token");

Get Token Metadata

const metadata = await program.getMetadata();
console.log(metadata.supply);
console.log(metadata.decimals);
View in Javascript SDK Documentation

Get Token Balance

const address = "..."
const balance = await program.balanceOf(address);
console.log(balance.displayValue);
View in Javascript SDK Documentation

Mint Tokens

// Specify the address to mint tokens to
const address = "{{wallet_address}}"";
// And the amount of tokens to mint
const amount = 1;
// And then you can make a mint transaction
const tx = await program.mintTo(address, 1);
View in Javascript SDK Documentation

Transfer Tokens

// Specify the address to transfer tokens to
const to = "...";
// And the amount of tokens to transfer
const amount = 1;
// And then you can make the transfer transaction
const tx = await program.transfer(to, amount);
View in Javascript SDK Documentation