MANTRA Chain
  • Introduction
    • Overview
    • Why MANTRA Chain
    • Building on MANTRA Chain
    • MANTRA RWA Suite
  • Using MANTRA Chain
    • MANTRA Chain Wallet Setup
      • Connect to Testnet
      • Connect to Mainnet
      • Testnet Faucet
    • MANTRA Zone
    • MANTRA Bridge
      • MANTRA Bridge User Guide
      • MANTRA Bridge FAQs
    • Stake
      • Stake User Guide
      • Stake FAQs
    • MANTRA Swap
      • MANTRA Swap User Guide
      • Liquidity Pools User Guide
      • MANTRA Swap FAQs
    • Claiming Journey
      • Check If You're Eligible
      • Claiming Journey User Guide
      • I've redeemed my rewards, now what?
    • Chakra Pool
      • What can I do with my USDY
      • Chakra Pool Deposit Guide
      • How KARMA works for Chakra Pool
        • How much KARMA do I get for depositing into Chakra Pool?
        • Can I make multiple deposits and how will KARMA be calculated then?
        • My KARMA is not updated even though I make multiple deposits?
        • Will I get daily KARMA for my deposit on USDY Chakra Pool launched on Hongbai earlier?
      • Chakra Pool FAQs
    • MANTRA Zone Leaderboard
      • MANTRA Zone Leaderboard User Guide
        • Mission Guides
          • Pledge your OM 🕉️
          • Claim OM Staking Rewards
          • OMly Drip 💧
      • MANTRA Zone Leaderboard FAQs
  • Developing on MANTRA Chain
    • Getting Started
      • DuKong Testnet
      • Install Prerequisites
      • Setting Up Dev Environment
      • Compiling a Contract
      • Deployment and Interaction
    • CosmWasm Quick Start Guide
      • CosmWasm Contracts
      • Understanding CosmWasm File Structure
    • DAPP Tooling
      • Cosmos SDK
      • Important Libraries
      • Developer Resources
    • Developer FAQs
  • MANTRA Smart Contracts
    • Overview
    • MANTRA Dex
      • 🚢Deployments
      • 📚Common Types
      • 💰Fee Collector
      • ⌛Epoch Manager
      • 🌊Pool Manager
      • 🎁Farm Manager
    • Claimdrop Contract
    • Audits
  • Node & Validator Operations
    • Overview
    • Node Setup & Deployment
      • Node System Requirements
      • Running a Node
      • How to run Mantrachain with Systemd
      • Validator Nodes
        • Connect sidecar
    • Validator Architecture Recommendations
      • Secure Validator
    • Governance
      • Draft a Proposal
        • Text Proposal
        • Community Spend Proposal
        • Software Upgrade
        • Cancel Software Upgrade
      • Submitting a Proposal
      • Verifying your transaction
      • Depositing funds
      • Voting on a Proposal
    • Download nodes snapshots
  • MANTRA Chain with EVM (Alpha)
    • Getting Started on OMSTEAD Testnet
  • Setup Instructions
  • Using Foundry
    • Deployment with Foundry
  • Using Hardhat
    • Deployment with Hardhat
  • Mainnet OM Information
    • Background
    • Updated OM Tokenomics
    • OM Distribution Updates
    • Inflation & Vesting Schedule
    • Legacy tokens to mainnet staking tokens
  • Appendix
    • Frequently Asked Questions
      • General FAQs
        • What is MANTRA Chain?
        • What are the key features/ modules available to builders on MANTRA Chain?
        • What support is available for developers and validators that join the ecosystem
        • Where can i find MANTRA Social Accounts & Communities?
        • How can an Issue or a bug be reported?
        • How can I identify official MANTRA communication and websites?
      • Validator FAQs
        • What does a new validator’s journey look like?
        • What are my key responsibilities as a validator?
        • What is uptime and how is it maintained?
        • What are the hardware requirements?
        • How to get validator keys?
        • How can I connect a validator from an older testnet to the newest testnet?
        • How do I create a backup snapshot of a node?
        • How do I restore a node from a snapshot?
        • What are the different states a validator can be in?
        • How do I unjail a validator?
        • How do I edit a validator's description?
        • What is self-delegation?
        • Is there a minimum amount of OM that must be delegated to be an active validator?
      • Developer FAQs
        • What is MANTRA Chain, and how does it utilize the Cosmos ecosystem?
        • How does MANTRA Chain ensure interoperability with other blockchains in the Cosmos ecosystem?
        • What is the Cosmos ecosystem, and how does it differ from other blockchain platforms?
        • Which programming languages are commonly used for developing on the Cosmos ecosystem?
        • How do I get started with development on the Cosmos ecosystem?
        • What are Cosmos SDK and Tendermint, and how do they work together?
        • What are Cosmos zones and how do they interact?
        • How do I build and deploy smart contracts on the Cosmos ecosystem?
        • How do I interact with Cosmos chains and applications programmatically?
        • What is the best way to learn about developing for the MANTRA Chain and Cosmos ecosystem?
      • Hongbai FAQs
        • Where do I sign up for Hongbai?
        • Why do I need to provide 2 wallets during signup?
        • How can I Login?
        • What should I do if I forgot my password?
        • What can I do if i forget my registered email?
        • Where do i verify my email?
        • How to connect my Metamask wallet?
        • Is Hongbai app a testnet or live app?
        • Can I change my wallet ?
        • Error “invalid user credentials“
        • Why can i not Invest?
      • How to Guides
        • Install Keplr Wallet
        • Keplr and Ledger
        • Add DuKong Testnet to Keplr
        • Get Tokens from Faucet
        • Track activity on Leaderboard
      • More Help & Support
      • MANTRA Zone FAQs
        • MANTRA Zone General FAQs
          • What wallets are currently supported on the MANTRA Zone?
          • How do I connect my wallet to the MANTRA Zone?
          • How do I copy my connected wallet’s address?
          • How do I connect a different wallet to the MANTRA Zone?
          • Can I disconnect my wallet from MANTRA Zone?
          • How can I resolve seeing multiple entires of the same amount of testnet OM in my Keplr wallet?
          • The question that I have is not covered by the FAQ, what should I do?
        • MANTRA Bridge FAQs
          • What is MANTRA Bridge?
          • Why should I use the MANTRA Bridge?
          • Is there a fee for using the MANTRA Bridge?
          • Do I have to pay gas fees?
          • What tokens will I receive?
          • How does the migration process work?
          • How long should the MANTRA Bridge order take?
          • How can I track the status of my MANTRA Bridge order?
          • What happens to my ERC20 OM tokens once I use the MANTRA Bridge?
          • Which network can I use on the MANTRA Bridge?
          • What should I do if I see ‘Wrong network’ error on the app?
          • Will there be a two-way bridge in the future?
          • My MANTRA Bridge order is stuck on Ethereum?! How can I fix this?
          • Who can I contact for support during the migration process?
          • Which EVM chains can I bridge from?
          • Are the OM tokens I receive wrapped tokens or the native MANTRA Chain OM tokens?
          • Is the MANTRA Bridge a non-custodial solution?
          • What happens if the MANTRA Bridge is hacked or goes offline?
          • Are there any risks associated with using the MANTRA Bridge?
          • How does the MANTRA Bridge ensure the security of my tokens during migration?
          • Can I use my existing Ethereum wallet to access the MANTRA Bridge?
          • How does wallet linking and airdrop participation work?
        • Stake FAQs
          • What is Stake?
          • What are validators, and how do I choose one?
          • What rewards can I earn by staking $OM?
          • How are staking rewards calculated?
          • Can I choose to unstake my $OM coins?
          • What is the unbonding period?
          • Can I change validators after staking $OM?
          • Can I stake $OM with multiple validators?
          • Are there any risks involved with staking $OM?
          • Will my rewards gets automatically restaked after redemption?
          • Do I lose my claimable rewards when performing actions with a validator with unclaimed rewards?
          • My wallet is showing a 0 balance even though I have funds. What should I do?
          • How do I know if my $OM is staked?
        • Chakra Pool FAQs
          • What are the Chakra Pool rewards?
          • What is USDY?
          • How do I get the yield from the treasury bonds by holding USDY?
          • Can I change my linked wallet?
          • I don’t remember my linked wallet - what can I do?
          • What are the bonus rewards and where I can see my rewards?
          • How are the USDY rewards calculated and when can I redeem my USDY rewards?
          • How are the $OM rewards calculated and when can I redeem my $OM rewards?
          • How are the $ONDO rewards calculated and when can I redeem my $ONDO rewards?
          • What can I do with my USDY and $OM rewards after redemption?
        • MANTRA Zone Leaderboard FAQs
          • I have someone that wants to participate in the MANTRA Zone Leaderboard but they don’t know how.
          • What does the ⚡icon and ‘Get + x KARMA’ text under the ‘KARMA’ section refer to?
          • The KARMA on the Zone Leaderboard only lists MANTRA Chain wallets, how to check my EVM wallet rank?
          • Which wallet IDs are visible on the Leaderboard Ranking Table?
          • Why are there three different categories for the Leaderboard Ranking Table?
          • How can I get the Leaderboard Ranking Table to show where my connected wallet ranks currently?
          • How can I search where a specific wallet ID ranks in the Leaderboard Ranking Table?
          • How can I search what wallet ID currently ranks in a specific ranking number?
          • My KARMA and/or multiplier amount did not update on the Leaderboard Ranking Table, why is that?
          • What is the calculation for the KARMA?
          • I’m unable to see the OMly Faucet on my Keplr/Cosmostation wallet
          • I'm unable to see my OMly Faucet Claim transaction on the explorer
          • The question that I have is not covered by the FAQ, what should I do?
        • MANTRA Swap FAQs
          • What is Swap?
          • How can I swap?
          • I have connected my EVM wallet, but I’m still unable to swap. Why?
          • Where can I view my past transactions?
          • Why is my swap button disabled?
          • Why can’t I swap with a slippage more than 5%?
          • What is Exchange Rate?
          • How do I get OM tokens in my wallet?
          • How do I get other tokens in my wallet?
          • Will the swap fee be deducted from my sell or buy token?
          • Why can’t I see the balance of tokens in my wallet but on the Swap panel?
          • How do I add liquidity to a pool?
          • I am unable to provide liquidity to the pool.
          • While adding liquidity, why are the two tokens USD value not equal?
          • How do I withdraw my funds from Liquidity Pools?
          • Why can I not see my tokens for withdrawal?
          • Why can I not remove liquidity?
          • Why is my deposited value of the two tokens changing in my position?
          • Do liquidity pools have a bonding period?
          • What are LP tokens?
          • What can I do with my LP tokens?
          • Why can I not see any LP token balance?
          • I am connected with my MANTRA wallet, but still cannot view my positions?
          • I provided liquidity, but I can’t see my position. What should I do?
          • Why is my transaction not successful?
    • Glossary
    • MANTRA's Incentivised Testnet
      • Testnet Phase 1
      • Hongbai - Testnet Phase 2
  • Third Party Bridges
    • Base Bridge
    • Polygon Bridge
Powered by GitBook
On this page
  • Features
  • Generating airdrop data
  • How it works
  • Instantiate
  • ExecuteMsg
  • ManageCampaign
  • Claim
  • UpdateOwnership(::cw_ownable::Action)
  • QueryMsg
  • Campaign
  • Rewards
  • Claimed
  1. MANTRA Smart Contracts

Claimdrop Contract

The Claimdrop Contract is a smart contract designed to distribute tokens to a list of addresses in a secure and efficient manner. 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.

  • The linear version distribution may or may not have a cliff duration.

  • 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.

  • The user can claim tokens from the campaign by providing a valid merkle proof. This can happen at any point once the campaign has started and before it is ended (closed by the campaign owner or contract owner). Any dust left when claiming due to rounding errors can be redeemed by the user once the distribution types have ended, which may or may not coincide with the end of 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.

contract_addr,address,amount
mantra1j28m8g0afvfr23423k5wypfykqrxsu94xhxvxdeyrfc4jkqm7zhqckdf5w,mantra1x5nk33zpglp4ge6q9a8xx3zceqf4g8nvaggjmc,100
mantra1j28m8g0afvfr23423k5wypfykqrxsu94xhxvxdeyrfc4jkqm7zhqckdf5w,mantra1rj2n3hge32n5u6zzw0u7clrys76srapulsvv39,200
mantra1j28m8g0afvfr23423k5wypfykqrxsu94xhxvxdeyrfc4jkqm7zhqckdf5w,mantra18mv5sz7nj2arpsqjc2aeslhh3v475np8ng6tt5,300
mantra1j28m8g0afvfr23423k5wypfykqrxsu94xhxvxdeyrfc4jkqm7zhqckdf5w,mantra16qtk5fnm4se6362yaah0scdmatx0qvp70fhej2,400

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

