Skip to content

devcovato/201819_sem1_las3019

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

University of Malta - PLAS/LAS3019 2018/19

Tested only on Windows 10, but should work also on Linux and Mac with minor tweaks

NOTE There is an assumption that the below software is known

LAS3019 - Blockchain and Smart Contract Programming

Table Of Contents

Intro

To start developing on Ethereum the following software is required:

NOTE The below software is installed using chocolatey.

  • vagrant (version at writing moment: 2.2.2)
  • virtualbox (version at writing moment: 5.2.22)
  • git (version at writing moment: 2.19.1). The chocolatey package name git.install
  • openssh (version at writing moment: 7.7.2.1)
  • visual studio code (version at writing moment: 1.30.2) as editor or whatever you like

Vagrant

To get a functional vagrant the following tested plugin are required:

To save download time for guest machine use the plugin vagrant-cachier and define the following environment variables:

  • VAGRANT_SF_SMB_HOST is the IP host to connect to, for example 10.0.2.2
  • VAGRANT_SF_SMB_USERNAME is the user name allowed to map the remote folder
  • VAGRANT_SF_SMB_PASSWORD is the user password

The plugin vagrant-cachier is configured to be optional.

Project Organization

Below the project organization:

<current_folder>
|   .editorconfig
|   .gitignore
|   LICENSE.md
|   README.md
|
+---projects
|       .gitignore
|
\---vagrant
    |   Vagrantfile
    |
    \---scripts
            install-geth.sh
            install-node-nvm.sh
            install-nvm.sh
            install-truffle.sh
            provision.sh
            setup-devenv.sh
            setup-trufflebox.sh

The projects folder contains truffle projects only. Additionally, the folder projects is mounted as shared folder into the vagrant box as /home/vagrant/sf_projects.

Truffle Project Development

By default the script setup-trufflebox.sh creates a new truffle project named trufflebox-webpack. Moreover, the file trufflebox-webpack.lock is created to avoid overriding the project already set up. So, if you want to recreate the project than delete the lock file.

To set up a different project name and/or truffle box applies the following change:

    exec env TRUFFLEBOX_PROJECT_NAME='my-project' "$BASH" -il /vagrant/scripts/setup-trufflebox.sh
    # or
    exec env TRUFFLEBOX_NAME='webpack' "$BASH" -il /vagrant/scripts/setup-trufflebox.sh
    # or
    exec env TRUFFLEBOX_PRJNAME='my-project' env TRUFFLEBOX_NAME='webpack' "$BASH" -il /vagrant/scripts/setup-trufflebox.sh

In case of webpack box, before running a truffle project apply the following tweaks:

  • file package.json changes the script dev with webpack-dev-server --public 201819-sem1-las3019.test:8080 --host 0.0.0.0 --watch-poll

  • file app/src/index.js replaces 127.0.0.1 with 201819-sem1-las3019.test

  • file app/truffle-config.js add the following network configuration:

    development: {
      host: '0.0.0.0',
      port: 8545,
      network_id: '*' // Match any network id
    }
  • run ganache-cli --host 0.0.0.0 --port 8545, a Web3 provider for testing/development

  • run truffle console --network development in another terminal. Then migrate --reset

The above changes about host come in handy to avoid the ports remapping and potentially some side-effects.

Tips and Tricks

  • use byobu to split the screen and running multiple commands

  • open your favourite browser at http://201819-sem1-las3019.test:8080

  • to grab ganache accounts, create a log file, and keeping the output on screen invoke ganache-cli as follow:

    ganache-cli --host 0.0.0.0 | tee ganache.log | tee >(head -n 40 > ganache-accounts.txt) -p
    # or
    ganache-cli --host 0.0.0.0 | tee >(head -n 40 > ganache-accounts.txt) -p | tee ganache.log
    # or keep the same accounts
    ganache-cli --host 0.0.0.0 --mnemonic "las3019 blockchain ethereum dlt" | tee ganache.log | tee >(head -n 40 > ganache-accounts.txt) -p

Known Issues

License

The content of this project itself is licensed under the Creative Commons Attribution 3.0 Unported license, and the underlying source code used to format and display that content is licensed under the MIT license.

Releases

No releases published

Packages

No packages published