Token Drop
thirdweb's Token Drop contract is a way of releasing your ERC20 tokens for a set price.
The Token Drop contract allows you to define the conditions for when and how your users can claim your tokens; including allowlists, release dates, and claim limits.
In the Token Drop, you define the price for your tokens in each claim phase, and can set a limit on how many tokens you want to release.
You could use the Token Drop contract to:
- Release your new cryptocurrency for a set price such as 1 MATIC per token.
- Allow a specific set of wallets to claim your ERC-20 tokens before releasing it to the public.
- Allow users to claim your tokens up until a certain date.
Create a Token Drop Contract
Learn how to create any of thirdweb's pre-built contracts in the Deploying Contracts page.
Getting the contract in your application
To start using your Token Drop contract inside your application, you'll need to use it's contract address. You can get the contract address from the dashboard.
- Javascript
- React
- Python
- Go
import { ThirdwebSDK } from "@thirdweb-dev/sdk";
const sdk = new ThirdwebSDK("rinkeby");
const contract = sdk.getTokenDrop("{{contract_address}}");
React SDK support for initializing the SDK is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for initializing the SDK is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for initializing the SDK is coming soon.
Want this feature sooner? Let us know in Discord!
Setting Claim Phases
A claim phase is a set of conditions that define when and how your users can mint your tokens.
You can have multiple claim phases that occur in sequence.
For each claim phase, you can define:
- When the claim phase will start
- How many tokens you want to drop
- How much you want to charge per token
- What currency you want to charge in
- Which wallet addreses are allowed to claim tokens (allowlist)
- How many tokens can be claimed per transaction
- How many seconds wallets have to wait between claims
Using the dashboard
You can configure the claim phases from the Claim Phases tab in the dashboard.
Using the thirdweb SDK
- Javascript
- React
- Python
- Go
const presaleStartTime = new Date();
const publicSaleStartTime = new Date(Date.now() + 60 * 60 * 24 * 1000);
const claimConditions = [
{
startTime: presaleStartTime, // start the presale now
maxQuantity: 3117.42, // limit how many tokens are released in this presale
price: 0.001, // presale price per token
snapshot: ['0x...', '0x...'], // limit claiming to only certain addresses
},
{
startTime: publicSaleStartTime, // 24h after presale, start public sale
price: 0.008, // public sale price per token
}
]);
await contract.claimConditions.set(claimConditions);
React SDK support for claimConditions is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for claimConditions is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for claimConditions is coming soon.
Want this feature sooner? Let us know in Discord!
Claiming Tokens
Your users can claim tokens if their wallet address meets the criteria to be included in the current claim phase.
- Javascript
- React
- Python
- Go
const address = "{{wallet_address}}"; // address of the wallet you want to claim the NFTs
const quantity = 42.69; // how many tokens you want to claim
const tx = await contract.claimTo(address, quantity);
const receipt = tx.receipt; // the transaction receipt
React SDK support for claimTo is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for claimTo is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for claimTo is coming soon.
Want this feature sooner? Let us know in Discord!
Token Metadata
Get the metadata about the token itself, such as the name, symbol, and decimals.
- Javascript
- React
- Python
- Go
const token = await contract.token.get();
React SDK support for get is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for get is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for get is coming soon.
Want this feature sooner? Let us know in Discord!
You can get the total supply of the token too.
- Javascript
- React
- Python
- Go
const balance = await contract.token.totalSupply();
React SDK support for totalSupply is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for totalSupply is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for totalSupply is coming soon.
Want this feature sooner? Let us know in Discord!
Token Balance
Balance of the connected wallet
- Javascript
- React
- Python
- Go
const balance = await contract.token.balance();
React SDK support for balance is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for balance is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for balance is coming soon.
Want this feature sooner? Let us know in Discord!
Balance of a specified wallet
- Javascript
- React
- Python
- Go
// Address of the wallet to check token balance
const walletAddress = "{{wallet_address}}";
const balance = await contract.token.balanceOf(walletAddress);
React SDK support for balanceOf is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for balanceOf is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for balanceOf is coming soon.
Want this feature sooner? Let us know in Discord!
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 amount of tokens that another wallet is allowed to spend on behalf of the connected wallet.
- Javascript
- React
- Python
- Go
// Address of the wallet to check token allowance
const spenderAddress = "0x...";
const allowance = await contract.token.allowance(spenderAddress);
React SDK support for allowance is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for allowance is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for allowance is coming soon.
Want this feature sooner? Let us know in Discord!
Get allowance for a specified wallet
Get the amount of tokens that another wallet is allowed to spend on behalf of the specified wallet.
- Javascript
- React
- Python
- Go
// 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.token.allowanceOf(owner, spender);
React SDK support for allowanceOf is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for allowanceOf is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for allowanceOf is coming soon.
Want this feature sooner? Let us know in Discord!
Set Allowance
Specify how many tokens another wallet is allowed to spend on behalf of the connected wallet.
- Javascript
- React
- Python
- Go
// Address of the wallet to allow transfers from
const spenderAddress = "0x...";
// The number of tokens to give as allowance
const amount = 100
await contract.token.setAllowance(spenderAddress, amount);
React SDK support for setAllowance is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for setAllowance is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for setAllowance is coming soon.
Want this feature sooner? Let us know in Discord!
Transfer Tokens
You can transfer tokens from one wallet to another, or send tokens to a smart contract address.
Transfer from the connected wallet
- Javascript
- React
- Python
- Go
// 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.token.transfer(toAddress, amount);
React SDK support for transfer is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for transfer is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for transfer is coming soon.
Want this feature sooner? Let us know in Discord!
Transfer from the connected wallet in batch
- Javascript
- React
- Python
- Go
// 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.token.transferBatch(data);
React SDK support for transferBatch is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for transferBatch is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for transferBatch is coming soon.
Want this feature sooner? Let us know in Discord!
Transfer from a specified wallet
- Javascript
- React
- Python
- Go
// 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.token.transferFrom(fromAddress, toAddress, amount);
React SDK support for transferFrom is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for transferFrom is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for transferFrom is coming soon.
Want this feature sooner? Let us know in Discord!
Burning Tokens
Burning tokens takes a specified amount of tokens out of the circulating supply.
Burn from the connected wallet
- Javascript
- React
- Python
- Go
// The amount of this token you want to burn
const amount = 1.2;
await contract.burn(amount);
React SDK support for burn is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for burn is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for burn is coming soon.
Want this feature sooner? Let us know in Discord!
Burn from a specified wallet
- Javascript
- React
- Python
- Go
// 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);
React SDK support for burnFrom is coming soon.
Want this feature sooner? Let us know in Discord!
Python SDK support for burnFrom is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for burnFrom is coming soon.
Want this feature sooner? Let us know in Discord!