Created
September 13, 2022 16:08
-
-
Save abhik-99/3af5981291a88d1bf953faa8b02b8083 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
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 "@openzeppelin/[email protected]/token/ERC721/extensions/ERC721Enumerable.sol"; | |
import "@openzeppelin/[email protected]/access/Ownable.sol"; | |
import "@openzeppelin/[email protected]/utils/Counters.sol"; | |
contract OurSBT is ERC721Enumerable, Ownable { | |
using Counters for Counters.Counter; | |
Counters.Counter private _tokenIdCounter; | |
constructor() ERC721("OurSBT", "OST") {} | |
function safeMint(address to) public payable onlyOwner { | |
require(balanceOf(to) == 0, "Already Minted to Address!"); | |
uint256 tokenId = _tokenIdCounter.current(); | |
_tokenIdCounter.increment(); | |
_safeMint(to, tokenId); | |
} | |
// The following functions are overrides required by Solidity. | |
function _beforeTokenTransfer(address from, address to, uint256 tokenId) | |
internal | |
override | |
{ | |
super._beforeTokenTransfer(from, to, tokenId); | |
require(from == address(0), "Not Allowed"); | |
} | |
function supportsInterface(bytes4 interfaceId) | |
public | |
view | |
override | |
returns (bool) | |
{ | |
return super.supportsInterface(interfaceId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Soul Bound Tokens
Above is an implementation of Early stage SBT created by modifying ERC721.