Development Framework

Published on 2018 Oct 23 00:00:04
Last Updated on 2018 Oct 25 16:38:37

Project 8

A toolkit for developing Token Incentivized Sidechains on top of Ethereum.

Prerequisites

Setup

git clone git@github.com:luciditytech/token-incentivized-sidechains.git
npm install

Development Environment

Use the following instructions to setup a development enviroment to test and develop sidechain applications.

Deploy Smart Contracts

You can edit the config/develpment.json file to review and make changes prior to deploying the contracts.
Use truffle migrate to deploy all relevant smart contracts to your local devnet using sane defaults.

The development migration scripts will launch a new ERC-20 token, Verifier Registry, and other Rootchain contracts.

Add Local Verifier Entry

Access the truffle console using: truffle console.

Add a new development verifier using the following:

1
2
3
4
5
6
7
var verifierRegistry = VerifierRegistry.at(VerifierRegistry.address);

verifierRegistry.create(
"http://127.0.0.1:9000",
web3.eth.accounts[0],
true
);

Validate that the new verifier was created:

1
verifierRegistry.verifiers(web3.eth.accounts[0]);

Validate the number of registered verifiers:

1
2
3
4
verifierRegistry
.getNumberOfVerifiers().then((v) =>
v.toNumber()
);

Set Tokens at Stake

In order to participate in consensus, the local verifier must first deposit tokens that will be set at stake during consensus.

Access the truffle console using: truffle console.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var token = HumanStandardToken.at(HumanStandardToken.address);

var chain = Chain.at(Chain.address);
var bankAddress; chain.stakingBank().then((s) => bankAddress = s);

...

var stakingBank = StakingBank.at(bankAddress);

token.approveAndCall(
stakingBank.address,
1,
null,
{ from: web3.eth.accounts[0] }
);

stakingBank.balances(web3.eth.accounts[0]).then((v) => v.toNumber());

Start Verifier Message Listener Service

Start Verifier Message Handler Service

Add Participant Entry

Start Consensus Handler Service