This repository contains smart contracts for an advanced NFT-based land ownership and rental system with an integrated marketplace. The system allows for tokenization of land ownership, facilitates various trading mechanisms, and supports temporary transfers of usage rights.
Purpose: This interface extends the ERC721 standard to include user and expires functionality, enabling time-limited permissions on NFTs. It's crucial for implementing rental or time-limited usage features for NFTs.
Key Functions:
setUser(uint256 tokenId, address user, uint64 expires)
: Assigns user rights to an address for a specific NFT with an expiration time.userOf(uint256 tokenId)
: Retrieves the current user of an NFT.userExpires(uint256 tokenId)
: Returns the expiration timestamp of the current user's rights.
Events:
UpdateUser(uint256 indexed tokenId, address indexed user, uint64 expires)
: Emitted when user rights are updated.
Purpose: This is the core NFT contract representing land ownership as non-fungible tokens. It implements ERC721 and IERC4907 standards, allowing for ownership and time-limited usage rights.
Key Features:
- ERC721 Compatibility: Implements standard NFT functions like
transfer
,approve
, etc. - Minting: Allows creation of new land NFTs with associated metadata.
- User Rights Management: Implements IERC4907 for managing temporary usage rights.
- Supply Control: Includes a maximum supply limit and tracking of total supply.
- Metadata Management: Uses ERC721URIStorage for flexible metadata handling.
Key Functions:
mint(string calldata MtokenURI)
: Mints a new land NFT with specified metadata.setUser(uint256 tokenId, address user, uint64 expires)
: Sets temporary user rights for an NFT.userOf(uint256 tokenId)
: Returns the current user of an NFT.userExpires(uint256 tokenId)
: Returns the expiration time of user rights.setMaxSupply(uint256 maxSupply_)
: Allows owner to adjust the maximum supply.
Security Measures:
- Access Control: Uses OpenZeppelin's
Ownable
for restricted functions. - Checks: Implements various require statements to ensure valid operations.
Purpose: This contract provides a comprehensive platform for trading and renting LandChain NFTs through various mechanisms including auctions, direct sales, and rentals.
Key Features:
-
Auctions
- Creation: Sellers can create time-limited auctions for their NFTs.
- Bidding: Users can place bids on active auctions.
- Automatic Extension: Auctions are extended if a bid is placed near the end time.
- Settlement: Auctions can be settled after the end time, transferring the NFT and funds.
-
Direct Sales
- Listing: Sellers can list their NFTs for a fixed price.
- Purchasing: Buyers can directly purchase listed NFTs.
- Cancellation: Sellers can cancel their listings.
-
Rentals
- Listing: NFT owners can list their tokens for rent with a price and duration.
- Renting: Users can rent NFTs, gaining temporary usage rights.
- Cancellation: Owners can cancel their rental listings.
-
Financial Management
- Platform Fees: Implements a percentage-based fee on all transactions.
- Withdrawals: Users can withdraw funds from outbid or cancelled transactions.
- Owner Withdrawals: Contract owner can withdraw accumulated platform fees.
Key Functions:
- Auction Functions:
createAuction
,placeBid
,endAuction
- Direct Sale Functions:
createDirectSale
,buyDirectSale
,cancelDirectSale
- Rental Functions:
createRentSale
,rentNFT
,cancelRentSale
- Financial Functions:
withdraw
,withdrawPlatformFees
- Management Functions:
setNftContract
,setPlatformFee
,pause
,unpause
Security Measures:
- Reentrancy Guard: Uses OpenZeppelin's
ReentrancyGuard
to prevent reentrancy attacks. - Pausability: Implements
Pausable
for emergency stops. - Access Control: Utilizes
Ownable
for restricted functions. - Checks-Effects-Interactions Pattern: Follows best practices to prevent potential vulnerabilities.
- NFT Creation: Users mint land NFTs using the
LandChain
contract. - Marketplace Interaction: NFT owners can list their tokens on the
Marketplace
contract. - Trading Options:
- Sellers can create auctions, direct sales, or rental listings.
- Buyers can bid on auctions, purchase directly, or rent NFTs.
- Transaction Settlement: The marketplace handles transfers of NFTs and funds, including fee calculations.
- Rental Management: For rented NFTs, the system manages temporary user rights and expirations.
- The contracts inherit from OpenZeppelin's audited contracts for enhanced security.
- Reentrancy guards are implemented to prevent common attack vectors.
- The system uses a checks-effects-interactions pattern to ensure state consistency.
- Pausability allows for emergency stops in case of detected issues.
- Access control mechanisms restrict sensitive functions to authorized users only.
When deploying these contracts:
- Deploy the
LandChain
contract first. - Deploy the
Marketplace
contract, passing the address of theLandChain
contract. - Call
setApprovalForAll
on theLandChain
contract to approve theMarketplace
for trading.
- Implementation of API of UK Real Estate System for verification of the owner of the property
- Integration with real-world land registry systems for increased utility.
- Addition of fractional ownership capabilities for land NFTs.
This system provides a robust, secure, and flexible solution for tokenizing land ownership, facilitating various trading mechanisms, and managing temporary usage rights, all secured on the blockchain.