idand the module allows the users involved to autonomously claim tokens in the temporal window between the
Merkle Tree. Thanks to the features of these data structure (i.e., a binary tree where each non-leaf node is the hash of its childs) they are particularly efficient in space usage and during the verification process (as explained in the Verification process).
actual block height + 100000.
start_heightand lower than a maximum value of
start_height + 5000000.
denomof the token to drop.
amountof token to drop.
merkledropmodule keeps track of LastMerkledropId, Merkledrops, Indexes and Parameters.
uint64, automatically incremented everytime a new merkledrop is created;
denomof the token to drop;
amountof token to drop;
msgs) are objects that trigger state transitions. Messages are wrapped in transactions (
txs) that clients submit to the network. The BitSong SDK wraps and unwraps
merkledropmodule messages from transactions.
MsgCreatemessage is used to create a new merkledrop. It takes as input
Coin. The value of the block height at which the drop become available (the starting block) must be greater or equal to the block height where the transaction is included. For this reason, if the users select 0 as
StartHeightit will be automatically set to the current block height (the one where the transaction is included). Moreover, there exists an upper bound for this value, that corresponds to the value of the
actual block height + 100000. This choice derives from a design pattern that avoid the generation of spam merkledrop. At the same time, the
EndHeightvalue, which corresponds to the block height where the merkledrop can be considered expired and the withdrawal is executed if part of the tokens were not claimed. This value must be greater than the
StartHeightand lower than a maximum value of
StartHeight + 5000000. The
Coinis made up of the
denomof the token to distribute and the
amount, which corresponds to the sum of all the tokens to drop. Once the module has verified that the
owneraddress is valid and that the
merkletree rootis a hexadecimal character string, it deduct the
creation feefrom the owner wallet and send the
coin(the amount of token to drop), from the owner address to the module. At this point, the
LastMerkleDropIdis increased and the merkledrop is created, by assigning zero to the claimed value (since at the creation time, no one claimed any token). They are added three indexes:
EventCreateis emitted at the end of the creation process.
MsgClaimmessage is used to claim tokens from an active merkledrop. It takes as input
Amountto claim, and a list of
Proofs. In such a scenario, verified the validity of the
senderaddress and the existence of the merkledrop by the ID, if the airdrop is currently active (i.e., its
start block heightis lower than the current block height and its
end block heightis greater than the current one), the module verifies if the
senderalready claimed his tokens (by querying at an index). In case he didn't, the module proceeds retriving the merkletree root for the merkledrop from the chain and verifies the proofs (as described in the verification process). After tese verifications, the module only checks if the coin the
senderwants to claim are available, and send those tokens from the module to the
senderwallet. At this point, the claim is stored through its index, the claimed tokens are added to the actually claimed amount and, if all the drops are claimed with this operation, the merkledrop is cleaned by the state. An event of type
EventClaimis emitted at the end of the claim process.
EndHeight(i.e., the block height at which the airdrop expires), the module can verify at each block if there is any expired merkledrop at that particular time. To perform the operations, the module is able to retrive the the merkledrops ids by the
EndHeightand to process those drops. In particular, for each retrived merkledrop they are executed the
withdrawof the unclaimed tokens and then, the merkledrop is cleaned by the state.
EndHeightblock the merkledrop is still in the store, it means that not all the tokens were claimed. For this reason, the module automatically performs a withdraw of the unclaimed tokens to the owner wallet. In particular, the module verifies if the
total amountis lower than the
claimed amount, calculates the balance as the unclaimed tokens (i.e., the
total amount- the
claimedone). This amount is sent to the owner wallet and a corresponding event of type
owner, all the indexes linked to its
idare deleted together with the
merkledropobject in the store.
transactionscommands allow users to
querycommands allow users to query the merkledrop module.