Tokenizing Real-World Assets on the Blockchain
The RWA NFT Smart Contract is a comprehensive Solidity-based solution for tokenizing real-world assets as NFTs on Ethereum and EVM-compatible blockchains. This project enables the representation of physical assets like real estate, art, vehicles, and more as digital tokens with full on-chain verification and marketplace functionality.
- π¨ ERC-721 Standard: Full compliance with ERC-721 NFT standard
- β Asset Verification: Built-in verification system for real-world assets
- π Metadata Management: Comprehensive metadata storage including valuation, location, and legal documents
- π Access Control: Role-based permissions (Minter, Verifier, Admin)
- π° Royalty Support: EIP-2981 compliant royalty system
- πͺ Marketplace: Integrated marketplace for listing, buying, and auctioning NFTs
- β±οΈ Auction System: Time-based auctions with automatic bid refunds
- π‘οΈ Security: ReentrancyGuard, Pausable, and battle-tested OpenZeppelin contracts
- π¦ Batch Operations: Efficient batch minting capabilities
-
RWANFT.sol - Main NFT contract
- ERC-721 implementation for tokenizing real-world assets
- Role-based access control (Minter, Verifier, Pauser)
- Asset metadata and verification tracking
- Royalty system
- Pausable for emergency stops
-
RWAMarketplace.sol - Marketplace contract
- NFT listing and buying
- Auction creation and bidding
- Platform fee management
- Secure payment handling
struct AssetMetadata {
string assetType; // e.g., "Real Estate", "Art", "Vehicle"
string location; // Physical location
uint256 valuationUSD; // Valuation in USD cents
uint256 mintTimestamp; // Minting time
uint256 lastVerifiedDate; // Last verification timestamp
bool isVerified; // Verification status
string documentHash; // IPFS hash of legal documents
}Minting
function mintAsset(
address to,
string memory uri,
string memory assetType,
string memory location,
uint256 valuationUSD,
string memory documentHash
) public onlyRole(MINTER_ROLE) returns (uint256)Verification
function verifyAsset(uint256 tokenId) public onlyRole(VERIFIER_ROLE)Batch Minting
function batchMintAssets(...) public onlyRole(MINTER_ROLE) returns (uint256[] memory)struct Listing {
uint256 listingId;
address nftContract;
uint256 tokenId;
address seller;
uint256 price;
bool isActive;
uint256 listedAt;
}List NFT
function listNFT(
address nftContract,
uint256 tokenId,
uint256 price
) public returns (uint256)Buy NFT
function buyNFT(uint256 listingId) public payableCreate Auction
function createAuction(
address nftContract,
uint256 tokenId,
uint256 startingPrice,
uint256 duration
) public returns (uint256)- Node.js v16+ and npm/yarn
- Git
- Clone the repository
git clone https://github.com/topsecretagent007/RWA-Smart-Contract.git
cd RWA-Smart-Contract- Install dependencies
npm install
# or
yarn install- Set up environment variables
cp .env.example .env
# Edit .env with your valuesEdit .env file with your settings:
# Network RPC URLs
SEPOLIA_RPC_URL=https://rpc.sepolia.org
MAINNET_RPC_URL=https://eth.llamarpc.com
# Private Key (Never share!)
PRIVATE_KEY=
# API Keys
ETHERSCAN_API_KEY=npm run compilenpm run testLocal Network:
# Start local node
npm run node
# In another terminal, deploy
npm run deployTestnet (Sepolia):
npm run deploy:testnetUse the interaction script:
node scripts/interact.jsconst RWANFT = await ethers.getContractFactory("RWANFT");
const rwaNFT = await RWANFT.attach(RWA_NFT_ADDRESS);
await rwaNFT.mintAsset(
ownerAddress,
"ipfs://QmYourMetadataHash",
"Real Estate",
"123 Main St, New York, NY",
50000000, // $500,000.00 in cents
"ipfs://QmYourDocumentHash"
);const marketplace = await ethers.getContractAt("RWAMarketplace", MARKETPLACE_ADDRESS);
// Approve marketplace
await rwaNFT.approve(MARKETPLACE_ADDRESS, tokenId);
// List NFT
const listingId = await marketplace.listNFT(
RWA_NFT_ADDRESS,
tokenId,
ethers.parseEther("10") // 10 ETH
);await marketplace.buyNFT(listingId, {
value: ethers.parseEther("10")
});The project includes comprehensive test suites:
-
RWANFT.test.js - Tests for NFT contract
- Deployment
- Minting (single and batch)
- Verification
- Royalty system
- Token management
- Pause functionality
-
RWAMarketplace.test.js - Tests for marketplace
- NFT listing and buying
- Auction creation and bidding
- Payment distribution
- Admin functions
Run tests with coverage:
npm run test
npx hardhat coverageApproximate gas costs (can vary based on network conditions):
| Function | Gas Cost |
|---|---|
| Mint Asset | ~250,000 |
| Batch Mint (3 assets) | ~650,000 |
| Verify Asset | ~50,000 |
| List NFT | ~120,000 |
| Buy NFT | ~180,000 |
| Create Auction | ~140,000 |
| Place Bid | ~100,000 |
- β ReentrancyGuard: Protection against reentrancy attacks
- β Access Control: Role-based permissions
- β Pausable: Emergency stop mechanism
- β SafeERC721: Safe transfer mechanisms
- β OpenZeppelin: Battle-tested contract libraries
- β Input Validation: Comprehensive checks on all inputs
- Ethereum Mainnet
- Ethereum Sepolia (Testnet)
- Polygon
- Binance Smart Chain
- Any EVM-compatible chain
- DEFAULT_ADMIN_ROLE: Full contract control
- MINTER_ROLE: Can mint new RWA NFTs
- VERIFIER_ROLE: Can verify assets and update metadata
- PAUSER_ROLE: Can pause/unpause contract
RWANFT Events:
AssetMinted(uint256 tokenId, address owner, string assetType, uint256 valuationUSD)AssetVerified(uint256 tokenId, address verifier, uint256 timestamp)AssetMetadataUpdated(uint256 tokenId, uint256 newValuation, string documentHash)RoyaltyUpdated(address newReceiver, uint96 newBasisPoints)
Marketplace Events:
NFTListed(uint256 listingId, address nftContract, uint256 tokenId, address seller, uint256 price)NFTSold(...)AuctionCreated(...)BidPlaced(...)AuctionEnded(...)
RWA-Smart-Contract/
βββ contracts/ # Smart contracts
β βββ RWANFT.sol
β βββ RWAMarketplace.sol
βββ scripts/ # Deployment scripts
β βββ deploy.js
β βββ interact.js
βββ test/ # Test files
β βββ RWANFT.test.js
β βββ RWAMarketplace.test.js
βββ hardhat.config.js # Hardhat configuration
βββ package.json
βββ README.md
- Write tests first (TDD approach)
- Implement the feature
- Run tests:
npm test - Check gas usage:
REPORT_GAS=true npm test - Deploy to testnet
- Verify and test on testnet
- Write comprehensive tests
- Follow Solidity style guide
- Add documentation for new features
- Ensure all tests pass
- Update README if needed
- Maximum batch mint size is limited to 50 to prevent gas issues
- Auction minimum duration is 1 hour
- Platform fees capped at 10%
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenZeppelin for secure contract libraries
- Hardhat for development environment
- The Ethereum community
Developer: topsecretagent_007
- π± Telegram: @topsecretagent_007
- π GitHub: topsecretagent007