Skip to main content

Token

Learn how to interact with your Token contract in the SDK.

Create a Token Contract

Deploys a new Token contract
const sdk = useSDK();

const contractAddress = await sdk.deployer.deployToken({
name: "My Token",
primary_sale_recipient: "your-address",
});
View in React SDK Documentation

Getting the contract in your application

To start using your Token contract inside your application, you need to use its contract address. You can get the contract address from the dashboard.

This feature is missing a code snippet or might not be supported yet.

Check the React SDK Reference for more information.

Reach out on Discord for further assistance!

Minting Tokens

Mint tokens to a specified wallet

const toAddress = "{{wallet_address}}"; // Address of the wallet you want to mint the tokens to
const amount = "1.5"; // The amount of this token you want to mint

await contract.mintTo(toAddress, amount);
View in React SDK Documentation

Mint tokens to many wallets in one transaction (batch)

Mint Tokens To Many Wallets
// Data of the tokens you want to mint
const data = [
{
toAddress: "{{wallet_address}}", // Address to mint tokens to
amount: 0.2, // How many tokens to mint to specified address
},
{
toAddress: "0x...",
amount: 1.4,
}
]

await contract.mintBatchTo(data);
View in React SDK Documentation

Token Metadata

Get the metadata about the token itself, such as the name, symbol, and decimals.

const token = await contract.get();
View in React SDK Documentation

You can get the total supply of the token too.

const balance = await contract.totalSupply();
View in React SDK Documentation

Token Balance

Balance of the connected wallet

Get Token Balance for the currently connected wallet
const balance = await contract.balance();
View in React SDK Documentation

Balance of a specified wallet

Get Token Balance
// Address of the wallet to check token balance
const walletAddress = "{{wallet_address}}";
const balance = await contract.balanceOf(walletAddress);
View in React SDK Documentation

Token Allowance

Allowance refers to how many tokens another address is allowed to spend from your wallet.

For example, our Marketplace contract asks you permission to increase your allowance when you make a bid on an auction listing.

Get allowance for the connected wallet

Get the number of tokens that another wallet can spend on behalf of the connected wallet.

// Address of the wallet to check token allowance
const spenderAddress = "0x...";
const allowance = await contract.allowance(spenderAddress);
View in React SDK Documentation

Get allowance for a specified wallet

Get the number of tokens that another wallet can spend on behalf of the specified wallet.

// Address of the wallet who owns the funds
const owner = "{{wallet_address}}";
// Address of the wallet to check token allowance
const spender = "0x...";
const allowance = await contract.allowanceOf(owner, spender);
View in React SDK Documentation

Set Allowance

Specify how many tokens another wallet is allowed to spend on behalf of the connected wallet.

// Address of the wallet to allow transfers from
const spenderAddress = "0x...";
// The number of tokens to give as allowance
const amount = 100
await contract.setAllowance(spenderAddress, amount);
View in React SDK Documentation

Transfer Tokens

You can transfer tokens from one wallet to another or send tokens to a smart contract address.

Transfer from the connected wallet

// Address of the wallet you want to send the tokens to
const toAddress = "0x...";
// The amount of tokens you want to send
const amount = 0.1;
await contract.transfer(toAddress, amount);
View in React SDK Documentation

Transfer from the connected wallet in batch

Transfer Tokens To Many Wallets
// Data of the tokens you want to mint
const data = [
{
toAddress: "{{wallet_address}}", // Address to mint tokens to
amount: 100, // How many tokens to mint to specified address
},
{
toAddress: "0x...",
amount: 100,
}
]

await contract.transferBatch(data);
View in React SDK Documentation

Transfer from a specified wallet

Transfer Tokens From Address
// Address of the wallet sending the tokens
const fromAddress = "{{wallet_address}}";
// Address of the wallet you want to send the tokens to
const toAddress = "0x...";
// The number of tokens you want to send
const amount = 1.2
// Note that the connected wallet must have approval to transfer the tokens of the fromAddress
await contract.transferFrom(fromAddress, toAddress, amount);
View in React SDK Documentation

Burning Tokens

Burning tokens takes a specified amount of tokens out of the circulating supply.

Burn from the connected wallet

Burn Tokens
// The amount of this token you want to burn
const amount = 1.2;

await contract.burnTokens(amount);
View in React SDK Documentation

Burn from a specified wallet

Burn Tokens
// Address of the wallet sending the tokens
const holderAddress = "{{wallet_address}}";

// The amount of this token you want to burn
const amount = 1.2;

await contract.burnFrom(holderAddress, amount);
View in React SDK Documentation