Skip to content

Commit

Permalink
updated soulbound contract to support revoke token
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperBatata committed Oct 8, 2023
1 parent eff815b commit cc3bf0e
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/main/solidity/soulbound.sol
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract SoulBoundTest is ERC721, ERC721URIStorage, Ownable {
using Counters for Counters.Counter;
contract waltidSoulBound is ERC721,ERC721URIStorage , Ownable{

using Counters for Counters.Counter;
Counters.Counter private _tokenIdCounter;

constructor() ERC721("SoulBoundTest", "SBT") {}
constructor() ERC721("WaltidSBT","SBT") {}

function safeMint(address to , string memory uri) public onlyOwner {

function safeMint(address to, string memory uri) public onlyOwner {
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(to, tokenId);
_setTokenURI(tokenId, uri);
}

function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal override virtual {
require(from == address(0), "Err: token transfer is BLOCKED");
super._beforeTokenTransfer(from, to, tokenId);
}

// The following functions are overrides required by Solidity.

function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) {
super._burn(tokenId);
}

function unequip(uint256 tokenId) external {
require(ownerOf(tokenId) == msg.sender , "You are not the owner of this NFT");
_burn(tokenId);
}

function revoke(uint256 tokenId) external onlyOwner{
_burn(tokenId);
}

function tokenURI(uint256 tokenId)
public
view
Expand All @@ -43,4 +44,10 @@ contract SoulBoundTest is ERC721, ERC721URIStorage, Ownable {
{
return super.tokenURI(tokenId);
}

function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override virtual {
require(from == address(0) || to == address(0), "Err: token transfer is BLOCKED");
super._beforeTokenTransfer(from, to, tokenId);
}

}

0 comments on commit cc3bf0e

Please sign in to comment.