1+ // SPDX-License-Identifier: MIT
2+ pragma solidity ^ 0.8.20 ;
3+
4+ import "@openzeppelin/contracts/token/ERC721/ERC721.sol " ;
5+ import "@openzeppelin/contracts/access/Ownable.sol " ;
6+
7+ contract PropertyToken is ERC721 , Ownable {
8+ uint256 public tokenCounter;
9+ mapping (uint256 => string ) public propertyMetadata; // IPFS hash for metadata
10+
11+ constructor () ERC721 ("BlockEstate " , "BEST " ) Ownable (msg .sender ) {
12+ tokenCounter = 0 ;
13+ }
14+
15+ // Mint a new property NFT
16+ function mintProperty (address owner , string memory ipfsHash ) public onlyOwner returns (uint256 ) {
17+ uint256 newTokenId = tokenCounter;
18+ _safeMint (owner, newTokenId);
19+ propertyMetadata[newTokenId] = ipfsHash;
20+ tokenCounter++ ;
21+ return newTokenId;
22+ }
23+
24+ // Get metadata for a property
25+ function getPropertyMetadata (uint256 tokenId ) public view returns (string memory ) {
26+ require (_exists (tokenId), "Token does not exist " );
27+ return propertyMetadata[tokenId];
28+ }
29+
30+ // Update metadata (e.g., for document updates)
31+ function updateMetadata (uint256 tokenId , string memory newIpfsHash ) public onlyOwner {
32+ require (_exists (tokenId), "Token does not exist " );
33+ propertyMetadata[tokenId] = newIpfsHash;
34+ }
35+ }
0 commit comments