Linear Vesting Airdrop
Sui Tears💧 Airdrop modules are "pulled" based. The modules store the root of a Merkle tree that consists of the address of the user and the airdrop amount. Users are required to submit a Merkle proof to claim their airdrops. The leafs are constructed by hashing (sha3256) the sender's address with the amount. This module returns the airdrop inside a linear vesting airdrop wallet.
Please check here on how to construct the Merkle Tree.
Structs
Airdrop
balance - Coins to airdrop
root - The root of the Merkle tree
start - The timestamp in which the vesting schedule starts.
duration - The duration of the vesting schedule.
map - Bitmap keeps track of airdrop claims.
Interface
new
Creates a linear vested airdrop.
@param airdrop_coin: The coin that will be distributed in the airdrop.
@param root: The Merkle tree root that keeps track of all the airdrops.
@param start: The start timestamp of the vesting schedule.
@param duration: The duration of the vesting schedule.
@param c: The
sui::clock::Clock
shared object.@return Airdrop<T>
Aborts
root is empty.
start time of the airdrop is in the past.
balance
Returns the current amount of airdrop coins in the Airdrop object.
@param: self The shared Airdrop object
@return u64
root
Returns the root of the Merkle tree for the airdrop.
@param: self The shared Airdrop object.
@return vector<u8>.
start
Returns the start timestamp of the airdrop. Users can claim after this date.
@param: self The shared Airdrop object.
@return u64.
duration
Returns the duration of the vesting schedule.
@param: self The shared Airdrop object.
@return u64.
borrow_map
Returns an immutable reference of the Bitmap. It keeps track of the claimed airdrops.
@param: self The shared Airdrop object.
@return &Bitmap.
has_account_claimed
Checks if a user has already claimed his airdrop.
@param self: The shared Airdrop object.
@param proof: The proof that the sender can redeem the
amount
from the airdrop.@param amount: Number of coins the sender can redeem.
@param address: A user address.
@return bool. True if he has claimed the airdrop already.
Aborts
If the
proof
is not valid.
get_airdrop
Allows a user to claim his airdrop by proving that his address and amount are in the Merkle tree.
@param self: The shared Airdrop object.
@param proof: The proof that the sender can redeem the
amount
from the airdrop.@param c: The
sui::clock::Clock
shared object.@param amount: Number of coins the sender can redeem.
@return Wallet. The airdrop Coin locked in a linear vested {Wallet}.
Aborts
If the
proof
is not valid.The user already claimed it
destroy_zero
Destroys an empty Airdrop.
@param self: The shared {Airdrop} object.
Aborts
The
self
has left over coins.
Last updated