Sample DAppChain showing the integration between LoomProvider, Web3 and Loom.js for a super simple social network interaction, where users can post and comment on posts
The smart contract compiled for this examples uses the Solidity version 0.4.24 (SimpleSocialNetwork.sol)
This example also uses Redis and ElasticSearch to manages a cache layer
Please consult the Loom SDK docs for further instruction on running your own DappChain.
git clone https://github.com/loomnetwork/solidity-social-example
cd solidity-social-example
cd dappchain
wget https://storage.googleapis.com/private.delegatecall.com/loom/osx/build-137/loom
chmod +x loom
# Configure
./loom init
cp genesis.example.json genesis.json
# Run
./loom run
Notice that both services are required in order to correct run and interact with the application
# macOS
brew tap homebrew/services
brew install elasticsearch
brew install redis
# Start services on macOS
brew services start elasticsearch
brew services start redis
The indexer.js
is a service which will receive all events from the smart contract and feeds a cache layer built on a message queue and a fast database (Redis + ElasticSearch), it also serves the app with a fresh data on the address http://localhost:8081/posts
or http://localhost:8081/comments
Note this works best on Node8
brew install node@8
# On second terminal
cd web3-loom-provider/webclient
# install
yarn
node indexer.js
Finally we're going to start the webserver which will supply the interface allowing users to interact to the smart contracts on the Loom DappChain
# On third terminal
cd web3-loom-provider/webclient
# Install
yarn
# Compile protobuf
yarn run proto
# Start the demo
yarn start
The Simple Social Network web interface will be available on http://localhost:8080
MIT