Code Monkey home page Code Monkey logo

events-and-ticket-management's Introduction

Events and Ticket Management

  • Events and ticket management is a platform with a canister written in TypeScript, libraries from the Azle framework CDK (Canister Development Kit), and a bundled react.js front-end. Having implemented functionalities and modules that interact with corresponding front-end and canister utilities to manage events and ticket purchases. Ideally developed to run on the ICP (Internet Computer Protocol).

Instructions on Deploying and Testing Canisters

  • Deploy and test on GitHub Codespaces (recommended)

Test On GitHub Codespaces

  • To deploy and test locally, you will need the following technologies:

  • install Docker

  • VS Code

  • On your Local Host and follow the link provided below

Test locally in Dev Containers

NOTE: You will need to wait for the container to install all dependencies and start dfx,

Deploying Canisters

  • Deploy the ledger canister, an icp test token canister for dev environments.
bash deploy-local-ledger.sh
  • Deploy the internet identity, a canister for authenticating and assigning identities to users in a dev environment accessing the canister front-end
bash dfx deploy internet_identity
  • Deploy the Event manager front and back ends, i.e the canister for creating and maintainig events and tickets.
bash dfx deploy event_manager_js_backend
bash dfx generate event_manager_js_backend
bash dfx deploy event_manager_js_frontend

NOTE: After deploying all canisters, run python3 canister_urls.py and follow the links provided.

Testing the Event Manager via the Front-end

  • Follow the link to the front-end provided from running the previous command, click on the connect button you will be redirected to the internet identity canister, create a new identity following the provided instructions.

  • After creating an identity you will be redirected to the event manager where you will see a button managed events, click on the button to open the modal, below the modal is the add event component used to create events, and create an event. On the newly created event before the footer will be buttons to manage the event, create a new ticket class for the event, and publish the event. Close the modal and log out with the logout button provided on the drop-down from the balance icon.

  • Now connect again but create a new identity to simulate an event attendee. After being redirected to the event manager copy the current Principal from the drop-down of the balance icon.

  • Now go back to the terminal and run the following commands to get an account-id and mints ICP's to the attendee's account.

dfx ledger account-id --of-principal <COPIED PRINCIPAL>
  • The above command returns the account-id to the provided principle, copy that down it will be needed for the icp minting.

  • Mint ICPs to the returned Account-id

dfx ledger --network local transfer --amount 100 --fee 0 --memo <nat64> <ACCOUNT-ID>
  • Return to the app and refresh the page to update the balance. There should be an available published event in the events list, on the event there will be a button Purchase Event Tickets to pop open a modal with available tickets and purchase one. After purchase the ticket will be available in your My Tickets modal.

Test Canister via DFX

  • Create a new identity for a manager
$ dfx identity new [OPTIONS] <IDENTITY>
  • Select the identity
$ dfx identity use [OPTIONS] <IDENTITY>
  • Add an event
$ dfx canister call be2us-64aaa-aaaaa-qaabq-cai addEvent '( record { 'title'= "event title"; 'description' = "event description"; 'eventLocation' = "event location"; 'bannerUrl' = "banner url"; 'eventStart' = 'date-timestamp-microseconds'; 'eventEnd' = 'date-timestamp-microseconds'; })'
  • Update an event
$ dfx canister call be2us-64aaa-aaaaa-qaabq-cai updateEvent '( record { 'title'= "event title"; 'description' = "event description"; 'eventLocation' = "event location"; 'bannerUrl' = "banner url"; 'eventStart' = 'date-timestamp-microseconds'; 'eventEnd' = 'date-timestamp-microseconds'; }, 'eventId' )'
  • Get Managed Events
$ dfx canister call be2us-64aaa-aaaaa-qaabq-cai getEventsByManagment '()'
  • Add a Ticket Class
$ dfx canister call be2us-64aaa-aaaaa-qaabq-cai addTicketClass '( record { 'title'= "ticketclass title"; 'cost' = "nat64 in  e8s"; 'badgeUrl' = "badge url"; }, 'eventId' )'
  • Update a Ticket Class
$ dfx canister call be2us-64aaa-aaaaa-qaabq-cai updateTicketClass '( record { 'title'= "ticketclass title"; 'cost' = "nat64 in  e8s"; 'badgeUrl' = "badge url"; }, 'eventId', ticketclassId)'
  • Publish an Event
$ dfx canister call be2us-64aaa-aaaaa-qaabq-cai publishEvent '('eventId')'
  • Create a new identity for an Attendee
$ dfx identity new [OPTIONS] <IDENTITY>
  • Select the identity
$ dfx identity use [OPTIONS] <IDENTITY>
  • Get newly created identity Principal
dfx identity get-principal --identity <IDENTITY>
  • Get Account-ID to Principal
dfx ledger account-id --of-principal <PRINCIPAL>
  • Now switch to the minter's identity with the command below and mint icp's to the attendee
$ dfx identity use minter
dfx ledger --network local transfer --amount 100 --fee 0 --memo <nat64> <ATTENDEE ACCOUNT-ID>
  • Now switch to the attendee's identity with the command below to purchase a ticket
$ dfx identity use <ATTENDEE IDENTITY>
  • First, get the Manager account-id for ICP transfer.
dfx ledger account-id --of-principal <MANAGERS PRINCIPAL>
  • Get All Events
$ dfx canister call be2us-64aaa-aaaaa-qaabq-cai getAllEvents '()'
  • Transfer Ticket cost to the Event Manager
dfx ledger --network local transfer --amount <cost/10**8: nat64> --fee 0 --memo <nat64> <EVENT MANAGER ACCOUNT-ID>
  • the above command will return a block number, you will need that to get the purchased ticket

  • Buy A ticket

$ dfx canister call be2us-64aaa-aaaaa-qaabq-cai makePayment '('eventId', 'ticketclassId')'
  • Returns a payment object you will need the memo in the object for the next call. the PAYMENT_RESERVATION_PERIOD is 3 mins enough to complete the transaction.

  • Complete Payment And get a Ticket with acquired information.

  • Get the manager's Principal

dfx identity get-principal --identity <MANAGERS IDENTITY>
$ dfx canister call be2us-64aaa-aaaaa-qaabq-cai getTicket '('Managers Principal', 'Ticket Cost <nat64>', 'Payment Block Number', 'memo')'
  • Delete an Event, should be called by the Event creator
$ dfx canister call be2us-64aaa-aaaaa-qaabq-cai deleteEvent '("eventId")'
  • Delete a TicketClass, which should be called by the TicketClass creator
$ dfx canister call be2us-64aaa-aaaaa-qaabq-cai deleteTicketClass '("eventId", "ticketclassId")'
  • Delete a Ticket, should be called by the owner of the Ticket
$ dfx canister call be2us-64aaa-aaaaa-qaabq-cai deleteTicket '("ticketId")'

events-and-ticket-management's People

Contributors

lukrycyfa avatar coolestnick 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.