Skip to content

Instantly share code, notes, and snippets.

@abhik-99
Created September 13, 2022 16:08
Show Gist options
  • Save abhik-99/3af5981291a88d1bf953faa8b02b8083 to your computer and use it in GitHub Desktop.
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=
// 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);
}
}
@abhik-99
Copy link
Author

Soul Bound Tokens
Above is an implementation of Early stage SBT created by modifying ERC721.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment