Last active
April 29, 2022 21:31
-
-
Save z0r0z/884f6d3c5f90826ecaa546fc6a2f8239 to your computer and use it in GitHub Desktop.
NFT restricted access
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.4; | |
import 'https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol'; | |
contract Ownable { | |
address public owner; | |
modifier onlyOwner { | |
require(msg.sender == owner, "NOT_OWNER"); | |
_; | |
} | |
constructor() { | |
owner = msg.sender; | |
} | |
function transferOwnership(address newOwner) public onlyOwner { | |
owner = newOwner; | |
} | |
} | |
contract AccessToken is ERC721("ACCESS", "ACS"), Ownable { | |
modifier HasAccessToken { | |
require(balanceOf[msg.sender] > 0, "NOT_HOLDER"); | |
_; | |
} | |
function mint(address to, uint256 id) public onlyOwner { | |
_mint(to, id); | |
} | |
function tokenURI(uint256) public override pure returns (string memory) { | |
return "PLACEHOLDER"; | |
} | |
} | |
/// @notice This is an NFT restricted contract. | |
contract TokenRestrictedThing is AccessToken { | |
uint256 public counter = 1; | |
function doThing() public HasAccessToken { | |
counter++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment