lightbulb-exclamation-onCore Contract Functions Explained

(These functions power the entire burn-to-earn economy - let's break them down in detail)

  1. The Burn Function: burnNFT(uint256 tokenId)

What it does: This is how you destroy ("burn") your NFT to claim your portion of the ETC reward pool. It's the heart of the project's scarcity mechanism.

Step-by-Step Process:

  1. Ownership Check:

    • The contract first verifies you own the NFT you're trying to burn.

    • Technical: Calls ownerOf(tokenId) and compares to your wallet address.

  2. Burn Status Check:

    • Ensures the NFT hasn't already been burned.

    • Technical: Looks up tokenIdToBurned[tokenId] mapping.

  3. Reward Calculation:

    • Calculates your share of the locked ETC:

      uint256 remainingNFTs = (currentTokenId - 1) - totalBurned;
      uint256 reward = totalLockedValue / remainingNFTs;
    • Example: If there's 10 ETC locked and 100 NFTs remaining, you get 0.1 ETC.

  4. Funds Transfer:

    • Safely sends your reward to your wallet.

    • Security: Uses nonReentrant to prevent attacks.

  5. State Updates:

    • Marks NFT as burned (tokenIdToBurned[tokenId] = true)

    • Decreases totalLockedValue by the reward amount

    • Increments totalBurned counter

Why This Matters:

  • Creates artificial scarcity by reducing supply

  • Rewards participants for increasing the value of remaining NFTs

  • Entirely trustless - rewards are calculated automatically

2. The Receive Function: receive()

What it does: This special function allows anyone to add ETC to the reward pool by simply sending funds to the contract address.

Key Details:

  • No Function Call Needed: Just send ETC to the contract like a normal transaction

  • Automatic Accounting:

  • Transparent: Emits an EtherReceived event showing who contributed and how much

Use Cases:

  • Project team can seed initial rewards

  • Community members can voluntarily boost rewards

  • Future integrations can programmatically fund rewards

Special Note: This is a "fallback" function - it executes automatically when ETC is sent with no data. This makes contributions as simple as sending a normal payment.


🔄 How These Functions Work Together

  1. Minting: Users mint NFTs, 70% of mint price goes to totalLockedValue

  2. Contributing: Anyone can add more ETC via receive()

  3. Burning: Users burn NFTs to claim a share of the growing reward pool

Last updated