Airdrop is a popular way to distribute project tokens to the community. Airdrop sometimes leads to congestion in the Ethereum network and huge commissions in transactions. More recently, such a mechanic, which was used to vote on the FCoin exchange, led to dire consequences for the entire Ethereum network.
A good algorithm allows solving several problems of smart contracts at once, which operate with large lists of user addresses. The fact is that putting a list of even several thousand addresses into a contract and allowing this set of addresses to do something in the contract will not work directly – the blockchain saves every byte and it is too expensive.
To solve the problem, it is necessary to determine in the contract code whether this address belongs to the list of “white” addresses. If yes, then allow the desired action. The proposed option allows you to quite simply solve this problem, holding in the contract only one number. ico airdrop The algorithm of the brilliant cryptographer Ralph Merkle is widely used in almost any decentralized software to ensure the integrity of the data sets.
Airdrop and ACL
There is a practice to release your token and send out small amounts of it to tens of thousands of addresses that have, for example, at least 1 ETH on the balance. Such spam is extremely popular now to promote your own tokens. Few people like the appearance on their balance of someone’s unknown tokens. However, projects need it, and orders for airdrop are very popular. This is usually done in the old fashioned way, like this (using the example of Ethereum, but other blockchains with contracts, EOS, for example) are also suitable:
- find many addresses by specified criteria;
- create an address where enough tokens are stored for distribution to everyone from the list, or provide a token in the contract to create (min) the required number of tokens to a given address (when sending a transaction from a special preferred address);
- Ethereum is put on this address enough to pay the fee for each shipment of tokens to the user;
- they launch a mailing script that iterates through the addresses and for each creates a transaction that translates (or mints) tokens to the specified address.
That is, it’s just going through a pile of addresses and sending tokens to everyone. In decentralized systems, such a push strategy is usually quite lame, expensive, creates security holes, and in general is spam. Among its disadvantages:
- a lot of money is spent on commission (the more addresses, the more commission). In addition, at the time of mailing the commission can grow, because the load on the network grows, the cost of the transaction grows too;
- mailing requires writing a script that will send transactions, and in the script is sewn a secret key that gives access to a heap of tokens;
- It is necessary to program the newsletter and be able to continue from the place where everything is broken.
In this case, there is a much simpler solution, which, as is customary in decentralized networks, gives most of the work to software on the client side. what is airdropThis is access control using the Merkle tree – an extremely convenient data structure to store only one fixed-size number (merkleRoot) in the contract, which contains information about all the data included in the tree (about a huge list of recipients, for example).
So, this algorithm is suitable for creating huge ACLs (Access Control List), which allow providing access to a certain contract function for millions of accounts. To do this, you need to write in the contract a single number to verify that the account belongs to the list.
Consider a circuit with an airdrop, since It is now extremely in demand in the market and is a simple and demonstrative example of smart contracts with large ACLs.
First, it is worth recalling that a smart contract is first deposited into the Ethereum network, after which it receives its own address and balance on the network, and then it accepts and processes incoming transactions within itself.
In the merkle-airdrop scheme, tokens are not sent to addresses, and users themselves “require” their tokens by sending transactions to the contract and paying a commission. How to use airdrop? The secret is that users add data to a transaction, allowing the contract to easily verify whether they are in the “white” address list, and the list itself is not necessary to remember the contract. The contract itself is extremely economical, it needs only one (!) Number for a list of addresses of any (!) Size – this is the essence of this excellent algorithm. And such a contract is extremely easy to run, after which it does not require any support at all, and due to this simplicity, it is also extremely safe to use.