claim()

Call the claim method to claim a specific amount of tokens in the airdrop of the contract, along with its parameters and response details.

Step 1: Create Signer instance

  • browser environment (we are using metamask in this example)
const ethereum = (window as any).ethereum;
const accounts = await ethereum.request({
  method: "eth_requestAccounts",
});

const provider = new ethers.providers.Web3Provider(ethereum)
const signer = provider.getSigner(accounts[0]);
  • nodejs environment:
const provider = new ethers.providers.JsonRpcProvider("RPC_URL", 5);
const signer = new ethers.Wallet("WALLET_PRIVATE_KEY", provider);

Step 2: Call claim method

Claim a given amount of token in the airdrop of this contract

Parameter

ArgumentTypeDescription
tostringThe receiver address of the claim.
idnumberThe id of the airdrop to claim.
amountstringThe amount to claim.
proofstring[]The merkle proof to verify receiver's claim.
signerSignerThe instance to represent wallet address.

Response

FieldTypeDescription
typenumberThe EIP-2718 type of this transaction.
chainIdnumberThe id of the network.
noncenumberThe nonce used as part of the proof-of-work to mine this block.
maxPriorityFeePerGasBigNumberThe price (in wei) per unit of gas this transaction.
maxFeePerGasBigNumberThe maximum price (in wei) per unit of gas this transaction will pay for the combined EIP-1559 base fee and this transaction's priority fee.
gasPriceBigNumberThe price (in wei) per unit of gas this transaction will pay.
gasLimitBigNumberThe maximum amount of gas that this block was permitted to use.
tostringThe address of the target.
valueBigNumberThe amount (in wei) this transaction is sending.
datastringTransaction data.
accessListAccessListishThe AccessList include; only available for EIP-2930 [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559transactions.
hashstringTransaction hash.
vnumberValues for the transaction's signature.
rstringValues for the transaction's signature.
sstringValues for the transaction's signature.
fromstringThe sender address of the transaction.
confirmationsnumberThe number of blocks that have been mined (including the initial block) since this transaction was mined

Example

await airdrop.claim(
    walletAddress,             // walletAddress must be an address from recipients in the above code snippet
    id,                        // id is the get from getAirdropCount in the above code snippet
    amount.toString(),         // if walletAddress is the i^{th} element of recipients, then amount is amounts[i]
    proof,                     // see how to obtain in the quickstart section
    signer
)