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
Argument | Type | Description |
---|---|---|
to | string | The receiver address of the claim. |
id | number | The id of the airdrop to claim. |
amount | string | The amount to claim. |
proof | string[] | The merkle proof to verify receiver's claim. |
signer | Signer | The instance to represent wallet address. |
Response
Field | Type | Description |
---|---|---|
type | number | The EIP-2718 type of this transaction. |
chainId | number | The id of the network. |
nonce | number | The nonce used as part of the proof-of-work to mine this block. |
maxPriorityFeePerGas | BigNumber | The price (in wei) per unit of gas this transaction. |
maxFeePerGas | BigNumber | The 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. |
gasPrice | BigNumber | The price (in wei) per unit of gas this transaction will pay. |
gasLimit | BigNumber | The maximum amount of gas that this block was permitted to use. |
to | string | The address of the target. |
value | BigNumber | The amount (in wei) this transaction is sending. |
data | string | Transaction data. |
accessList | AccessListish | The AccessList include; only available for EIP-2930 [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559transactions. |
hash | string | Transaction hash. |
v | number | Values for the transaction's signature. |
r | string | Values for the transaction's signature. |
s | string | Values for the transaction's signature. |
from | string | The sender address of the transaction. |
confirmations | number | The 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
)