Token Drop
When using the Token Drop smart contract, there is no need to provide a contract type argument, as the functionality of the smart contract is all available through the extensions interface.
The extensions that the Token Drop contract supports are listed below.
- ERC20
- ERC20Burnable
- ERC20ClaimPhases
- ERC20Permit
- PlatformFee
- PrimarySale
- Permissions
- ContractMetadata
- Gasless
allowance
Get the allowance of another wallet address over the connected wallet's funds.
"Allowance" refers to the number of tokens that another wallet is allowed to spend on behalf of the connected wallet.
// Address of the wallet to check token allowance
const spenderAddress = "{{wallet_address}}";
const allowance = await contract.erc20.allowance(spenderAddress);
Configuration
allowanceOf
The same as allowance
, but allows you to specify the owner wallet to check, instead of using the connected wallet.
// Address of the wallet who owns the funds
const owner = "{{wallet_address}}";
// Address of the wallet to check token allowance
const spender = "{{wallet_address}}";
const allowance = await contract.erc20.allowanceOf(owner, spender);
Configuration
balance
View the balance (i.e. number of tokens) the connected wallet has in their wallet from this contract.
const balance = await contract.erc20.balance();
Configuration
balanceOf
The same as balance
, but allows you to specify the wallet address to check, instead of using the connected wallet.
// Address of the wallet to check token balance
const walletAddress = "{{wallet_address}}";
const balance = await contract.erc20.balanceOf(walletAddress);
Configuration
burn
Burn tokens held by the connected wallet.
// The amount of this token you want to burn
const amount = 1.2;
const txResult = await contract.erc20.burn(amount);
Configuration
burnFrom
Burn tokens held by a specified wallet (requires allowance
).
// Address of the wallet sending the tokens
const holderAddress = "{{wallet_address}}";
// The amount of this token you want to burn
const amount = 1.2;
const txResult = await contract.erc20.burnFrom(holderAddress, amount);
Configuration
canClaim
Check if tokens are currently available for claiming, optionally specifying if a specific wallet address can claim.
const canClaim = await contract.erc20.claimConditions.canClaim("{{quantity}}");
Configuration
claim
Claim a specified number of tokens to the connected wallet.
const txResult = await contract.erc20.claim("{{amount}}");
Configuration
claimTo
The same as claim
, but allows specifying the recipient address rather than using the connected wallet.
const txResult = await contract.erc20.claimTo("{{recipient}}", "{{amount}}");
Configuration
get
Get the metadata of the token smart contract, such as the name, symbol, and decimals.
const metadata = await contract.erc20.get();
Configuration
get - Contract Metadata
Get the metadata of a smart contract.
const metadata = await contract.metadata.get();
Configuration
get - Permissions
Get a list of wallet addresses that are members of a given role.
const members = await contract.roles.get("{{role_name}}");
Configuration
get - PlatformFee
Get the platform fee recipient and basis points.
const feeInfo = await contract.platformFee.get();
Configuration
getActive - Claim Conditions
Retrieve the currently active claim phase, if any.
const activePhase = await contract.erc20.claimConditions.getActive();
Configuration
getAll - Claim Conditions
Get all the claim phases configured on the drop contract.
const claimPhases = await contract.erc20.claimConditions.getAll();
Configuration
getAll - Permissions
Retrieve all of the roles and associated wallets.
const allRoles = await contract.roles.getAll();
Configuration
getClaimIneligibilityReasons
Get an array of reasons why a specific wallet address is not eligible to claim tokens, if any.
const reasons = await contract.erc20.getClaimIneligibilityReasons(
"{{quantity}}", // Quantity of tokens to claim
"{{wallet_address}}", // Wallet address to check
);
Configuration
getClaimTransaction
Construct a claim transaction without executing it. This is useful for estimating the gas cost of a claim transaction, overriding transaction options and having fine grained control over the transaction execution.
const claimTransaction =
await contract.erc20.claimConditions.getClaimTransaction(
"{{wallet_address}}",
"{{quantity}}",
);
Configuration
getClaimerProofs
Returns allowlist information and merkle proofs for a given wallet address. Returns null
if no proof is found for the given wallet address.
const claimerProofs = await contract.erc20.claimConditions.getClaimerProofs(
"{{wallet_address}}",
);
Configuration
getRecipient
Get the primary sale recipient.
const salesRecipient = await contract.sales.getRecipient();
Configuration
grant - Permissions
Make a wallet a member of a given role.
const txResult = await contract.roles.grant(
"{{role_name}}",
"{{wallet_address}}",
);
Configuration
normalizeAmount
Convert a number of tokens to a number of wei.
const amount = 100;
const weiAmount = await contract.erc20.normalizeAmount(amount);
Configuration
revoke - Permissions
Revoke a given role from a wallet.
const txResult = await contract.roles.revoke(
"{{role_name}}",
"{{wallet_address}}",
);
Configuration
set - Claim Conditions
Overwrite the claim phases on the drop contract.
const txResult = await contract.erc20.claimConditions.set([
{
metadata: {
name: "Phase 1", // The name of the phase
},
currencyAddress: "0x...", // The address of the currency you want users to pay in
price: 1, // The price of the token in the currency specified above
maxClaimablePerWallet: 1, // The maximum number of tokens a wallet can claim
maxClaimableSupply: 100, // The total number of tokens that can be claimed in this phase
startTime: new Date(), // When the phase starts (i.e. when users can start claiming tokens)
waitInSeconds: 60 * 60 * 24 * 7, // The period of time users must wait between repeat claims
snapshot: [
{
address: "0x...", // The address of the wallet
currencyAddress: "0x...", // Override the currency address this wallet pays in
maxClaimable: 5, // Override the maximum number of tokens this wallet can claim
price: 0.5, // Override the price this wallet pays
},
],
merkleRootHash: "0x...", // The merkle root hash of the snapshot
},
]);
Configuration
set - Contract Metadata
Overwrite the metadata of a contract, an object following the contract level metadata standards.
This operation ignores any existing metadata and replaces it with the new metadata provided.
const txResult = await contract.metadata.set({
name: "My Contract",
description: "My contract description",
});
Configuration
set - PlatformFee
Set the platform fee recipient and basis points.
const txResult = await contract.platformFees.set({
platform_fee_basis_points: 100,
platform_fee_recipient: "0x123",
});
Configuration
setAll - Permissions
Overwrite all roles with new members.
This overwrites all members, INCLUDING YOUR OWN WALLET ADDRESS!
This means you can permanently remove yourself as an admin, which is non-reversible.
Please use this method with caution.
const txResult = await contract.roles.setAll({
admin: ["0x12", "0x123"],
minter: ["0x1234"],
});
Configuration
setAllowance
Grant allowance to another wallet address to spend the connected wallet's funds (of this token).
// Address of the wallet to allow transfers from
const spenderAddress = "0x...";
// The number of tokens to give as allowance
const amount = 100;
await contract.erc20.setAllowance(spenderAddress, amount);
Configuration
setRecipient
Set the primary sale recipient.
await contract.sales.setRecipient("{{wallet_address}}");
Configuration
totalSupply
Get the number of tokens in circulation for this contract.
const balance = await contract.erc20.totalSupply();
Configuration
transfer
Transfer tokens from the connected wallet to another 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.erc20.transfer(toAddress, amount);
Configuration
transferBatch
Transfer multiple tokens from the connected wallet to multiple wallets.
const txResult = await contract.erc20.transferBatch([
{
amount: 1,
toAddress: "0x123",
},
{
amount: 2,
toAddress: "0x456",
},
]);
Configuration
transferFrom
The same as transfer
, but allows you to specify the wallet address to send the tokens from,
instead of using the connected wallet.
This is only possible if the wallet initiating this transaction has been given allowance to transfer the tokens of the fromAddress
.
// 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.erc20.transferFrom(fromAddress, toAddress, amount);
Configuration
update - Claim Conditions
Update a single claim phase on the drop contract, by providing the index of that phase and the new phase configuration.
The index
is the position of the phase in the list of phases you have made, starting from zero.
e.g. if you have two phases, the first phase has an index of 0
and the second phase has an index of 1
.
const txResult = await contract.erc20.claimConditions.update(
0, // The index of the phase to update
{
metadata: {
name: "Phase 1", // The name of the phase
},
currencyAddress: "0x...", // The address of the currency you want users to pay in
price: 1, // The price of the token in the currency specified above
maxClaimablePerWallet: 1, // The maximum number of tokens a wallet can claim
maxClaimableSupply: 100, // The total number of tokens that can be claimed in this phase
startTime: new Date(), // When the phase starts (i.e. when users can start claiming tokens)
waitInSeconds: 60 * 60 * 24 * 7, // The period of time users must wait between repeat claims
snapshot: [
{
address: "0x...", // The address of the wallet
currencyAddress: "0x...", // Override the currency address this wallet pays in
maxClaimable: 5, // Override the maximum number of tokens this wallet can claim
price: 0.5, // Override the price this wallet pays
},
],
merkleRootHash: "0x...", // The merkle root hash of the snapshot
},
);
Configuration
update - Contract Metadata
Update the metadata of your smart contract.
const txResult = await contract.metadata.update({
name: "My Contract",
description: "My contract description",
});
Configuration
verify - Permissions
Check to see if a wallet has a set of roles.
Throws an error if the wallet does not have any of the given roles.
const verifyRole = await contract.roles.verify(
["admin", "minter"],
"{{wallet_address}}",
);