{
  "owner": "mantra1..."
}
Key
Type
Description

owner

Option<String>

The owner of the contract. If none is provided, the address instantiating the contract becomes the owner.

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.

{
  "manage_campaign": {
    "action": {
      "create_campaign": {
        "params": {
          "owner": "mantra1...",
          "name": "Airdrop",
          "description": "This is an airdrop description.",
          "reward_asset": {
            "denom": "uom",
            "amount": "888888888888"
          },
          "distribution_type": [
            {
              "lump_sum": {
                "percentage": "0.25",
                "start_time": 1571797419
              }
            },
            {
              "linear_vesting": {
                "percentage": "0.75",
                "start_time": 1572402219,
                "end_time": 1573007019,
                "cliff_duration": 86400
              }
            }
          ],
          "start_time": 1571797419,
          "end_time": 1573007019,
          "merkle_root": "b32b978b07b56e8f10de1f098390407017daa61c90da6a6875ca0f2d655b6107"
        }
      }
    }
  }
}
Key
Type
Description

owner

Option<String>

The campaign owner. If none is provided, the sender of the message will the owner.

name

String

The name of the campaign. The name cannot be empty nor above 50 chars in length.

description

String

The description of the campaign. The description cannot be empty nor above 500 chars in length.

reward_asset

Coin

The asset to be distributed as reward by the campaign

distribution_type

Vec<DistributionType>

The distribution types. It can be two at most, and it can be a combination of LumpSum and LinearVesting. The percentage of both distributions needs to be equal to 100%, and their start time needs to be in the future.

start_time

u64

The campaign start time (unix timestamp), in seconds.

end_time

u64

The campaign end timestamp (unix timestamp), in seconds.

merkle_root

String

The campaign merkle root.

Note: the reward_asset must be sent with this transaction.

{
  "manage_campaign": {
    "action": {
      "top_up_campaign": {}
    }
  }
}

Note: the same denom set as reward_asset when creating the campaign must be sent with this transaction. Can't top up a campaign that has been closed.

{
  "manage_campaign": {
    "action": {
      "close_campaign": {}
    }
  }
}

Note: Can't close a campaign which has already been closed.

Claim

Claims rewards from a campaign.

{
  "claim": {
    "total_claimable_amount": "88888",
    "receiver": "mantra1...",
    "proof": [
        "1b20d6e1fa2e464d3a94fabdf28add25b6152663aa19efe1b6da2f28f50412cd",
        "27c16d1dd47dedab5c9d394d02b507e3abd01ef11f753ffc3148b04bd1aa0487"
    ]
  }
}
Key
Type
Description

total_claimable_amount

Uint128

The total claimable amount from the campaign.

receiver

Option<String>

The receiver address of the claimed rewards. If not set, the sender of the message will be the receiver. This is useful for allowing a contract to do the claim operation on behalf of a user.

proof

Vec<String>

A Vector of all necessary proofs for the merkle root verification, hex-encoded.

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.

{
  "update_ownership": {
    "transfer_ownership": {
      "new_owner": "mantra1...",
      "expiry": {
        "at_height": "424242424242"
      }
    }
  }
}
Key
Type
Description

new_owner

String

The new owner proposed,

expiry

Option<Expiration>

Optional expiration time parameter.

Accept the pending ownership transfer. Can only be called by the pending owner.

