Skip to content

FuturICT2/susDAO-demos

Repository files navigation

Demos in the Sustainable DAOs lecture 2020

As shown live in Block IV of the lecture, see the recording here.

#1 eth.build demo

Link to the eth.build demo setup. Also saved as .webloc in this repo.

#2 Deployment demo

Note that the HTML-setup is not recommended as a boilerplate to start coding from, it was merely intended as "shortest path" to wiring up something functional in the browser during the live demo.

For a proper dApp setup you might look into boilerplates like the truffle react box, scaffold-eth or create-eth-app. There are also many tutorials out there to help you get going. The pet shop one was helpful to me back then - it seems a bit old now though.

Setup

# Node.js 10.0.0
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
source ~/.bashrc
nvm install 10.0.0
nvm use 10.0.0

# Truffle
npm install -g truffle

# Ganache
# install from trufflesuite.com/ganache

Deploying the smart contract

truffle compile # creates DemoContract.json in the build/contracts/ folder
truffle migrate # deploys the smart contract onto the blockchain

Interacting with it via command line

truffle console
> DemoContract.deployed().then(inst => inst.foo())
> DemoContract.deployed().then(inst => inst.setFoo(7))

Interacting with it via browser

python3 -m http.server # quickest way to serve from current directory
# --> http://localhost:8000/

Create contract-address.js with the address of the deployed DemoContract:

let contractAddress = '0x...';

Commit-walker script

I wrote the commit-walker.sh script to advance in the git history commit by commit during the deployment live demo. Starting from the past on a new branch and cherry-picking one by one from main forward. It uses stepcounter to read/write the next step and git.log to extract the respective commit hash. The command to list the hashes is:

git log --reverse --pretty=tformat:%h > git.log