Skip to content

Instantly share code, notes, and snippets.

@z0r0z
Created January 25, 2022 01:51
Show Gist options
  • Select an option

  • Save z0r0z/1ce96691ee2abfb1f42bd96d80e8a648 to your computer and use it in GitHub Desktop.

Select an option

Save z0r0z/1ce96691ee2abfb1f42bd96d80e8a648 to your computer and use it in GitHub Desktop.
mint an NFT based on admin rights
// 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