Skip to main content

ERC20Airdrop

Functionality available for contracts that implement the ERC20Airdrop extension.

Deploy an ERC20Airdrop contract from the Explore page:

drop

Airdrop ERC20 tokens to multiple recipients.

// Airdrop content array, with recipients and token amounts
const contents = [
{
recipient: "0xabc...", // first recipient address
amount: "10", // number of tokens in wei units
},
{
recipient: "0x123...", // second recipient address
amount: "20", // number of tokens in wei units
},
];

const tokenAddress = "0x..."; // Address of the ERC20 token being airdropped
const tokenOwner = "0x..."; // Address of the owner of the tokens being airdropped

const output = await contract.airdrop20.drop(
tokenAddress,
tokenOwner,
contents,
);

// the `output` return value above contains:
// - count of successful and failed drops
// - array containing failed drops, if any

Return Value

The drop function returns an array of recipients for who the airdrop failed (empty means all transfers were successful).

Parameters

Configuration

tokenAddress

A string representing the address of the ERC20 token being airdropped:

const tokenAddress = "0x..."; // Address of the ERC20 token being airdropped

const contents = [
{
recipient: "0xabc...", // first recipient address
amount: "10", // number of tokens in wei units
},
{
recipient: "0x123...", // second recipient address
amount: "20", // number of tokens in wei units
},
];

const tokenOwner = "0x...";

const output = await contract.airdrop20.drop(
tokenAddress,
tokenOwner,
contents,
);

tokenOwner

A string representing the address of the owner of the tokens being airdropped:

const contents = [
{
recipient: "0xabc...", // first recipient address
amount: "10", // number of tokens in wei units
},
{
recipient: "0x123...", // second recipient address
amount: "20", // number of tokens in wei units
},
];

const tokenAddress = "0x...";
const tokenOwner = "0x..."; // Address of the owner of the tokens being airdropped

const output = await contract.airdrop20.drop(
tokenAddress,
tokenOwner,
contents,
);

contents

An array of the contents of the airdrop, containing the recipients addresses and tokenId to airdrop.

const contents = [
{
recipient: "0xabc...", // first recipient address
amount: "10", // number of tokens in wei units
},
{
recipient: "0x123...", // second recipient address
amount: "20", // number of tokens in wei units
},
];

const tokenAddress = "0x...";
const tokenOwner = "0x...";

const output = await contract.airdrop20.drop(
tokenAddress,
tokenOwner,
contents,
);