Created
January 20, 2024 17:39
-
-
Save max-clinch/3371351e140e73efb1138bf53efa8598 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.0; | |
| import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
| import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; | |
| import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
| import "@openzeppelin/contracts/utils/Counters.sol"; | |
| contract NovaNexHub is ERC721Enumerable{ | |
| using Counters for Counters.Counter; | |
| Counters.Counter private _tokenIds; | |
| address public marketplace; | |
| struct Item { | |
| uint256 id; | |
| address creator; | |
| string uri;//metadata url | |
| } | |
| mapping(uint256 => Item) public Items; //id => Item | |
| constructor () ERC721("NovaNexHub", "NNH") {} | |
| function mint(string memory uri) public returns (uint256){ | |
| _tokenIds.increment(); | |
| uint256 newItemId = _tokenIds.current(); | |
| _safeMint(msg.sender, newItemId); | |
| approve(marketplace, newItemId); | |
| Items[newItemId] = Item({ | |
| id: newItemId, | |
| creator: msg.sender, | |
| uri: uri | |
| }); | |
| return newItemId; | |
| } | |
| function tokenURI(uint256 tokenId) public view override returns (string memory) { | |
| return Items[tokenId].uri; | |
| } | |
| function setMarketplace(address market) public { | |
| //require(msg.sender ==); | |
| marketplace = market; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment