WENBlocks
  • Getting Started
    • Overview
      • Technical Architecture
    • Key Features
  • Staking
    • Overview
    • Creating a Stake
    • Withdrawing the Stake
    • Claiming Rewards
  • Liquidity Program
    • How It Works
  • WNT
    • WNT — The Engine of the WEN Ecosystem
  • Airdrops
    • Airdrop Schedule
    • Server Management
    • Penalty Structure
    • How It Works
    • Example
  • Smart Contracts
  • Security
    • Overview
    • Internal Audits
    • External Audits
    • AI Audits
      • Grok
  • CODE
    • WENBlocksManager.sol
    • wnmContract.sol
    • wblkToken.sol
    • wuniContract.sol
    • wntToken.sol
    • syncnode.py
    • airdropGenerator.js
    • dayTrigger.js
  • Conclusion
    • Conclusion
  • Socials
    • Links
Powered by GitBook
On this page
  1. Airdrops

How It Works

The airdrop system combines off-chain data processing with on-chain verification through Merkle trees:

  1. Data Synchronization:

    • The WENBlocks server runs the syncnode.py script to synchronize with XENBlocks: This includes the XNM, X.BLK, and XUNI holdings of users.

    def get_total_blocks():
        url = "http://xenblocks.io:4447/total_blocks"
        response = requests.get(url)
        if response.status_code == 200:
            try:
                data = json.loads(response.text)
                total_blocks_top100 = data.get("total_blocks", 0)
                adjusted_value = (total_blocks_top100 - 100) // 100
                return adjusted_value
            except Exception as e:
                print(f"Error parsing JSON: {e}")
        else:
            print(f"Failed to fetch data. Status code: {response.status_code}")
        return None

  2. Save and Generate Merkle Tree:

    • The fetched data is saved in a CSV file, which is then used to generate a Merkle Tree. This Merkle Tree is a cryptographic structure that allows for efficient and secure verification of the airdrop data:

      def build_merkle_tree(elements, merkle_tree={}):
          if len(elements) == 1:
              return elements[0], merkle_tree
      
          new_elements = []
          for i in range(0, len(elements), 2):
              left = elements[i]
              right = elements[i + 1] if i + 1 < len(elements) else left
              combined = left + right
              new_hash = hash_value(combined)
              merkle_tree[new_hash] = {'left': left, 'right': right}
              new_elements.append(new_hash)
          return build_merkle_tree(new_elements, merkle_tree)
  3. Push to Smart Contract:

    • The Merkle root (a unique cryptographic representation of the Merkle Tree) is pushed to the WENBlocks smart contract. This ensures that the airdrop data is securely submitted and verified on-chain: def build_merkle_tree(elements, merkle_tree={}):

          if len(elements) == 1:
              return elements[0], merkle_tree
      
          new_elements = []
          for i in range(0, len(elements), 2):
              left = elements[i]
              right = elements[i + 1] if i + 1 < len(elements) else left
              combined = left + right
              new_hash = hash_value(combined)
              merkle_tree[new_hash] = {'left': left, 'right': right}
              new_elements.append(new_hash)
          return build_merkle_tree(new_elements, merkle_tree)
The airdrop process is fully automated and occurs every 7 days at 00:00 UTC.
PreviousPenalty StructureNextExample

Last updated 1 month ago