Code Monkey home page Code Monkey logo

web3-tickets's Introduction

Play with web3-tickets

Blockchain dApp demo project

  • Using Ganache UI (RPC Server is: HTTP://127.0.0.1:8545). Import the first account to MetaMask.
  • Deploy the contract:
truffle migrate
  • Test the contract (optional):
truffle test test/Tickets.js

drawing

  • Install all the dependencies that was registered in the package.json (including web3, parcel, bootstrap, etc..) and run the project:
cd client
npm install
npm run start

Finally, connect your current account to the localhost server

drawing

Buying ticket:

drawing

Ganache Back-end console with current contract balance:

drawing

Current transaction information:

drawing


MEMO

Commands used for creating client directory and dependencies:

mkdir client
cd client
npm init -f
npm install --save-dev parcel
npm install --save web3 bootstrap

Connect to MetaMask using HTML & JavaScript

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JavaScript Test</title>
</head>
<body>
    <script>
        async function connect() {
            if ( typeof window.ethereum !== "undefined") {
                ethereum.request({method: "eth_requestAccounts"});
            }
        }
    </script>
    <button id="connectButton" onclick="connect()">Connect!</button>
</body>
</html>

REMINDER: If reboot and reconnect the Ganache UI, reinstalling npm dependencies is needed:

rm -rf node_modules
npm install
npm run start

References

Original auther: https://www.youtube.com/watch?v=FYhZPovlGZQ https://www.youtube.com/watch?v=JXa_Y-17Oj4

web3-tickets's People

Contributors

hyc0812 avatar

Stargazers

 avatar

Watchers

 avatar  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.