Skip to content

Instantly share code, notes, and snippets.

Created December 29, 2022 19:58
What would you like to do?
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at
//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);
string memory eventName,
string memory shortName
) ERC721(eventName, shortName) {
// initializes the NFT storage
function createTicket(address visitor, string memory tokenURI) external {
// 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);
emit TicketCreated(tokenId, visitor);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment