@mirrorworld/evm.token-claim
v8.0.0
Published
Air Droper Contract SDK
Downloads
1
Readme
This SDK contains the client side methods for the Token Claim EVM Smart Contract
Installation
🚨 Please make sure to add this NPM token in your
.npmrc
file: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
yarn add @usemirrorworld/evm.token-claim
Usage
Import the TokenClaimLib
instance into your client for using the Token Claim Smart Contract. It expects
a contractAddress
and provider
instance.
import { TokenClaimLib} from "@mirrorworld/evm.token-claim";
const RPC = "http://localhost:8500";
let provider = new ethers.providers.JsonRpcProvider(RPC);
let tokenClaimLib: TokenClaimLib = new TokenClaimLib(tokenClaim.address, provider);
Demo
Example: You can see example project in this is here
Initialize Claim Config
For setup up the claim pool call the "initializeClaimConfig" method
let tx = await tokenClaimLib.createInitializeClaimConfigTransactionRequest(caller.address, claimPoolName, ercTokenAddress, poolOwnerAddress, gasPrice, gasLimit);
const sigTx = await caller.signTransaction(tx);
const sentTx = await provider.sendTransaction(sigTx);
const txRe = await sentTx.wait();
Update Claim Config
For setting the enable or disable the claim pool, airdrop and claim call the "updateClaimConfig" method
let tx = await tokenClaimLib.createUpdateClaimConfigTransactionRequest(caller.address, claimPoolName, isEnable, isClaimEnable, isAirdropEnable, gasPrice, gasLimit);
const sigTx = await caller.signTransaction(tx);
const sentTx = await provider.sendTransaction(sigTx);
Add Pool Supply
For top up the pool supply for claim and airdrop call the "addPoolSupply" method, but before calling this method caller must call of this method must call the ERC20 approve for this Token Claim contract address as spender and amount which need to added in the supply
let tx = await tokenClaimLib.createAddPoolSupplyTransactionRequest(caller.address, claimPoolName, amount, gasPrice, gasLimit);
const sigTx = await caller.signTransaction(tx);
const sentTx = await provider.sendTransaction(sigTx);
Withdraw Pool Supply
For withdraw the pool supply call the "withdrawPoolSupply" method
let tx = await tokenClaimLib.createWithdrawPoolSupplyTransactionRequest(caller.address, claimPoolName, amount, receiver, gasPrice, gasLimit);
const sigTx = await caller.signTransaction(tx);
const sentTx = await provider.sendTransaction(sigTx);
Airdrop
For airdrop the token to the user call the "airdrop" method
let tx = await tokenClaimLib.createAirdropTransactionRequest(caller.address, claimPoolName, amount, user, gasPrice, gasLimit);
const sigTx = await caller.signTransaction(tx);
const sentTx = await provider.sendTransaction(sigTx);
Claim
For user to claim the token claim pool owner need to sign the payload with "claim ID (season ID)" and create the transaction which user send to the network
let claimMsg = tokenClaimLib.getClaimMessage(claimPoolName, caller.address, BigNumber.from(amount), claimId)
let claimSig = await tokenClaimLib.signMessage(ownerWallet, claimMsg)
let tx = await tokenClaimLib.createClaimTransactionRequest(caller.address, claimPoolName, amount, claimId, claimSig, gasPrice, gasLimit);
const sigTx = await caller.signTransaction(tx);
const sentTx = await provider.sendTransaction(sigTx);
const txRe = await sentTx.wait();