This simple example shows how you can use Truffle and the Loom Truffle Provider to build a simple Web UI that interacts with the Loom PlasmaChain.
Make sure the following requirements are met and then follow the steps in the next section:
Recommended Node version v10.15.3
yarn or npm
First, let's clone this repository. Open a terminal, cd into the directory where you store your projects, and run the following command:
git clone https://github.com/loomnetwork/truffle-dappchain-exampleNext, cd into truffle-dappchain-example:
cd truffle-dappchain-exampleand run:
yarn installThe following command will download the loom binary and generate the private key for you:
yarn gen:extdev-keyThis will download the loom binary and generate a private key. The private key will be saved into a file called extdev_private_key.
As an example, we will deploy and run our application against extdev_plasma_us1.
Run the following command:
yarn deploy:extdevThe above command will compile and then deploy our smart contract to
extdev_plasma_us1
Run this command below to send transactions to the smart contract deployed to extdev_plasma_us1:
yarn test:extdev
If everything looks good, let's spin up a web server and interact with our smart contract.
The web interface is built with React and Webpack. Open a new terminal and run the following command:
yarn serve:extdevThe web interface is available on http://localhost:8080.
First, you have to generate a private key using:
yarn gen:loom-keyThis will download the loom binary and write a private key to a file called loom_private_key
In a new terminal, run:
yarn loom:initand then:
yarn loom:runTo deploy, run the following command:
yarn deployyarn testWe're ready to start the web server. In a new terminal, run:
yarn serve-
In order to correctly redeploy the contracts, there's a command
yarn deploy:reset. -
Also is possible to call truffle command directly with
yarn truffle. -
We're not versioning the build directory for this particular example, although is recommended to versioning, the limitation can be removed by editing the
.gitignorefile.
- Events declared on smart contracts should have an named parameter like
NewValueSet(uint _value)in the contractSimpleStore.sol. Also, it helps in dealing with events.
BSD 3-Clause License
