Giter Site home page Giter Site logo

blockchain-sample's Introduction

blockchain-app-template

blockchain-app-template

setup

  1. install node.js
  2. create Web3 development environment https://www.alchemy.com/
  3. send crypt currency from https://goerlifaucet.com/

setup react and smart contruct templates

$ . ./setup.sh
  • setup client files

    • create react app
      • $npx create-react-app client
    • copy blockchain_react_app_template files
    • install ethers.js
      • $npm install --save ethers
  • setup smart contract

    • install hardhat
      • $install --save-dev hardhat
    • copy smart_contract_template files

Deploy Smart Contract

  1. edit hardhat.config.js # TODO 自動生成
require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  defaultNetwork: "goerli",
  solidity: "0.8.9",
  networks: {
    goerli: {
      // alchemy API KEY. https://www.alchemy.com/
      url: "https://eth-goerli.g.alchemy.com/v2/wfI0G...",

      accounts:[
        // MetaMask Private Key
        // **CAUTION!** Must not be public. Must not be committed to GitHub
        "b8d...",
      ]
    }
  }
};
  1. run deploy.js
$ cd smart_contract
$ npx hardhat run scripts/deploy.js --network goerli
  1. copy Aplication Binary Interface file(ABI) to ./client/utils
  2. write deployed address to connect.js
  • TODO: connect.js を自動生成

  • connect.js

/ Applicartion Binary Interface.
// copy from ./smart_contract/artifacts/contract/Transactions.sol/
import abi from "./Transactions.json";

export const contractABI = abi.abi;

// copy and paste deployed address from console
// TODO: Automatically generate connect.js
export const contractAddress = "03a...";

Develop blockchain App

  • Start app
$ cd ./client
$ npm start
  • Implement Smart Contract

  • Implement App

    • READ React documents!!

Deploy to Heroku

note

Lisence

  • GPL v2
  • 商用利用不可 ♪

blockchain-sample's People

Contributors

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