[Tech] Part 1 — Distributing Bounties and Airdrops (60K TX)

Team REMIIT
REMIIT
Published in
3 min readMar 19, 2019

Introduction

Bounties and Airdrops, which have become buzz words in the crypto market, are a marketing tool that can inform many people about the project in the early days of the project. This is one of the most important marketing tools that can be undertaken early in the project as it forms a community at the start and shares project details on various channels. REMIIT conducted the campaign three months before the TGE. Bounty is a reward that has been announced to more people by sharing content on the various channels including YouTube, blogs, BitcoinTalk, Facebook, Twitter, and LinkedIn. Airdrop is a reward given when someone follows a community’s project and recommends it to a friend.

The project’s bounty and airdrop campaign was complete very successfully, attracting people from a variety of countries, including 250 pages of comments, and a large number of participants beyond our expectations. The actual event participation exceeded 110,000 people, but due to over budget, we were only able to pay out to approximately 62,000 wallets.

Therefore we had to conduct more than 60,000 transactions, but token contract was already deployed thus we could not put new functions in the contract.

Airdrop Preparation

Since there were so many recipients, we focused on reducing gas costs rather than reusable, versatile contracts. The process was as follows.

  • Reduce transaction size and memory usage by reducing arguments
    Through the constructor, set REMI Contract Address, REMI Owner Address, and Default Distribution to State Variables.
    — The deployment has defaulted to 1250 because 1250 REMIs were the majority (over 80%).
  • Make the sending amount the same
    — If the amount to send was different, we had to send it to each address in an array.
    — We bundled the wallet addresses that will receive the same amount and replaced the sending amount into one integer.
    — With the above Default Distribution, we did not have to record how much to spend on the majority of transactions.

``solidity
// State Variable that affects to airdropToken function
address public SOURCE_ADDRESS;​
uint public DEFAULT_AMOUNT;​
IERC20 public REMI_INTERFACE;

// Set state variables simultaneously with construct​
constructor (address _tokenAddress, address _sourceAddress, uint _defaultAmount) public{
REMI_INTERFACE = IERC20(_tokenAddress);
SOURCE_ADDRESS = _sourceAddress;
DEFAULT_AMOUNT = _defaultAmount;​
}
```

  • Sending in a bundle
    — In addition to the advantage of time saving in transactions to many people at the same time, gas costs were also greatly influential.
    — The biggest burden of small transactions was the underlying transaction cost (21k).
    — So we took the form of bundling 50 people each.
    1. The reason we put them in groups of 50 was because after finishing all the optimizations below, the cost was only slightly lower than 2M. (1/4 of the block size)
    2.The larger the transaction volume, the smaller the gas cost per capita, but the lower the probability of being included in the block, and eventually we have to raise the gas cost or wait just wait, which is a good compromisation between cost and time.

```solidity
// Airdrop token from SOURCE_ADDRESS a _dropAmount per each _recipientList[i] via REMI_INTERFACE
function airdropToken(address[] calldata _recipientList, uint _dropAmount) external onlyOwner{
uint dropAmount = (_dropAmount > 0 ? _dropAmount : DEFAULT_AMOUNT) * 10**18;

require(_recipientList.length * dropAmount <= REMI_INTERFACE.allowance(SOURCE_ADDRESS,address(this)), “Allowed authority insufficient”);

for(uint i = 0; i < _recipientList.length; i++){
REMI_INTERFACE.transferFrom(SOURCE_ADDRESS, _recipientList[i], dropAmount);
}
}
```

  • Minimize unnecessary parts
    — SafeMath, which prevents over/underflow, is not used because it increases the operation cost.
    — In addition to access management for minimal security, we have omitted the exception handling we have placed just in case.
  • As a result, the average gas consumption per person was 40k, and the basic consumption cost was less than 10% except 36k (basic, store writing).

After completing the contract, we bundled the fragmented data to create a new table for the airdrop. The Wallet program was a mixed case of Wallet addresses, so we verified that it did not change the validity of the wallet in upper and lower case letters, so we proceeded with the lowercase. After that, we gave the txIndex by bundling up to 50 items with the same amount, starting from the lowest amount.

In the following section, I will describe the process of actually airdrop transactions on both the testnet and mainnet.

Join REMIIT’s Community

Telegram: https://t.me/remiit

Website: https://remiit.io/

Twitter: https://twitter.com/remiitplatform

--

--

Team REMIIT
REMIIT
Editor for

Remiit is a decentralized remittance and payment platform that aims to act as a catalyst of globalization through the blockchain.