Skip to content

Instantly share code, notes, and snippets.

@critesjosh
Last active September 27, 2019 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save critesjosh/f3a03f0bbfa8c11b8d59e9e82df513c7 to your computer and use it in GitHub Desktop.
Save critesjosh/f3a03f0bbfa8c11b8d59e9e82df513c7 to your computer and use it in GitHub Desktop.
This contract describes a non-transferable ERC 721 token with an update-able token URI data
pragma solidity ^0.5.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721MetadataMintable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721Enumerable.sol";
contract Cert721 is ERC721MetadataMintable, ERC721Enumerable {
constructor (string memory name, string memory symbol)
public
ERC721Metadata(name, symbol)
{
// solhint-disable-previous-line no-empty-blocks
}
function transferFrom(address from, address to, uint256 tokenId) public {
revert("This token is non-tranferrable");
}
function safeTransferFrom(address from, address to, uint256 tokenId) public {
revert("This token is non-tranferrable");
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public {
revert("This token is non-tranferrable");
}
function mintNextTokenWithTokenURI(address to, string memory tokenURI) public onlyMinter returns (bool) {
uint256 tokenId = _getNextTokenId();
_mint(to, tokenId);
_setTokenURI(tokenId, tokenURI);
return true;
}
function _getNextTokenId() private view returns (uint256) {
return totalSupply().add(1);
}
function updateTokenURI(uint256 tokenId, string memory tokenURI) onlyMinter public returns (bool) {
_setTokenURI(tokenId, tokenURI);
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment