Skip to content

Setting up local development environment

Kosta Korenkov edited this page Feb 5, 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 -b migrations https://github.com/leapdao/leap-contracts.git
cd leap-contracts/
yarn

Now run:

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 node_config.json configuration file which we will use later for running the parsec node.

Launching the node

Leave the truffle console running, open a new terminal tab and cd into ParsecLabsRepos. 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/node_config.json

Should look something like this:

⚠️Irrelevant for PoA contracts: Now you need to buy a slot to become a validator on your chain. This means we have to interact with the bridge contract. You can do this in remix or you can use the web-ui.

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 Custum 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.

⚠️Irrelevant for PoA contracts: Now to become a validator, notice the message left by the node when we started it. There you can see the parameters you need to register your node as a validator. Fill the form on the web-ui with this data, mine looks like this:

Then submit the transaction and you should be a validator now. Now go back to the node and restart it, the validator warning should be gone now.

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.

Clone this wiki locally