{
  "update_ownership": {
    "accept_ownership": {}
  }
}

Give up the contract's ownership and the possibility of appointing a new owner. Can only be invoked by the contract's current owner. Any existing pending ownership transfer is canceled.

{
  "update_ownership": {
    "renounce_ownership": {}
  }
}

QueryMsg

Campaign

Get the airdrop campaign.

{
  "campaign": {}
}
{
  "owner": "mantra1...",
  "name": "Airdrop title",
  "description": "Airdrop description",
  "reward_asset": {
    "denom": "uom",
    "amount": "888888888888"
  },
  "claimed": {
    "denom": "uom",
    "amount": "8888"
  },
  "distribution_type": [
    {
      "lump_sum": {
        "percentage": "0.25",
        "start_time": 1571797419
      }
    },
    {
      "linear_vesting": {
        "percentage": "0.75",
        "start_time": 1572402219,
        "end_time": 1573007019,
        "cliff_duration": 86400
      }
    }
  ],
  "start_time": 1571797419,
  "end_time": 1573007019,
  "merkle_root": "b32b978b07b56e8f10de1f098390407017daa61c90da6a6875ca0f2d655b6107",
  "closed": 1573008019
}
Key
Type
Description

owner

Addr

The campaign owner. If none is provided, the sender of the message will the owner.

name

String

The name of the campaign. The name cannot be empty nor above 50 chars in length.

description

String

The description of the campaign. The description cannot be empty nor above 500 chars in length.

reward_asset

Coin

The asset to be distributed as reward by the campaign

distribution_type

Vec<DistributionType>

The distribution types. It can be two at most, and it can be a combination of LumpSum and LinearVesting. The percentage of both distributions needs to be equal to 100%, and their start time needs to be in the future.

start_time

u64

The campaign start time (unix timestamp), in seconds.

end_time

u64

The campaign end timestamp (unix timestamp), in seconds.

merkle_root

String

The campaign merkle root.

closed

Option<u64>

The timestamp at which the campaign was closed, in seconds.

Rewards

Get the rewards for a specific campaign and receiver address.

{
  "rewards": {
    "total_claimable_amount": "8888",
    "receiver": "mantra1...",
    "proof": [
      "1b20d6e1fa2e464d3a94fabdf28add25b6152663aa19efe1b6da2f28f50412cd",
      "27c16d1dd47dedab5c9d394d02b507e3abd01ef11f753ffc3148b04bd1aa0487"
    ]
  }
}
Key
Type
Description

total_claimable_amount

Uint128

The total claimable amount for the campaign.

receiver

String

The address to get the rewards for.

proof

Vec<String>

A Vector with the necessary proofs for the merkle root verification, hex-encoded.

{
  "claimed": [
    {
      "denom": "uom",
      "amount": "888"
    }
  ],
  "pending": [
    {
      "denom": "uom",
      "amount": "8000"
    }
  ],
  "available_to_claim": [
    {
      "denom": "uom",
      "amount": "1000"
    }
  ]
}
Key
Type
Description

claimed

Vec<Coin>

The tokens that have been claimed by the address.

pending

Vec<Coin>

The total amount of tokens that is pending to be claimed by the address.

available_to_claim

Vec<Coin>

he tokens that are available to be claimed by the address.

Claimed

Get the total amount of tokens claimed on the campaign.

{
  "claimed": {
    "address": "mantra1...",
    "start_from": "mantra1...",
    "limit": 50
  }
}
Key
Type
Description

address

Option<String>

If provided, it will return the tokens claimed by the specified address.

start_from

Option<String>

If provided, the address to start querying from. Used for paginating results.

limit

Option<u8>

The maximum number of items to return. If not set, the default value is used. Used for paginating results.

{
  "claimed": [
    ["mantra1...", { "denom": "uom", "amount": "1000" }],
    ["mantra1...", { "denom": "uom", "amount": "8888" }]
  ]
}
Key
Type
Description

claimed

Vec<(String, Coin)>

Contains a vector with a tuple with (address, coin) that have been claimed

PreviousFarm ManagerNextAudits

Last updated 5 months ago