The BookMyTicket smart contract is designed to manage a ticket booking platform on the Move blockchain. It includes functionalities for initializing the platform, buying and claiming tickets, managing ticket types, and handling ownership changes. The contract is implemented in Move, the programming language for the Move blockchain.
- Introduction
- Smart Contract Components
- Events
- Error Constants
- Initialization
- Functionalities
- Testing
- Usage
- License
BookMyTicket is a decentralized ticket booking platform that leverages the Move blockchain's capabilities to ensure secure and transparent transactions. The smart contract is designed to handle ticket purchases, profit claims, and ownership changes. It provides a robust mechanism for adding, removing, and managing various ticket types.
The OwnerCap
struct represents the owner's capabilities, providing a key for secure access.
The BmtPlatformDetails
struct contains essential details about the BookMyTicket platform, such as the owner's address, platform parameters, profit information, and user-related data.
The TicketNFT
struct represents a non-fungible ticket, including information like ticket type, description, ticket ID, and claimed status.
The UserTicketInfo
struct stores information about tickets owned by a user, including the owner's address, ticket ID, ticket type, and the amount paid.
PlatformInitializedEvent
: Emitted when the BookMyTicket platform is initialized.ProfitClaimedEvent
: Emitted when profits are claimed on the platform.TicketTypeAddedEvent
: Emitted when a new ticket type is added.TicketClaimedEvent
: Emitted when a ticket is claimed.BlockUserEvent
: Emitted when a user is blocked or unblocked.OwnerChangeEvent
: Emitted when the owner of the platform is changed.TicketTypeRemovedEvent
: Emitted when a ticket type is removed.TicketPurchasedEvent
: Emitted when a user purchases a ticket.
EINVALID_CLAIMABLE_AMOUNT
: Invalid claimable amount.EINVALID_LENGTH
: Invalid length.ETICKET_LIMIT_EXCEED
: Exceeding the ticket limit.EINVALID_TICKET_TYPE
: Invalid ticket type.EINSUFFICIENT_AMOUNT
: Insufficient amount.EINVALID_SIGNATURE
: Invalid signature.EUSER_ALREADY_BLACKLISTED
: User already blacklisted.EUSER_NOT_BLOCKED
: User not blocked when expected.EUSER_BLACKLISTED
: User blacklisted when not expected.
The init
function initializes the BookMyTicket platform, creating initial platform details and owner capabilities. It emits a PlatformInitializedEvent
to signify the completion of the initialization.
The claim_profit
function allows the owner to claim profits from the platform. It verifies the owner's signature, checks the claimable amount, transfers profits to the owner, and updates the claim nonce. It emits a ProfitClaimedEvent
upon successful execution.
The buy_tickets
function enables users to buy tickets on the platform. It checks user eligibility, ticket type validity, and user funds. Users can purchase tickets, and the platform updates its profit and ticket information. It emits a TicketPurchasedEvent
upon successful execution.
The claim_ticket
function allows users to claim a ticket, marking it as claimed and emitting a TicketClaimedEvent
.
Functions like add_ticket_types
, remove_ticket_type
, and get_all_ticket_types
allow the owner to add, remove, and retrieve information about ticket types.
The change_owner
function facilitates ownership changes, updating the owner's address and emitting an OwnerChangeEvent
. Additionally, functions like block_user
and unblock_user
allow the owner to manage user blacklisting.
This smart contract is released under the MIT License. Feel free to use, modify, and distribute it as needed.
The TicketProjectToken::ticket_token
module defines a Move smart contract for managing a custom token called TICKET_TOKEN
. This token is designed for use in the Ticket Project and is responsible for ticket purchases.
The TICKET_TOKEN
module is a part of the Ticket Project and is dedicated to managing the custom token used for purchasing tickets on the platform. It provides functionalities for initialization, minting, and includes a testing scenario.
The TICKET_TOKEN
struct represents the custom token used in the Ticket Project. It is designed to be used for ticket purchases within the platform.
The init
function initializes the TICKET_TOKEN
by creating its treasury cap, defining metadata, and minting an initial supply of tokens to the owner. It also transfers the treasury cap to the owner.
The mint
function allows the owner to mint additional TICKET_TOKENs
and transfer them to a specified recipient. It also shares the minting information by creating a Check
object.
The module includes a testing scenario (coin_tests_metadata
), which is currently commented out. This scenario aims to test coin metadata functionality, specifically the initialization of the TICKET_TOKEN
and metadata retrieval.
This smart contract is released under the MIT License. Feel free to use, modify, and distribute it as needed.