CTC Pay

Technical Overview

architecture diagram

As can be seen from the demo chart , we have the application running on Ethereum , which uses the Chainlink ETH / USD Price Feed . We will use the Price Feed to convert the concert ticket price into Ether ( ETH ) . After the concert organizer releases the concert information , the computer terminal displays the address of the concert , the time , the viewing area and the converted ticket price . When the user buys the ticket , he pays with Ether ( ETH ) according to the wallet address . After the payment is successful , the system will generate NFT pattern and send it to the user ' s mobile phone and send the ticket to the delivery address filled in by the user . The user uses the NFT and ticket to get in to the concert . The project makes concert ticket prices transparent and avoids the phenomenon of inflated ticket prices caused by scalpers controlling the majority of ticket sources .

Diving Into the Smart Contract

Here you can see how to run the application locally, we created a contract called "ConcertTicket" which inherits the ERC721URIStoragecontract with the contract administrator set up. In addition, we introduce the vrfv2Consumer.sol contract and create a VRFv2Consumercontract instance. Define a structure called Concert to store concert information, including the concert ID, ticket price, owner's wallet address, and total price sold, etc. Using a mapping relationship, map each concert ID to a concert structure and each ticket ID (the TokenID of the NFT) to a concert ID to make buying tickets easy.

smart contract 1

Constructor to name the NFT as Concert Ticket. Connect to the sepoila test network using chainlink's feed price service.

smart contract 2

The initial ticket information includes the ticket price, the concert ID, and the owner's wallet address. Return the ticket price to show the latest ETH price. The -mintTicket function is implemented for purchasing tickets and minting NFT (ERC721).This process requires the incoming concert ID, ticket 1D and base URI, and the user pays Ether equivalent to the ticket price and adds the purchase amount to the total amount of the concert.

smart contract 3

Test the ticket payment function

First, click "show" to go to the app.

home page

On the screen, concerts of different performances appear, and each concert information contains the time, stand location, location, and ether (ETH) price.

concert info

Click the "Buy now" button to select the ticket. which will be linked to MetaMask for Ether purchase. If the wallet balance is sufficient, the purchase is successful, and the generated NFT will be sent to the user's mobile phone for use during admission.

Successfully purchased concert tickets

If the wallet balance is insufficient, the purchase cannot be made.

insufficient wallet balance, purchase failed

Check NFT Picture

Users can log in to the system through their wallets to view the balance of Ethereum and NFT pictures cast after successful ticket purchase.

Check NFT after logging in  through wallet

NFT Picture

What’s Next for Concert tickets paid in cryptocurrency

Add concert sweepstakes. For the realization of the raffle function, it is realized by writing a function. It involves writing smart contracts to generate random numbers, we need to pass in the concert ID, the total number of people participating in the draw and the URI of the winning picture. The contract calculates the winner based on the random number and sets the URI of the corresponding ticket to the URI of the winning picture. Users can check whether they have won the lottery on their mobile phones. This feature adds to the audience interaction at concerts, making them more dynamic and full of uncertainty.

Built With

Share this project:

Updates