In order to listen the BitBracket's smart contract events, we have developed this project based on NodeJS.
$ [sudo] npm install forever -g
$ npm run start-prod
See more details in https://github.com/foreverjs/forever
Creates a .env file in the root folder and add into it the following pair key/values:
DB_URL="mongodb:url"
SC_URL_WS="ws://127.0.0.1:3001"
- Create a
.envfile based on the.env.template. - Set your MondoDB URL in the DB_URL key.
In order to listen the smart contract events, the app needs to read the smart contract's ABI/Interface. The ABI/Interface is a JSON file located in your smart contract project. So, you need to configure where the ABI/Interface folder is located. To do that, you need to change in the configuration:
baseOutputJson: "relative/path/to/your/smartconstract/jsons/"
You need to setup those three variables.
We usually use the Rinkeby network to test our contracts. So, you will only need to setup those variable in ./conf/env/rinkeby.js file.
The app will get the contract's addresses from the DB configured in the DB_URL value. So, when you deploy your smart contracts, you will need to save the addresses in your mongo database.
First, you need to install the Remix-IDE locally. To do that visit this URL.
In other command line execute the remix-ide command in the root folder of your smart contract folder. It will start a local Remix instance, and it will be able to be accessed by a browser.
- Clone the repository.
- Create your configurarion based on a template file. See How Setup Local Environment
- Configure the Smart Contracts' folder to get the JSON files. See How Configure Smart Contracts' folder.
- Check your smart contract's addresses. See Check Addresses in MongoDB.
- Invoke
npm run dev-rinkeby. It will start the app listening the smart contracts' events in the Rinkeby network. When you run the first execution, it will start listening the contract saved in the DB. - In other command line execute the Remix-IDE locally. See Execute Remix-IDE locally.
- Access to
http://localhost:8080and click on the link button located on the top left. After click it, select your smart contracts folder. - Configure Remix to access to the Rinkeby network.
- Open a smart contract.
- Now you can invoke function on a smart contract and listen the events in the app.