Git Product home page Git Product logo

ticketing-system's Introduction

Ticketing System with Factory

This project implements an upgradeable (UUPS Proxy pattern) Event Factory smart contract, which is responsible for creating Event smart contracts for ERC1155 ticket sales.

The development tool used is the Foundry where the contracts and the tests are written, and then there's hardhat integrated which is used for writing the deployment and upgrade scripts.

Table of Contents

Features

EventFactory Contract

  • createEvent - Users can create the Event smart contract by calling this function and passing in the data about the tickets. This data should include the different types of tickets that there will be with their id, cost, and the maximum supply. The ownership of this smart contract is then transferred to the caller of the transaction and the EventCreated event is fired.

  • version - Returns the version of the Factory contract as it's upgradeable.

Event Contract

  • buyTickets - By calling this function, users can buy ticket(s) for that specific event. The exact ether value should be sent with this transaction for it to succeed, if it is sent more, the transaction will revert. If the maximum amount of ticket amount has been reached, users won't be able to call this function. The owner of the event contract can also pause the ticket sales which will make it impossible for users to call this function.

  • buyTicketsBatch - If users want to buy different types of tickets, they should call this function, if even one of the ticket number limits is reached, the whole transaction will revert. It's also important that the user should be sent the exact amount of ether for all the tickets combined for this transaction to succeed.

  • remainingTickets - Returns the remaining amount of a specific ticket.

  • soldTickets - Returns the sold amount of a specific ticket.

  • endSales - Owners function to stop ticket sales. IMPORTANT: If the sales are stopped, users are still able to transfer tickets to other addresses.

  • continueSales - Owners function to continue ticket sales.

  • version - Returns the version of the contract.

  • withdrawFunds - Transfers all the contract funds to the owner.

Testing

Tests are written to cover as many scenarios as possible, but still, it's not enough for production. This should never happen in production-ready code!

To run the tests, you will have to do the following

IMPORTANT: Make sure you run tests on a Mainnet fork because some test cases include Mainnet token addresses!

  1. Clone this repository to your local machine.
  2. Run forge install.
  3. Run forge build.
  4. Run forge test --fork-url {MAINNET_RPC_URL].

OR, you can just run forge test --fork-url {MAINNET_RPC_URL], which will automatically install dependencies and compile the contracts.

Deploying

To deploy the contract, you will have to do the following

  1. Clone this repository to your local machine.
  2. Run forge install && npm install.
  3. Create the .env file based on the .env.example.
  4. Modify network options in hardhat.config.ts.
  5. Deploy the smart contract with npx hardhat run script/deploy.ts --network {network name}

If you would like to deploy it locally, make sure to run npx hardhat node before the 3rd step, and deploy the smart contract with localhost as the "network name"

ticketing-system's People

Contributors

nikakhachi avatar

Stargazers

Eugene Kadish avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.