Last active
May 12, 2021 21:06
-
-
Save TheBojda/9fb22e3ecc8258b1f77b2846ee37ced6 to your computer and use it in GitHub Desktop.
Minimalistic NFT Ethereum contract in Solidity
This file contains 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: Apache-2.0 | |
pragma solidity ^0.8.4; | |
contract NFTToken { | |
event Mint(address indexed _to, uint256 indexed _tokenId, bytes32 _ipfsHash); | |
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); | |
uint256 tokenCounter = 1; | |
mapping(uint256 => address) internal idToOwner; | |
function mint(address _to, bytes32 _ipfsHash) public { | |
uint256 _tokenId = tokenCounter; | |
idToOwner[_tokenId] = _to; | |
tokenCounter++; | |
emit Mint(_to, _tokenId, _ipfsHash); | |
} | |
function transfer(address _to, uint256 _tokenId) public { | |
require(msg.sender == idToOwner[_tokenId]); | |
idToOwner[_tokenId] = _to; | |
emit Transfer(msg.sender, _to, _tokenId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment