Erc20
Standard ERC20 Token functions
Basic functionality for a ERC20 contract that handles all unit transformation for you.
const contract = await sdk.getContract("{{contract_address}}");await contract.erc20.transfer(walletAddress, amount);
class Erc20< T extends TokenERC20 | DropERC20 | BaseERC20 = | BaseERC20 | BaseSignatureMintERC20, > implements UpdateableNetwork, DetectableFeature {}
function constructor( contractWrapper: ContractWrapper<T>, chainId: number,
Get token allowance
Get the allowance of a 'spender' wallet over the connected wallet's funds - the allowance of a different address for a token is the amount of tokens that the spender
wallet is allowed to spend on behalf of the connected wallet.
// Address of the wallet to check token allowanceconst spenderAddress = "0x...";const allowance = await contract.erc20.allowance(spenderAddress);
function allowance( spender: string,): Promise<{ decimals: number; displayValue: string; name: string; symbol: string; value: BigNumber;}>;
Get token allowance of a specific wallet
Get the allowance of one wallet over another wallet's funds - the allowance of a different address for a token is the amount of tokens that the wallet is allowed to spend on behalf of the specified wallet.
// Address of the wallet who owns the fundsconst owner = "{{wallet_address}}";// Address of the wallet to check token allowanceconst spender = "0x...";const allowance = await contract.erc20.allowanceOf(owner, spender);
function allowanceOf( owner: string, spender: string,): Promise<{ decimals: number; displayValue: string; name: string; symbol: string; value: BigNumber;}>;
Get token balance for the currently connected wallet
Get a wallets token balance.
const balance = await contract.erc20.balance();
function balance(): Promise<{ decimals: number; displayValue: string; name: string; symbol: string; value: BigNumber;}>;
Get token balance for a specific wallet
Get a wallets token balance.
const walletAddress = "{{wallet_address}}";const balance = await contract.erc20.balanceOf(walletAddress);
function balanceOf( address: string,): Promise<{ decimals: number; displayValue: string; name: string; symbol: string; value: BigNumber;}>;
Get the token metadata
name, symbol, etc...
const token = await contract.erc20.get();
function get(): Promise<{ decimals: number; name: string; symbol: string;}>;
Use contract.erc20.mint.prepare(...args)
instead
Construct a mint transaction without executing it
This is useful for estimating the gas cost of a mint transaction, overriding transaction options and having fine grained control over the transaction execution.
function getMintTransaction( receiver: string, amount: string | number,): Promise<>;
let returnType: Promise<>;
Get the total supply for this token
Get how much supply has been minted
const balance = await contract.erc20.totalSupply();
function totalSupply(): Promise<{ decimals: number; displayValue: string; name: string; symbol: string; value: BigNumber;}>;
function burn(amount: string | number): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling burn.prepare()
with same arguments. Learn more
function burnFrom( holder: string, amount: string | number,): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling burnFrom.prepare()
with same arguments. Learn more
function claim( amount: string | number,): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling claim.prepare()
with same arguments. Learn more
function claimTo( destinationAddress: string, amount: string | number,): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling claimTo.prepare()
with same arguments. Learn more
function mint(amount: string | number): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling mint.prepare()
with same arguments. Learn more
function mintBatchTo( args: Array<{ amount: string | number; toAddress: string }>,): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling mintBatchTo.prepare()
with same arguments. Learn more
function mintTo( receiver: string, amount: string | number,): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling mintTo.prepare()
with same arguments. Learn more
function setAllowance( spender: string, amount: string | number,): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling setAllowance.prepare()
with same arguments. Learn more
function transfer( to: string, amount: string | number,): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling transfer.prepare()
with same arguments. Learn more
function transferBatch( args: Array<{ amount: string | number; toAddress: string }>,): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling transferBatch.prepare()
with same arguments. Learn more
function transferFrom( from: string, to: string, amount: string | number,): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling transferFrom.prepare()
with same arguments. Learn more
let featureName: "ERC20";
let chainId: number;
Configure claim conditions
Define who can claim NFTs in the collection, when and how many.
const presaleStartTime = new Date();const publicSaleStartTime = new Date(Date.now() + 60 * 60 * 24 * 1000);const claimConditions = [ { startTime: presaleStartTime, // start the presale now maxClaimableSupply: 2, // limit how many mints for this presale price: 0.01, // presale price snapshot: ['0x...', '0x...'], // limit minting to only certain addresses }, { startTime: publicSaleStartTime, // 24h after presale, start public sale price: 0.08, // public sale price }]);await contract.erc20.claimConditions.set(claimConditions);
Mint with signature
Generate dynamic tokens with your own signature, and let others mint them using that signature.
// see how to craft a payload to sign in the `contract.erc20.signature.generate()` documentationconst signedPayload = contract.erc20.signature().generate(payload); // now the payload can be used to mint tokensconst tx = contract.erc20.signature.mint(signedPayload);