Giter Site home page Giter Site logo

ahmetozlu / the_smart_contract_burger_store Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 1.0 700 KB

:hamburger: :fries: A real life case study for developing Ethereum smart contract for businesses: Building a smart contract to manage a burger store.

License: MIT License

Solidity 45.70% JavaScript 54.30%
dapp blockchain smart-contract defi ganache truffle case-study ssmart-contract-project develop-smart-contract smart-contract-payment

the_smart_contract_burger_store's Introduction

The Smart Contract Burger Store

This project focuses on a real life case study which is developing an Ethereum smart contract to manage a burger store. This case study can be adopted for various cases to use smart contract for real-life businesses. For more info, you can check related medium post.

Basicaly the smart contract, which is developed in this project, provides:

  • The functions for customers: Order burger, safe payment, get invoice and mark order as delivered functions.
  • The functions for burger store: Get orders, send price, send invoice and safe payout functions.

This repository presents practices about:

  • Setup a blockchain.
  • Develop Ethereum smart contract.
  • Deploy the contract and test it.

Theory

Basically there are 3 components in this project which are:

Component Explanation
Burger Store Deploys the contract and owns it.
Customers Can order burgers to buy them.
Smart Contract Provides safe and robust contract that are immutable.

And here is given below a business flow chart which explains a sample flow for the usage of this smart contract.

Functionalities

There are a bunch of functions are implemented in this case study. This functions can be adopted for any other business cases. Here are the functions and their details.

  • sendOrder: Function to send order. Only customers can use this function.
  • checkOrder: Function to check orders.
  • sendPrice: Function to send price. Only the owner (Burger Store which deploys this Smart Contract) can use this function.
  • sendSafePayment: Function to send safe payment. Only customers can use this function.
  • sendInvoice: Function to send invoice. Only the owner can use this function.
  • getInvoice: Function to get invoice.
  • markOrderDelivered: Function to mark the order as delivered. Only customers can use this function.

And, here are the events are triggered for the activities:

  • OrderSent: Event triggers when order sent.
  • PriceSent: Event triggers when price sent.
  • SafePaymentSent: Event triggers when safe payment sent.
  • InvoiceSent: Event triggers when invoice sent.
  • OrderDelivered: Event triggers when order delivered.

The functions and events can be modified and used for any other business logic requirements.

Quick Demo

First, clone the repository and build the project using truffle by this command:

truffle build

After building the project and starting ganache which provides ethereum blockchain network on your local, our smart contract can be deployed using truffle by this command:

truffle migrate --reset

We can use developed unit test class to perform unit testing:

truffle test

Citation

If you use this code for your publications, please cite it as:

@ONLINE{
    author = "Ahmet Özlü",
    title  = "A Case Study: Ethreum Smart Contract for Managing a Burger Store",
    year   = "2021",
    url    = "https://github.com/ahmetozlu/the_smart_contract_burger_store"
}

Author

Ahmet Özlü

License

This system is available under the MIT license. See the LICENSE file for more info.

the_smart_contract_burger_store's People

Contributors

ahmetozlu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

catcoinsnet

the_smart_contract_burger_store's Issues

Failed Deployment

2_deploy_contracts.js
=====================

   Deploying 'BurgerMenuOrder'
   ---------------------------

Error:  *** Deployment Failed ***

"BurgerMenuOrder" -- invalid address (argument="address", value=undefined, code=INVALID_ARGUMENT, version=address/5.0.5) (argument="_buyerAddr", value=undefined, code=INVALID_ARGUMENT, version=abi/5.0.7).

    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:70:1)
    at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:56:1)
    at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:217:1)
    at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
    at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.runAll (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
    at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:258:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:223:1)
    at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:172:1)
Truffle v5.4.3 (core: 5.4.3)
Node v14.17.0

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.