Created
December 29, 2022 19:58
-
-
Save fassko/5e2e60ce4625f53e82c1bd7d5c379722 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=
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: Unlicense | |
pragma solidity ^0.8.0; | |
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
import "hardhat/console.sol"; | |
contract Ticket is ERC721URIStorage { | |
uint256 private tokenId; | |
event TicketCreated(uint256 tokenId, address visitor); | |
constructor( | |
string memory eventName, | |
string memory shortName | |
) ERC721(eventName, shortName) { | |
// initializes the NFT storage | |
} | |
function createTicket(address visitor, string memory tokenURI) external { | |
tokenId++; | |
// mint the NFT and assign to the visitor address | |
_mint(visitor, tokenId); | |
// set the token JSON file link that was uploaded to the IPFS | |
_setTokenURI(tokenId, tokenURI); | |
console.log(tokenId); | |
emit TicketCreated(tokenId, visitor); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment