- 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).
- Deploy and test on GitHub Codespaces (recommended)
-
To deploy and test locally, you will need the following technologies:
-
install Docker
-
On your Local Host and follow the link provided below
NOTE: You will need to wait for the container to install all dependencies and start dfx
,
- 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.
-
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 theadd 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 newticket class
for the event, andpublish
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 yourMy Tickets
modal.
- 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")'