Claimdrop Contract
The Airdrop Manager contract can be used to distribute tokens to a list of addresses. The contract uses a Merkle tree to store the list of addresses and their corresponding token amounts. The root of the Merkle tree is stored on the contract's campaign and is used to verify the validity of the proofs submitted by the recipients.
Features
Merkle tree based distribution
Lump sum and/or linear vesting distribution. Two distribution types are supported simultaneously. For instance one could be a lump sum distribution and the other could be a linear vesting distribution.
Only one campaign per contract. If there's an error with the current campaign, the owner of the contract or campaign can close the campaign, retrieving all the unclaimed tokens back. It's possible to get a snapshot of all the tokens claimed up to that point with the Claimed query, then create a new contract/campaign with the right data.
The owner of the contract is the only one who can create campaigns. A different address can be assigned as the owner of the campaign upon creation.
The owner of the campaign can top up the campaign with more tokens at any point before the campaign ends.
The owner of the campaign or the owner of the contract can close the campaign at any point before the campaign ends. When a campaign is ended, the owner of the campaign will receive the remaining, unclaimed tokens in the campaign.
Generating airdrop data
Generating the merkle root and proofs can be done by using the js scripts on the src code:
First, configure the csv file, which is formatted as formatted (with header) as contract_addr, address, amount.
node merkle_root.js
-> generates the merkle root
node merkle_proof.js
-> generates the proofs. Consider tweaking the variables in the script to generate valid proofs according to the csv data.
Use the merkle root when creating an airdrop campaign, and the merkle proofs to claim the airdrop with a given address.
Note: Only a single claim entry per address should be registered in the csv file. If an address has multiple entries, please consolidate them into a single entry, otherwise there will be issues at the contract level as the claims are considered to be unique in the contract.
The merkle_root.js
scripts validates addresses have a single entry in the csv file.
How it works
The Airdrop Manager contract is meant to host a single airdrop campaign per contract. When instantiating the contract, an owner can be specified. Only the owner of the contract can create new campaigns.
Once the contract is instantiated, a campaign can be created by the contract owner. When creating a campaign, there's a possibility to appoint a different address as the owner of the campaign. Only the owner of the campaign can top up the campaign.
If there's a mistake on the token distribution, i.e. the airdrop data was incorrect, the campaign can be closed by either the owner of the contract or campaign, returning the unclaimed funds to the owner of the campaign. Then, a new contract must be created to create a new campaign.
To claim an airdrop, the user needs to provide a valid merkle proof.
Instantiate
Instantiates an instance of the farm manager contract
ExecuteMsg
ManageCampaign
Manages a campaign based on the action, which can be:
CreateCampaign: Creates a new airdrop campaign, making sure all params are correct. Only the contract owner can perform this action.
TopUpCampaign: Adds additional funds to the campaign to be distributed. Only the campaign owner can perform this action.
CloseCampaign: Closes the campaign. The remaining unclaimed funds are returned the to owner of the campaign. Both the owner of the contract and campaign can perform this action.
Once created, the campaign is stored in the CAMPAIGN
item.
Note: the reward_asset
must be sent with this transaction.
Claim
Claims rewards from a campaign.
UpdateOwnership(::cw_ownable::Action)
Implements cw_ownable
. Updates the contract's ownership. ::cw_ownable::Action
can be TransferOwnership
, AcceptOwnership
and RenounceOwnership
.
Note: This is a cw_ownable
message.
Propose to transfer the contract's ownership to another account, optionally with an expiry time. Can only be called by the contract's current owner. Any existing pending ownership transfer is overwritten.
QueryMsg
Campaign
Get the airdrop campaign.
Rewards
Get the rewards for a specific campaign and receiver address.
Claimed
Get the total amount of tokens claimed on the campaign.
Last updated