Last active
September 24, 2021 20:37
-
-
Save nicola-attico/961e9dde5e6f1e1f7e3cc4d92aafb85e to your computer and use it in GitHub Desktop.
NFT with onchain properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Counters.sol"; | |
contract OnChainProperties { | |
mapping (uint256 => string) text; | |
} | |
contract NFT is ERC721, OnChainProperties { | |
using Counters for Counters.Counter; | |
Counters.Counter private _tokenIds; | |
constructor() ERC721("Item", "ITM") OnChainProperties() public { | |
} | |
function createItem(address tokenOwner, string memory _text) public returns (uint256) { | |
_tokenIds.increment(); | |
uint256 newItemId = _tokenIds.current(); | |
text[newItemId] = _text; | |
_mint(tokenOwner, newItemId); | |
// _setTokenURI(newItemId, tokenURI); | |
return newItemId; | |
} | |
function getProp(uint256 n) public view returns (string memory) { | |
return text[n]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment