Expand description
A program for distributing tokens efficiently via uploading a Merkle root.
This program is largely based off of Uniswap’s Merkle Distributor.
§Rationale
Although Solana has low fees for executing transactions, it requires staking tokens to pay for storage costs, also known as “rent”. These rent costs can add up when sending tokens to thousands or tens of thousands of wallets, making it economically unreasonable to distribute tokens to everyone.
The Merkle distributor, pioneered by Uniswap, solves this issue by deriving a 256-bit “root hash” from a tree of balances. This puts the gas cost on the claimer. Solana has the additional advantage of being able to reclaim rent from closed token accounts, so the net cost to the user should be around 0.000010 SOL
(at the time of writing).
The Merkle distributor is also significantly easier to manage from an operations perspective, since one does not need to send a transaction to each individual address that may be redeeming tokens.
§License
The Merkle distributor program and SDK is distributed under the GPL v3.0 license.
Modules§
- accounts
- An Anchor generated module, providing a set of structs
mirroring the structs deriving
Accounts
, where each field is aPubkey
. This is useful for specifying accounts for a client. - instruction
- An Anchor generated module containing the program’s set of
instructions, where each method handler in the
#[program]
mod is associated with a struct defining the input arguments to the method. These should be used directly, when one wants to serialize Anchor instruction data, for example, when speciying instructions on a client. - merkle_
distributor - The merkle_distributor program.
- merkle_
proof - These functions deal with verification of Merkle trees (hash trees). Direct port of https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0/contracts/cryptography/MerkleProof.sol
- program
- Module representing the program.
Structs§
- Claim
- merkle_distributor::claim accounts.
- Claim
Status - Holds whether or not a claimant has claimed tokens.
- Claimed
Event - Emitted when tokens are claimed.
- Merkle
Distributor - State for the account which distributes tokens.
- NewDistributor
- Accounts for merkle_distributor::new_distributor.
Enums§
- Error
Code - Error codes.
Statics§
- ID
- The static program ID
Functions§
- check_
id - Confirms that a given pubkey is equivalent to the program ID
- entry
- The Anchor codegen exposes a programming model where a user defines
a set of methods inside of a
#[program]
module in a way similar to writing RPC request handlers. The macro then generates a bunch of code wrapping these user defined methods into something that can be executed on Solana. - entrypoint⚠
- Safety
- id
- Returns the program ID