1

I'm new to smart contracts. is it possible to credit ethereum addresses with ERC20 tokens? basically "write" the balance instead of airdropping them via transactions. asking because gas-fees are so high

1
  • use TransferBatch approach and send many tokens in a single transaction
    – Nulik
    Commented Feb 11, 2021 at 23:07

2 Answers 2

0

You could initialize your _balances mapping in the ERC20 contract with several addresses:

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol#L33

However, depending on how many addresses you want to airdrop to, you might end up exceeding the contract code size limit:

https://github.com/ethereum/EIPs/blob/master/EIPS/eip-170.md

Also, note that initializing your _balances array will add to your deployment costs:

What is the real price of deploying a contract on the Mainnet?

In particular:

More bytecode means more storage, and each byte costs 200 gas. This adds up very quickly.

and:

If the constructor requires a lot of computation to generate the bytecode, then it'll be extra expensive.

1
  • Re: airdropping efficiently. I've seen several solutions: (1) set up a contract so that whitelisted addresses can withdraw their allocated airdrops (so that users pay their own gas fees for transfer), (2) you can take a look at what these guys did: github.com/rstormsf/multisender/tree/…
    – Sasa Milic
    Commented Feb 11, 2021 at 23:04
1

Uniswap had last year an airdrop where recipients were included in a merkle tree. Only the merkle tree root was written to the contract. The merkle tree was made public so anyone can check if their address was included.

To redeem the tokens each user has tu supply the branch of the merkle tree that included them. The contract verifies the branch and assign the token to the user. Each user had to pay the transactions fees for their tokens.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.