Giter Site home page Giter Site logo

bvg's Introduction

BVG_Logo_07 2021 svg Get me a ride!

Solidity smart contract to simulate buying a transport ticket from BVG.

The smart contract provides funtionality to set and query owners of the contract, set prices of different kind of tickets, and buy and query user's tickets.

The initial owner and tickets prices are set when the contract is deployed, and both can be updated through the public interface.

There are different kind of tickets based on their duration:

  • Single (2 hours)
  • Daily (24 hours)
  • Weekly (7 days)
  • Monthly (31 days)
  • Yearly (365 days)

Read functions:

  • owners: Checks whether an address is an owner or not
  • ticketPrices: Gets a ticket price given a ticket type
  • users: Gets the tickets from a user given a user adresss and a ticket number
  • getBalance(): Gets the balance of the contract
  • isTicketExpired(uint _ticketNumber): Checks if the user's ticket has expired given a ticket number
  • getUserTicket(uint _ticketNumber): Gets the user's ticket information given a ticket number
  • getUserAllTickets(): Gets a list of all user's tickets

Write functions:

  • setTicketPrice(TicketType _type, uint _price): Sets the price of a ticket, only owners are allowed to perform this transaction
  • addOwner(address _owner): Adds an owner to the list of owners, only owners are allowed to perform this transaction
  • withdraw(): Withdraw the total balance to an owner, only owners are allowed to perform this transaction
  • buyTicket(TicketType _type): Buys a ticket and returns the ticket number, the ticket hash, and ticket information, any user can perform this transaction

Ticket information:

  • blockNumber: block number of the ticket creation
  • startTimestamp: the timestamp of the ticket creation
  • endTimestamp: the expiry date timestamp
  • ticketType: the ticket type {0: single, 1: daily, 2: weekly, 3: monthly, 4: yearly}
  • price: the price of the ticket at creation

bvg's People

Contributors

daniel-zullo 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.