A decentralized NFT marketplace smart contract built on Stacks, featuring NFT minting with Bitcoin collateralization, fractional ownership, staking capabilities, and DeFi elements.
- Mint NFTs with Bitcoin (STX) collateral backing
- Transfer NFTs between wallets
- Minimum collateral ratio of 150% required for minting
- URI validation for NFT metadata
- List NFTs for sale with custom pricing
- Purchase NFTs with automatic fee distribution
- 2.5% protocol fee on all transactions
- Built-in overflow protection for mathematical operations
- Split NFT ownership into transferable shares
- Track share distribution across multiple owners
- Transfer shares between wallets with balance validation
- Stake NFTs to earn yield
- 5% annual yield rate
- Accumulated rewards calculation based on block height
- Claim rewards in STX tokens
- Unstake with automatic reward distribution
min-collateral-ratio: 150%
protocol-fee: 2.5% (25 basis points)
yield-rate: 5% annually (50 basis points)
u100
: Owner-only operationu101
: Not token owneru102
: Insufficient balanceu103
: Invalid tokenu104
: Listing not foundu105
: Invalid priceu106
: Insufficient collateralu107
: Already stakedu108
: Not stakedu109
: Invalid percentageu110
: Invalid URIu111
: Invalid recipientu112
: Overflow error
(contract-call? .nft-marketplace mint-nft "https://example.com/metadata.json" u1000)
(contract-call? .nft-marketplace list-nft u1 u5000)
(contract-call? .nft-marketplace purchase-nft u1)
;; Stake NFT
(contract-call? .nft-marketplace stake-nft u1)
;; Unstake NFT
(contract-call? .nft-marketplace unstake-nft u1)
(contract-call? .nft-marketplace transfer-shares u1 'SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7 u50)
-
Collateral Protection
- All NFTs must maintain minimum collateral ratio
- Collateral is locked in contract until NFT is burned or transferred
-
Access Control
- Owner-only functions for critical operations
- Token ownership verification for transfers and listings
- Contract self-calls prevented for sensitive operations
-
Mathematical Safety
- Overflow checking on all mathematical operations
- Safe addition implementation for balance updates
- Percentage calculations use basis points for precision
get-token-info
: Retrieve token detailsget-listing
: Get active listing informationget-fractional-shares
: Query share ownershipget-staking-rewards
: Check accumulated rewardscalculate-rewards
: Preview pending staking rewards
- Clarity contract deployment environment
- Access to Stacks blockchain
- Understanding of Bitcoin and STX token mechanics
Recommended test coverage should include:
- NFT minting with various collateral ratios
- Marketplace operations with edge cases
- Staking reward calculations
- Fractional ownership transfers
- Error condition handling
This smart contract is provided underunder the MIT License. See the LICENSE file for details.
Note: This is a complex smart contract handling real value. Thorough audit and testing are strongly recommended before mainnet deployment.