Skip to content

Latest commit

 

History

History
79 lines (59 loc) · 2.25 KB

README.md

File metadata and controls

79 lines (59 loc) · 2.25 KB

Ethereum Sample

Prerequisites

  • Java (tested with java8)
  • Node (tested with 9.11.1)
  • git (apt-get install git-core)
  • Python 2.X (Sudo apt install python-minimal)
  • GCC (Sudo apt install gcc)
  • build-essential (sudo apt-get install build-essential)
  • Maven (Sudo apt-get install maven)
  • Setup Environment

  • Install Docker
  • Install Geth
  • sudo apt-get upgrade
    sudo apt-get install -y build-essential
    sudo apt-get install git
    cd ~
    git clone https://github.com/ethereum/go-ethereum.git
    
    cd ~
    wget https://dl.google.com/go/go1.9.3.linux-amd64.tar.gz
    sudo tar -C /usr/local -xzf go1.9.3.linux-amd64.tar.gz
    add to ~/.profile : export PATH="$PATH:/usr/local/go/bin"
    
    cd ~
    cd go-ethereum
    make geth
    
    • Install SolC
    Npm install -g solc
    • Install Web3J
    Npm install -g web3

    Run application

    1. Running Ethereum

    Fron the ethereum folder, run ./runminer.sh to start the miner node. Check the logs by running docker ps to get the container ID and then docker logs CONTAINER_ID -f. When the DAG generation process has finished and the logs say 'commit new mining work', run ./runattach.sh to open RPC connection with the miner node. Generating DAG usually takes a while.

    2. Spin up database

    docker run --name some-postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres

    3. Start the Springboot app

    4. Deploy smart contract

    From the contracts folder, run

    ./redeploy-contract.sh

    5. Test API

  • POST to localhost:9000/register-user to create a user (request body: { "username":"Bob", "password":"some-password"}
  • POST to localhost:9000/ to create a contract (request body: {"creator":"Bob", "coach":"coach","coachee":"coachee"}. Make sure the creator has an account (so Bob in this case)
  • GET to localhost:9000?username=Bob to get the coachee from the smart contract (again make sure to pass the name of the creator of the contract, which is Bob here)

    Teardown

    From src/ethereum run
    ./wipeall.sh

    The ethereum-part is an (over)simplification of https://github.com/vertigobr/ethereum