Reputation: 419
I'm not having so much experience with ERC721 token standard, currently I'm working on a real-estate DAPP. I have a question. if I want to add external information related to a specific property like Location, Price, property number etc. every time if a new property register, what will be the best way to do that..?? but I don't want this with solidity Struct, is it possible to extend the ERC721 Metadata Interface Contract
?? or any other solution??
I have tried almost everything but I think I'm missing something.
Upvotes: 2
Views: 1590
Reputation: 21
Please see this post where I finally found a solution. It includes a sample implementation for both ERC20 and ERC721, forked from an implementation of Kaleido's Firefly and amended to cater for the mentioned Real Estate dApp. Hope it helps someone.
Upvotes: 0
Reputation: 43491
If you want to store the data on-chain, a mapping (uint256 => Property)
, where the uint256
is the token ID and Property
is "struct(location, price, ...)", containing the data is probably the cheapest option gas-wise.
But since your question states you don't want to use struct, you can chose to store the data on-chain with a series of mappings:
mapping (uint256 => string) tokenIdToLocation;
mapping (uint256 => uint64) tokenIdToUsdPrice;
// etc.
You can also decide to store the data off-chain, and link to this storage from your contract. In that case, you'd implement the tokenURI()
function of the ERC721Metadata
interface (both defined in the ERC-721 standard). The tokenUri()
would return a (string) URL of an off-chain resource where you can display the (off-chain) data.
Upvotes: 6