diff --git a/docs/content/developer/getting-started/independent-ticketing-system/frontend.mdx b/docs/content/developer/getting-started/independent-ticketing-system/frontend.mdx new file mode 100644 index 00000000000..549d4982873 --- /dev/null +++ b/docs/content/developer/getting-started/independent-ticketing-system/frontend.mdx @@ -0,0 +1,214 @@ +--- +title: Frontend +description: Tutorial for Independent Ticketing System frontend +--- + +# Independent Ticketing System Frontend + +In the previous part of this tutorial, you built the [package contract](package.mdx) for the Independent ticketing system. Now, you can create the UI. To create the frontend dApp, we use [IOTA dApp kit](../../../ts-sdk/dapp-kit/). Apart from the dApp kit, we will also use an external package for client-side routing, which is react-router-dom. + +### Set Up the Frontend dApp + +First, create an initial react app using the following command: + +```npm2yarn +pnpm create @iota/create-dapp +``` + +### Set Up Network Configuration + +Add the following variables in the [`networkConfig.ts`](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/networkConfig.ts) file: + +```javascript reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/Frontend/src/networkConfig.ts#L1-L27 +``` + +You should retrieve the shared objects from the transaction digest of the published [package](package.mdx). + +:::note + +To mint a ticket from the UI, ensure that the IOTA wallet account is added to the IOTA CLI. This should be mentioned in the Simple Token Transfer tutorial. + +::: + +### Folder Structure +- [src](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src) + * [Components](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components) + * [molecules](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/molecules) + * [Button.tsx](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/molecules/Button.tsx) + * [CopyToClipboard.tsx](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/molecules/CopyToClipboard.tsx) + * [Loading.tsx](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/molecules/Loading.tsx) + * [LoadingBar.tsx](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/molecules/LoadingBar.tsx) + * [AvailableTickets.tsx](#availableticketstsx) + * [BurnTickets.tsx](#burnticketstsx) + * [Form.tsx](#formtsx) + * [Home.tsx](#hometsx) + * [Mint.tsx](#minttsx) + * [NftForm.tsx](#nftformtsx) + * [Ownedtickets.tsx](#ownedticketstsx) + * [ResellTickets.tsx](#resellticketstsx) + * [TransferTickets.tsx](#transferticketstsx) + * [hooks](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/hooks) + * [useCreateForm.ts](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/hooks/useCreateForm.ts) + * [utils](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/utils) + * [burn.ts](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/utils/Burn.ts) + * [buyResell.ts](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/utils/buyResell.ts) + * [enableTicketToBuy.ts](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/utils/enableTicketToBuy.ts) + * [mint.ts](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/utils/Mint.ts) + * [parseAddress.ts](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/utils/ParseAddress.ts) + * [resell.ts](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/utils/resell.ts) + * [submitForm.ts](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/utils/submitForm.ts) + * [submitNftForm.ts](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/utils/submitNftForm.ts) + * [transfer.ts](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/utils/Transfer.ts) + * [whilteListBuyer.ts](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/utils/whiteListBuyer.ts) + * [App.tsx](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/App.tsx) + * [constant.tsx](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/constant.tsx) + * [main.tsx](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/main.tsx) + +### [`App.tsx`](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/App.tsx) + +This component serves as the entry point, containing the navbar and the `outlet` component for client-side routing. + +```javascript reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/Frontend/src/App.tsx +``` + +### [`AvailableTickets.tsx`](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/molecules/AvailableTickets.tsx) + +The `AvailableTickets.tsx` component displays all NFT tickets available for purchase, including newly minted tickets and tickets listed for resale. + +```javascript reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/Frontend/src/components/AvailableTickets.tsx +``` + +### [`BurnTickets.tsx`](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/molecules/BurnTickets.tsx) + +The `BurnTickets.tsx` component handles the burning of ticket nfts. It functions as a child component of [`OwnedTickets.tsx`](#ownedticketstsx) and is rendered only when a ticket listed by the `OwnedTickets.tsx` component is being burned. + +```javascript reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/Frontend/src/components/BurnTickets.tsx +``` + +### [`Form.tsx`](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/Form.tsx) + +The `Form.tsx` component is an input form used to collect inputs for all operations. It is a versatile component utilized everywhere except in the [`OwnedTickets.tsx`](#ownedticketstsx) operation. + +```javascript reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/Frontend/src/components/Form.tsx +``` + +### [`Home.tsx`](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/Home.tsx) + +The `Home.tsx` component displays buttons for all operations and a list of owned objects associated with the currently connected account. + +```javascript reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/Frontend/src/components/Home.tsx +``` + +### [`Mint.tsx`](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/Mint.tsx) + +The `Mint.tsx` component allows the creator to mint tickets and is exclusively accessible to them. + +```javascript reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/Frontend/src/components/Mint.tsx +``` + +### [`NftForm.tsx`](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/NftForm.tsx) + +The `NftForm.tsx` is an input form used specifically in the [`OwnedTickets.tsx`](#ownedticketstsx) operation. + +```javascript reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/Frontend/src/components/NftForm.tsx +``` + +### [`Ownedtickets.tsx`](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/Ownedtickets.tsx) + +The [`OwnedTickets.tsx`](#ownedticketstsx) component lists all the NFT tickets owned by the connected account. It only displays objects of the `TicketNFT` type, excluding other types. + +```javascript reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/Frontend/src/components/OwnedTickets.tsx +``` + +### [`ResellTickets.tsx`](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/ResellTickets.tsx) + +The `ResellTickets.tsx` component is used for reselling NFTs. It is only utilized when someone resells an NFT listed in the [`OwnedTickets.tsx`](#ownedticketstsx) component. + +```javascript reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/Frontend/src/components/ResellTickets.tsx +``` + +### [`TransferTickets.tsx`](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/Frontend/src/components/TransferTickets.tsx) + +The `TransferTickets.tsx` component is used to transfer the ownership of an NFT to another recipient address. Similar to the `BurnTickets.tsx` and `ResellTickets.tsx` components, this component is rendered when someone transfers an NFT from the list of NFTs in the `OwnedTickets.tsx` component. + +```javascript reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/Frontend/src/components/TransferTickets.tsx +``` + +- **Deployed Frontend Application**: [Independent Ticketing System](https://independent-ticketing-system.netlify.app/) + +## Usage Example + +### Dashboard + +![Dashboard](/img/developer/getting-started/independent-ticketing-system/dashboard.png) + +### Mint Tokens + +- Click on the mint button located at the top-right corner (ensure that the creator account is connected). + +![Mint](/img/developer/getting-started/independent-ticketing-system/mint-page.png) + +![Mint-Transaction](/img/developer/getting-started/independent-ticketing-system/mint-ticket.png) + +### Whitelist Users + +- Before making the ticket available for purchase, whitelist the users first. + +![whiteListBuyer](/img/developer/getting-started/independent-ticketing-system/whitelist-buyer-page.png) + +![whiteListBuyer-transaction](/img/developer/getting-started/independent-ticketing-system/whitelist-buyer-transaction.png) + +### Enable Ticket to Buy + +- After whitelisting users, you can add the ticket to the `AvailableTickets` object. Follow the steps below to complete this process. + +![enableTicketToBuy](/img/developer/getting-started/independent-ticketing-system/enable-ticket-to-buy.png) + +![enableTicketToBuyTransaction](/img/developer/getting-started/independent-ticketing-system/enable-ticket-transaction.png) + +### Buy Ticket + +- To buy a ticket, enter the seat number and your IOTA coin address. + +![BuyTicket](/img/developer/getting-started/independent-ticketing-system/buy-ticket.png) + +![BuyTicketTransaction](/img/developer/getting-started/independent-ticketing-system/buy-ticket-transaction.png) + +- Once the ticket is purchased, the NFT will be displayed on the dashboard as shown below: + +![otherUser](/img/developer/getting-started/independent-ticketing-system/other-user.png) + +### Resell Ticket + +- Resell a ticket by wrapping the NFT into another object (`InitiateResale`). You can either update the price of the NFT or keep the same price as before. + +![resellTicket](/img/developer/getting-started/independent-ticketing-system/resell.png) + +![resellTicketTransaction](/img/developer/getting-started/independent-ticketing-system/resell-transaction.png) + +### Transfer Ticket + +- To transfer a ticket, click on the transfer button on the dashboard page or on the transfer button of the NFT listed under owned tickets, and enter the NFT ID. + +![transfer](/img/developer/getting-started/independent-ticketing-system/transfer.png) + +![transferTransaction](/img/developer/getting-started/independent-ticketing-system/transfer-ticket.png) + +- After the transaction, the NFT will appear under the recipient's address, as shown below: + +![afterTransfer](/img/developer/getting-started/independent-ticketing-system/after-transfer.png) + +## Conclusion + +In this tutorial, we successfully built an independent ticketing system where NFT tickets are created using the IOTA Move language for the contract package. We went through the functionality of the contract step by step and demonstrated how it works within the system. Additionally, we explored the integration of the IOTA dApp kit into the frontend, providing a comprehensive guide for building a fully functional dApp. Each component was explained in detail, from minting and transferring tickets to reselling and burning them, ensuring a clear understanding of the system. By following this tutorial, you should now be well-equipped to develop and deploy your own ticketing application using IOTA's technologies, offering a secure and decentralized solution for ticket management. \ No newline at end of file diff --git a/docs/content/developer/getting-started/independent-ticketing-system/package.mdx b/docs/content/developer/getting-started/independent-ticketing-system/package.mdx new file mode 100644 index 00000000000..64ef523c8f4 --- /dev/null +++ b/docs/content/developer/getting-started/independent-ticketing-system/package.mdx @@ -0,0 +1,196 @@ +--- +title: Move Package +description: Tutorial for Independent Ticketing System Package +tags: + - explanation + - tutorial + - move-sc + - nft + - sdk + - cli +--- + +# Independent Ticketing System Package + +In this tutorial, we will build an Independent Ticketing System utilizing the Move language for blockchain contracts and the [IOTA dApp kit](../../../ts-sdk/dapp-kit) for the frontend application. The project begins with [creating a Move package](../../getting-started/create-a-package.mdx), building and deploying it on the testnet network. Once the backend contract is operational, we will develop the [frontend dApp](./frontend.mdx). + +## Sequence Diagram + +This sequence diagram illustrates the flow of interactions within a decentralised ticketing system involving the Owner, User, Blockchain, and the `IndependentTicketingSystem` contract. The process begins with the Owner deploying the contract to the Blockchain, which initializes the contract. The Owner then mints a TicketNFT, specifying event details, while the contract verifies conditions like ownership and seat availability before transferring the NFT. Next, the Owner can whitelist a User to enable ticket purchases and then activate the ticket for sale. When a User buys a ticket, the contract validates seat availability and the whitelist status, processes payment, and transfers the NFT to the buyer. For resale, the User can list the NFT at a new price, and the contract handles royalty payments, ensures the buyer is whitelisted, and updates the Blockchain accordingly. The diagram also covers NFT burning, adding users to the whitelist, and creating new ticket objects for testing purposes. Each step ensures the system maintains security, ownership, and payment flow on the Blockchain. + +```mermaid +sequenceDiagram + participant Owner as Owner + participant User as User + participant Blockchain as Blockchain + participant NFTContract as IndependentTicketingSystemNFT + + Owner ->> Blockchain: Deploy Contract + Blockchain ->> NFTContract: init() + + Owner ->> NFTContract: mint_ticket(event_id, event_date, royalty_percentage, package_creator, total_seat, price, ctx) + NFTContract ->> NFTContract: Validate sender is creator + NFTContract ->> NFTContract: Validate total seats > 0 + NFTContract ->> NFTContract: Create TicketNFT + NFTContract ->> Blockchain: Public transfer of TicketNFT + + Owner ->> NFTContract: whitelist_buyer(user,nft,ctx) + NFTContract ->> NFTContract: Add user to NFT whitelist + + Owner ->> NFTContract: enable_ticket_to_buy(nft, creator, available_tickets, ctx) + NFTContract ->> NFTContract: Validate sender is creator + NFTContract ->> NFTContract: Add NFT to available_tickets + + User ->> NFTContract: buy_ticket(coin, seat_number, buyable_tickets, ctx) + NFTContract ->> NFTContract: Validate seat availability + NFTContract ->> NFTContract: Validate buyer is whitelisted + NFTContract ->> Blockchain: Split coin for payment + NFTContract ->> Blockchain: Transfer payment to creator + NFTContract ->> Blockchain: Public transfer of TicketNFT to buyer + + User ->> NFTContract: resale(nft, updated_price, recipient, ctx) + NFTContract ->> NFTContract: Validate sender is NFT owner + NFTContract ->> NFTContract: Validate recipient is whitelisted + NFTContract ->> Blockchain: Update price and initiate resale + + User ->> NFTContract: buy_resale(coin, initiated_resale, ctx) + NFTContract ->> NFTContract: Validate sender is buyer + NFTContract ->> Blockchain: Split coin for royalty and seller payment + NFTContract ->> Blockchain: Transfer royalty fee to creator + NFTContract ->> Blockchain: Transfer payment to seller + NFTContract ->> Blockchain: Public transfer of TicketNFT to buyer + NFTContract ->> NFTContract: Delete InitiateResale object + + User ->> NFTContract: burn(nft, ctx) + NFTContract ->> NFTContract: Validate sender is NFT owner + NFTContract ->> Blockchain: Delete NFT object + + User ->> NFTContract: whitelist_buyer(user, nft) + NFTContract ->> NFTContract: Add user to NFT whitelist + + User ->> NFTContract: create_TicketNFT(name, creator, owner, ... , ctx) + NFTContract ->> NFTContract: Create a new TicketNFT (Test purpose) + + User ->> NFTContract: create_TotalSeat(value, ctx) + NFTContract ->> NFTContract: Create TotalSeat object (Test purpose) +``` +## Prerequisites + +- [Node.js](https://nodejs.org/en) >= v20.18.0 +- [npx](https://www.npmjs.com/package/npx) >= 10.8.2 +- [iota](https://github.com/iotaledger/iota/releases) >= 0.7.3 + +## Create a Move Package + +Run the following command to [create a Move package](/developer/getting-started/create-a-package): + +```bash +iota move new independent_ticketing_system && cd independent_ticketing_system +``` + +## Package Overview + +### [`init`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L64-L75) + +In Move, the [`init`](../../iota-101/move-overview/init) function only runs once at package publication. +The `init` function will create three [`shared_object`](../../iota-101/objects/object-ownership/shared.mdx) type objects: +- [`CreatorCap`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L20-L22) will use to verify the creator of the package. +- [`EventObject`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L32-L36) - it will contain the total number of seat for the event which will update as per minting the tickets and an array of all the NFT which are minted by the creator and are available to buy. To buy tickets, the first user needs to be whitelisted. + +```move reference +https://github.com/iota-community/independent-ticketing-system/blob/6c6cd27bbf402dc3e1a219a2d6e5556eb968bb59/independent_ticketing_system/sources/independent_ticketing_system.move#L71-L85 +``` + +### [`mint_ticket`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L77-L115) + +- This function allows the creator to mint NFTs to their address. +- The creator must provide the total number of seats and the creator's object ID to mint the tickets. +- Only the creator is authorized to mint these NFTs; no one else can perform this action. + +```move reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L77-L115 +``` + +### [`enable_ticket_to_buy`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L117-L123) + +- This function can only be called by the creator, as it enables the minted NFTs to be available for purchase. +- It updates the [`EventObject`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L32-L36) shared object by adding the NFT to its `available_tickets_to_buy` field array. + +```move reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L117-L123 +``` + +### [`transfer_ticket`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L125-L135) + +- This function transfers the ownership of the `nft` to the `recipient` address. +- The creator will not receive any royalty fee when this function is called. + +```move reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L125-L135 +``` + +### [`resale`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L137-L159) + +- This function makes the `nft` available for resale. +- The `recipient` address must first be whitelisted for the `nft`. +- The function creates a new object called [`InitiateResale`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L24-L30) and transfers its ownership to the `recipient` address. + +```move reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L137-L159 +``` + +### [`buy_ticket`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L161-L199) + +- This function allows the purchase of NFTs listed in the [`EventObject`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L32-L36) object. +- The buyer must first be whitelisted. +- The object ID of the [`EventObject`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L32-L36) object must be provided when calling the function. + +```move reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L161-L199 +``` + +### [`buy_resale`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L201-L221) + +- This function transfers the ownership of the NFT wrapped in the [`InitiateResale`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L24-L30) object. +- The caller's address must match the buyer address of the [`InitiateResale`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L24-L30) object. +- A royalty fee will be transferred to the creator of the NFT by the caller of this function. + +```move reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L201-L221 +``` + +### [`burn`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L223-L239) + +- This function burns the NFT, removing the NFT object from the owner's account. +- Only the NFT's owner is authorized to burn the NFT. + +```move reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L223-L239 +``` + +### [`whitelist_buyer`](https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L246-L249) + +- This function allows the owner of an NFT to whitelist a user. +- Once whitelisted, the user becomes eligible to purchase the NFT. + +```move reference +https://github.com/iota-community/independent-ticketing-system/blob/31cf42397e8dfdbfb9bd6c4e8ce07151707e76e3/independent_ticketing_system/sources/independent_ticketing_system.move#L246-L249 +``` + +See the full example of the contract on [github](https://github.com/iota-community/independent-ticketing-system/blob/main/independent_ticketing_system/sources/independent_ticketing_system.move) . + +### Write Unit Tests + +After creating the module write the test for all the functions. Move the below code to the `independent_ticketing_system_test.move` file: + +```move reference +https://github.com/iota-community/independent-ticketing-system/blob/794492c7710358da53a9c01a85011f42eaea5500/independent_ticketing_system/tests/independent_ticketing_system_test.move +``` + +### Publish the Package + +[Publish](../publish.mdx) the package to the IOTA Testnet using the following command: + +```bash +iota client publish +``` \ No newline at end of file diff --git a/docs/content/sidebars/developer.js b/docs/content/sidebars/developer.js index cb86d0a2921..bd75997932f 100644 --- a/docs/content/sidebars/developer.js +++ b/docs/content/sidebars/developer.js @@ -27,6 +27,14 @@ const developer = [ 'developer/getting-started/debug', 'developer/getting-started/client-tssdk', 'developer/getting-started/coffee-example', + { + type: 'category', + label: "Independent Ticketing System Tutorial", + items: [ + 'developer/getting-started/independent-ticketing-system/package', + 'developer/getting-started/independent-ticketing-system/frontend', + ] + }, 'developer/getting-started/simple-token-transfer', ], }, diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/after-transfer.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/after-transfer.png new file mode 100644 index 00000000000..af64120aeab Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/after-transfer.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/buy-ticket-transaction.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/buy-ticket-transaction.png new file mode 100644 index 00000000000..10e4cafbaf1 Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/buy-ticket-transaction.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/buy-ticket.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/buy-ticket.png new file mode 100644 index 00000000000..f4f4b80dd6b Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/buy-ticket.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/dashboard.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/dashboard.png new file mode 100644 index 00000000000..e58e4f47132 Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/dashboard.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/enable-ticket-to-buy.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/enable-ticket-to-buy.png new file mode 100644 index 00000000000..55044b8878d Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/enable-ticket-to-buy.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/enable-ticket-transaction.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/enable-ticket-transaction.png new file mode 100644 index 00000000000..7cbb0be5a4b Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/enable-ticket-transaction.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/mint-page.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/mint-page.png new file mode 100644 index 00000000000..c0382bb7eb7 Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/mint-page.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/mint-ticket.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/mint-ticket.png new file mode 100644 index 00000000000..d9939c5c849 Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/mint-ticket.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/other-user.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/other-user.png new file mode 100644 index 00000000000..d28d0e16c84 Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/other-user.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/resell-transaction.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/resell-transaction.png new file mode 100644 index 00000000000..c8353be6918 Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/resell-transaction.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/resell.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/resell.png new file mode 100644 index 00000000000..126550adf96 Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/resell.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/transfer-ticket.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/transfer-ticket.png new file mode 100644 index 00000000000..29492950389 Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/transfer-ticket.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/transfer.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/transfer.png new file mode 100644 index 00000000000..96b43aa4c2c Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/transfer.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/whitelist-buyer-page.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/whitelist-buyer-page.png new file mode 100644 index 00000000000..9cba5a1db32 Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/whitelist-buyer-page.png differ diff --git a/docs/site/static/img/developer/getting-started/independent-ticketing-system/whitelist-buyer-transaction.png b/docs/site/static/img/developer/getting-started/independent-ticketing-system/whitelist-buyer-transaction.png new file mode 100644 index 00000000000..691540f8685 Binary files /dev/null and b/docs/site/static/img/developer/getting-started/independent-ticketing-system/whitelist-buyer-transaction.png differ