Token Module
Config
protocol_module
=token
Registry
The available fields in the Token module to use in the infinit.registry.json
are as follows:
Field | Type | Description |
---|---|---|
tokens | object<string ,{ type: 'InfinitERC20' | 'InfinitERC20Burnable' }> | Mapping of token addresses to TokenType. |
tokenDistributors | string[] | List of token distributor addresses. |
accumulativeMerkleDistributors | object<string ,{ implementation: string } | Mapping of addresses to proxies for accumulative Merkle distributors. |
merkleTree | MerkleTree | Merkle tree data. |
MerkleTree
Field | Type | Description |
---|---|---|
root | string | Root hash of the Merkle tree. |
merkle | object<string, { amount: string; proof: string[] }> | Mapping of addresses to Merkle proofs and amounts. |
Actions
The actions available in the @infinit-xyz/token/actions
are as follows:
import {
DeployInfinitERC20Action,
DeployInfinitERC20BurnableAction,
SetMerkleRootAction
} from '@infinit-xyz/token/actions'
DeployInfinitERC20Action
DeployInfinitERC20Action
is an action that deploys a pure ERC20 token.
Parameters
Field | Type | Required | Description |
---|---|---|---|
owner | Address | Yes | Token owner |
name | string | Yes | Token name |
symbol | string | Yes | Token symbol |
maxSupply | BigInt (opens in a new tab) | Yes | Token max supply |
initialSupply | BigInt (opens in a new tab) | Yes | Token mint amount when deployed |
Signers
deployer
: Deployer of the token will be assigned as the owner of the token.
DeployInfinitERC20BurnableAction
DeployInfinitERC20BurnableAction
is an action that deploys a burnable ERC20 token.
Parameters
Field | Type | Required | Description |
---|---|---|---|
owner | Address | Yes | Token owner address string |
name | string | Yes | Token name |
symbol | string | Yes | Token symbol |
maxSupply | BigInt (opens in a new tab) | Yes | Token max supply |
initialSupply | BigInt (opens in a new tab) | Yes | Token mint amount when deployed |
Signers
deployer
: Deployer of the token will be assigned as the owner of the token.
SetMerkleRootAction
SetMerkleRootAction
is an action that sets the Merkle root of the AccumulativeMerkleTree
.
Parameters
Field | Type | Required | Description |
---|---|---|---|
accumulativeMerkleDistributor | Address | Yes | Accumulative merkle distributor address string |
root | string | Yes | Merkle root string |
Signers
owner
: Owner address of the accumulative merkle distributor.
Utils
MerkleTree
Utility class for Merkle tree generation and proof verification.
interface MerkleTree {
userRewardMapping: Record<Address, string>;
tree: SimpleMerkleTree;
constructor(userRewardMapping: Record<Address, string>): void;
private generateTree(): SimpleMerkleTree;
public getProof(userAddress: Address): ProofDetail;
public getRoot(): string;
public getAllProofs(): Record<Address, ProofDetail>;
}
Usage:
import { MerkleTree } from "@infinit-xyz/token/utils"
const merkleTree = new MerkleTree({
userRewardMapping: {
"0x1234567890abcdef1234567890abcdef12345678": "1000",
"0xabcdef1234567890abcdef1234567890abcdef12": "2000"
}
})
merkleTree.getRoot() // Returns the root hash of the Merkle tree.
merkleTree.getProof("0x1234567890abcdef1234567890abcdef12345678") // Returns the Merkle proof for the user address.
merkleTree.getAllProofs() // Returns the Merkle proof for all user addresses.