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
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
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_HOSTis the IP host to connect to, for example10.0.2.2VAGRANT_SF_SMB_USERNAMEis the user name allowed to map the remote folderVAGRANT_SF_SMB_PASSWORDis the user password
The plugin vagrant-cachier is configured to be optional.
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.shThe projects folder contains truffle projects only. Additionally, the folder projects is mounted as shared folder into the vagrant box as /home/vagrant/sf_projects.
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.shIn case of webpack box, before running a truffle project apply the following tweaks:
-
file
package.jsonchanges the scriptdevwithwebpack-dev-server --public 201819-sem1-las3019.test:8080 --host 0.0.0.0 --watch-poll -
file
app/src/index.jsreplaces127.0.0.1with201819-sem1-las3019.test -
file
app/truffle-config.jsadd 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 developmentin another terminal. Thenmigrate --reset
The above changes about host come in handy to avoid the ports remapping and potentially some side-effects.
-
use
byobuto split the screen and running multiple commands -
open your favourite browser at http://201819-sem1-las3019.test:8080
-
to grab
ganacheaccounts, create a log file, and keeping the output on screen invokeganache-clias 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
-
VirtualBox cannot work when Hyper-v is enabled. Read the followings how to disable or apply an alternative solution:
-
Slow ssh connection running
vagrant ssh. Set up the environment variableVAGRANT_PREFER_SYSTEM_BINequals to 1 -
Failure to change the file hosts or mount shared folder. Run
vagrantcommand with administrative permission (aka run administration console) -
running
npm -g ls --depth=0provides some warnings like belowvagrant@201819-sem1-las3019:~$ npm -g ls --depth=0 /home/vagrant/.nvm/versions/node/v10.14.1/lib +-- ganache-cli@6.2.3 +-- node-gyp@3.8.0 +-- npm@6.4.1 +-- solc@0.4.25 +-- truffle@5.0.0 npm ERR! invalid: websocket@1.0.26 /home/vagrant/.nvm/versions/node/v10.14.1/lib/node_modules/ganache-cli/node_modules/ganache-core/node_modules/web3-providers-ws/node_modules/websocket npm ERR! invalid: ethereumjs-abi@0.6.5 /home/vagrant/.nvm/versions/node/v10.14.1/lib/node_modules/ganache-cli/node_modules/ganache-core/node_modules/eth-tx-summary/node_modules/eth-sig-util/node_modules/ethereumjs-abi npm ERR! invalid: ethereumjs-abi@0.6.5 /home/vagrant/.nvm/versions/node/v10.14.1/lib/node_modules/ganache-cli/node_modules/ganache-core/node_modules/web3-provider-engine/node_modules/eth-sig-util/node_modules/ethereumjs-abi
-
running bash script provide the warning message "bash: cannot set terminal process group (8598): Inappropriate ioctl for device"
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.