Skip to content

Setting up local development environment

Kosta Korenkov edited this page May 8, 2019 · 13 revisions

This is a quick guide on how to setup a local development environment for working with the parsec codebase.

To begin with, create a directory called something like leapdao somewhere on your file system:

mkdir leapdao
cd leapdao

Deploying smart contracts

First we will deploy the required smart contracts in our local truffle network. Start by cloning leap-contracts and building it:

git clone https://github.com/leapdao/leap-contracts.git
cd leap-contracts/
yarn

Now run:

./node_modules/.bin/truffle develop

You should see something like this:

truffle

This starts a local ethereum network on localhost:9545. Also note the mnemonic on the bottom, you can use it to import the generated accounts into metamask. Now in the truffle console run:

migrate --reset

You should see something like this:

The above command will also generate a build/nodeFiles/generatedConfig.json configuration file which we will use later for running the leap node.

Launching the node

Leave the truffle console running, open a new terminal tab and cd into leapdao folder. Now run:

git clone https://github.com/leapdao/leap-node.git
cd leap-node/
yarn

Now start the node with:

DEBUG=tendermint,leap-node* node index.js --config=../leap-contracts/build/nodeFiles/generatedConfig.json

Should look something like this:

TODO: add instruction how to set up PoA validator

Setting up remix

First install remixd, which will allow remix to access your local files. Then run this in your leap-contracts folder:

remixd -s .

Now go to remix. In the upper left corner you will see a button like this:

Click this to connect remix to your contracts folder. Then in the left-most column, navigate to /localhost/contracts/Bridge.sol. Now remix should compile your contract. Then in the upper right, click run and under environment select Web3 Provider. In the popup enter http://localhost:9545. Now you can load the Bridge at address given by the truffle console when we ran migrations and can call functions on the contract.

Web-UI

For supporting functions, the easiest way to interact with your contract is with the bridge-ui. In the leapdao folder, clone the web-ui repo:

git clone https://github.com/leapdao/bridge-ui.git
cd bridge-ui/
yarn
yarn start

You should now be able to visit the web-ui at http://localhost:1234. Now in metamask, select Custom RPC for the network provider and connect to http://localhost:9545. Then restore accounts from the seed given by the truffle console earlier. You should see some ether on this account.

Now you should make your node to be validator on the network. TODO: Guide how to set a validator slot on PoaOperator contract.

Also, don't forget to send some ether to the node validator address, so it can pay for the gas fees when submitting transactions.

Populating the blockchain

We now have a basic setup, but it would be nice to have some transactions in our blockchain. This is what we will do next.