Created
January 25, 2022 01:51
-
-
Save z0r0z/1ce96691ee2abfb1f42bd96d80e8a648 to your computer and use it in GitHub Desktop.
mint an NFT based on admin rights
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: GPL-3.0-or-later | |
| pragma solidity >=0.8.4; | |
| import "https://github.com/Rari-Capital/solmate/src/tokens/ERC721.sol"; | |
| interface IOwnable { | |
| function owner() external view returns (address); | |
| } | |
| error NotOwner(); | |
| contract OwnerNFT is ERC721("OwnerNFT", "ONFT") { | |
| uint256 public totalSupply; | |
| string public baseURI; | |
| constructor(string memory baseURI_) { | |
| baseURI = baseURI_; | |
| } | |
| function mint(IOwnable target) public virtual { | |
| if (msg.sender != target.owner()) revert NotOwner(); | |
| _safeMint(msg.sender, totalSupply++); | |
| } | |
| function tokenURI(uint256) public view override virtual returns (string memory) { | |
| return baseURI; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment