Skip to content

Solana / Rust / Anchor - NFT Marketplace Event Ticketing

License

Notifications You must be signed in to change notification settings

s-damian/anchor-nft-ticketing

Repository files navigation

NFT Ticketing in Rust / Solana / Anchor

Rust Logo Solana Logo Anchor Logo

#Rust πŸ¦€ #Solana πŸ’  #Anchor βš“ #React βš›οΈ #NFT πŸ–ΌοΈ #Web3 🌐

NFT Marketplace Event Ticketing on the Solana Blockchain

Tests Static Analysis License

This NFT Solana Project is developed by Stephen Damian

Note: I developed the same project with Ethereum / Hardhat

Summary

Project Overview

NFT Marketplace Event Ticketing - A decentralized application for managing and verifying event tickets as NFTs on the Solana blockchain.

Status: Under development 🚧

Img

See more images here: Images

Roadmap

  • βœ… Phantom integration.
  • βœ… Homepage.
  • βœ… Create event.
  • βœ… Event listing.
  • βœ… Buy a ticket.
  • βœ… Generate NFTs.
  • βœ… Verify NFTs.
  • ⬜ Integrate other wallets.
  • ⬜ Event organizer dashboard.

Prerequisites

  • Rust >= 1.75.0 (last tested: 1.83.0) - You can install Rust here: Rustup.
  • Solana >= 1.18.14 (last tested: 1.18.26) - You can install Solana CLI here: Solana CLI.
  • Anchor 0.30.1 - You can install Anchor here: Anchor.
  • Node.js >= 18 (last tested: 22) and npm - You can install Node.js and npm here: Node.js.

Technologies

  • Back-End: Rust, Solana, Anchor 0.30.1
  • Front-End: Next.js 14, React 18, TypeScript 5, Tailwind CSS
  • Blockchain Interaction: Solana-Web3.js
  • Wallet Integration: Phantom

Getting Started (Localnet)

Setup Solana Locally

Configure your Solana CLI to use your localhost validator:

solana config set --url localhost

Clone the Repository

git clone https://github.com/s-damian/anchor-nft-ticketing.git

Go to the Anchor Directory

cd /<your-path>/anchor-nft-ticketing

Install Dependencies

For the Anchor Program:

npm install

For the Next.js App:

npm install --prefix ./app/frontend

Update Anchor Configuration

  • In [provider] section, update to:
[provider]
cluster = "localnet"

Environment Setup

Create a ./app/frontend/.env file (for the Next.js App):

cp ./app/frontend/.env.example ./app/frontend/.env

Make Scripts Executable

Ensure that the shell scripts are executable:

chmod +x sh/*.sh

Run Solana Local Validator

Start the Solana local validator (solana-test-validator) with Metaplex:

npm run ledger

Fund Your Wallet

After starting the Solana local validator, you will probably need to airdrop SOL to your Localnet wallet:

solana airdrop <amount>

Build and Deploy the Anchor Program

Build:

anchor build

Deploy:

anchor deploy

PS: anchor deploy will create your target/idl/nft_ticketing.json file.

Update Program ID

Automatically update the Program ID in the necessary files:

npm run update-program-id

Rebuild and Redeploy the Anchor Program

anchor build && anchor deploy

This step is crucial after updating the Program ID to ensure that the deployed program matches the updated configuration.

IDL Setup

Copy the IDL (Interface Definition Language) file into the Next.js App:

npm run copy-idl

Phantom Wallet

In your Phantom wallet settings, switch to Solana Localnet.

Run Front-End (Next.js App)

Go to the Next.js App Directory:

cd /<your-path>/anchor-nft-ticketing/app/frontend

Start the development server:

npm run dev

Open your browser and go to:

http://localhost:3000

Transition: Localnet to Devnet

Preparing for Public Deployment: Transition from Localnet to Devnet

After successfully running your project locally, the next step is to deploy it on the public Devnet. This section guides you through the process of configuring your environment, deploying your program to Devnet, and updating your Front-End to interact with the deployed program on the Devnet.

To switch from the Localnet to Devnet: Localnet-to-Devnet.md

Code Structure

.
β”œβ”€β”€ app
β”‚   └── frontend
β”‚       β”œβ”€β”€ app
β”‚       β”‚   └── [React pages]
β”‚       β”œβ”€β”€ src
β”‚       β”‚   β”œβ”€β”€ components
β”‚       β”‚   β”‚   └── [React components]
β”‚       β”‚   β”œβ”€β”€ handlers
β”‚       β”‚   β”‚   └── [React handlers]
β”‚       β”‚   β”œβ”€β”€ idl
β”‚       β”‚   β”‚   └── nft_ticketing.json.
β”‚       β”‚   └── utils
β”‚       β”‚       └── [React utils]
β”‚       β”œβ”€β”€ .env
β”‚       β”œβ”€β”€ config-overrides.js
β”‚       β”œβ”€β”€ package.json
β”‚       └── tailwind.config.ts
β”œβ”€β”€ programs
β”‚   └── nft-ticketing
β”‚       β”œβ”€β”€ src
β”‚       β”‚   β”œβ”€β”€ kernel
β”‚       β”‚   β”‚   └── [Program managers]
β”‚       β”‚   └── lib.rs
β”‚       └── Cargo.toml
β”œβ”€β”€ tests
β”‚   └── [Tests]
β”œβ”€β”€ Anchor.toml
β”œβ”€β”€ Cargo.toml
β”œβ”€β”€ package.json
└── README.md

Various Documentations

License

This project is licensed under the MIT License. See the LICENSE file for more details.