Skip to content

Instantly share code, notes, and snippets.

@SeptiyanAndika
Created July 19, 2021 08:55
Show Gist options
  • Save SeptiyanAndika/ae282c9f69df8bd9432e892f27b5dbbd to your computer and use it in GitHub Desktop.
Save SeptiyanAndika/ae282c9f69df8bd9432e892f27b5dbbd 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.6+commit.11564f7e.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract MinimalNFT {
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