Skip to content

Instantly share code, notes, and snippets.

@TheBojda
Last active May 12, 2021 21:06
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 TheBojda/9fb22e3ecc8258b1f77b2846ee37ced6 to your computer and use it in GitHub Desktop.
Save TheBojda/9fb22e3ecc8258b1f77b2846ee37ced6 to your computer and use it in GitHub Desktop.
Minimalistic NFT Ethereum contract in Solidity
// 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