Skip to content

Commit fe6ab6e

Browse files
the property token is completed
1 parent 92e4dee commit fe6ab6e

4 files changed

Lines changed: 43 additions & 0 deletions

File tree

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
[submodule "lib/forge-std"]
22
path = lib/forge-std
33
url = https://github.com/foundry-rs/forge-std
4+
[submodule "lib/openzeppelin-contracts"]
5+
path = lib/openzeppelin-contracts
6+
url = https://github.com/OpenZeppelin/openzeppelin-contracts
7+
[submodule "lib/chainlink"]
8+
path = lib/chainlink
9+
url = https://github.com/smartcontractkit/chainlink

lib/chainlink

Submodule chainlink added at 5d5d024

lib/openzeppelin-contracts

Submodule openzeppelin-contracts added at 78eb160

src/PropertyToken.sol

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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

Comments
 (0)