Megapont Ape Club NFT

By @MegapontNFTarrow-up-right

circle-info

Deployed contract page found herearrow-up-right.

Contract Summary

The Megapont Ape Club NFT contract is a production-ready SIP-009 compliant NFT implementation featuring a 2,500-piece limited collection with built-in marketplace functionality. This contract serves as an excellent reference for developers looking to build feature-complete NFT projects on Stacks.

Key Features:

  • SIP-009 Standard Compliance - Implements the official Stacks NFT trait for full ecosystem compatibility

  • Built-in Marketplace - List, unlist, and buy NFTs directly through the contract without external marketplaces

  • Multi-Wallet Revenue Split - Automatic distribution of mint proceeds to 4 wallets with custom percentages

  • Mintpass System - Controlled minting through a separate mint contract for presale/whitelist functionality

  • Metadata Management - Configurable base URI with optional metadata freeze for permanence

  • Commission System - Flexible commission trait integration for marketplace fees

What Developers Can Learn:

  • How to implement SIP-009 NFT standard with marketplace features

  • Revenue splitting patterns for team/partner payouts

  • Access control patterns using contract-caller verification

  • Safe NFT transfer mechanisms with balance tracking

  • Marketplace listing/delisting patterns with commission handling



Function-by-Function Breakdown

SIP-009 Standard Functions

transfer (id uint) (sender principal) (recipient principal)

Transfers an NFT from sender to recipient, enforcing that the transaction sender must be the token owner and the NFT is not currently listed on the marketplace.

get-owner (id uint)

Returns the principal that owns the specified NFT ID.

get-last-token-id

Returns the ID of the most recently minted NFT, useful for tracking total supply.

get-token-uri (id uint)

Returns the base metadata URI for the NFT collection.

get-contract-uri

Returns the contract-level metadata URI containing collection information.

Minting Functions

mint (new-owner principal)

Mints a new NFT to the specified owner, automatically distributing the 50 STX mint price across 4 wallets. Can only be called by the authorized mint contract.

set-mint-address

One-time function to set which contract is authorized to call the mint function. Once set, it cannot be changed.

called-from-mint

Private helper function that verifies the caller is the authorized mint contract.

Marketplace Functions

list-in-ustx (id uint) (price uint) (comm <commission-trait>)

Lists an NFT for sale at the specified price in micro-STX, associating it with a commission contract. Only the NFT owner can list.

unlist-in-ustx (id uint)

Removes an NFT from marketplace listings. Only the NFT owner can unlist.

buy-in-ustx (id uint) (comm <commission-trait>)

Purchases a listed NFT, transferring STX to the seller, paying commission, and transferring the NFT to the buyer.

get-listing-in-ustx (id uint)

Returns the listing details (price and commission contract) for a given NFT ID if it's listed.

Balance & Ownership Helpers

get-balance (account principal)

Returns the number of NFTs owned by a given principal.

trnsfr (id uint) (sender principal) (recipient principal)

Private helper function that handles the actual NFT transfer and updates balance mappings.

is-sender-owner (id uint)

Private helper that verifies if the transaction sender or contract caller owns the specified NFT.

Admin/Metadata Functions

set-base-uri (new-base-uri (string-ascii 80))

Allows the contract owner to update the base metadata URI, but only if metadata hasn't been frozen.

freeze-metadata

Permanently freezes the metadata URI, preventing any future changes. This is irreversible.

Traits Used

nft-trait

SIP-009 NFT standard trait for ecosystem compatibility

commission-trait

Custom trait for handling marketplace commission payments


Key Concepts

Multi-Wallet Revenue Distribution

The mint function automatically splits the 50 STX mint price across 4 wallets with predefined percentages (47.5%, 45%, 5%, 2.5%). This pattern is useful for team splits, royalties, and service fees.

Mintpass Architecture

The contract uses a two-contract pattern where minting is delegated to a separate "mint" contract. This allows for flexible presale mechanics, whitelist management, and phased releases without modifying the core NFT contract.

Balance Tracking Pattern

Unlike basic NFT implementations, this contract maintains a token-count map to track how many NFTs each principal owns. This enables efficient balance queries without iterating through all NFTs.

Marketplace Integration

The built-in marketplace uses a commission trait pattern, allowing the contract to work with different commission structures. When listing an NFT, the owner specifies both price and commission contract, ensuring commission rules are locked at listing time.

Last updated

Was this helpful?