npm install -g @haechi-labs/henesis-cli
henesis login
git clone https://github.com/HAECHI-LABS/sample-erc20-watcher
cd sample-erc20-watcher
npm install
To subscribe the blockchain data without losing data using Henesis, it is necessary to record in the filter which contract's events will be listened to. Filter registration can be done through henesis.yaml
, and the sample code demonstrates how to use Henesis by subscribing to events from the TetherToken contract, which is distributed on the Ethereum mainnet.
name: tether-tutorialversion: v1 # (TBD) The version of this yaml file.apiVersion: v1 # (TBD) The version of Henesis api. The type of message you receive can be changed depending on this version.blockchain:platform: ethereumnetwork: mainnetthreshold: 6 # optional.# ethereum: (default: 12, min: 6)# klaytn: (default: 0, min: 0)filters:contracts:- address: '0xdac17f958d2ee523a2206206994597c13d831ec7'name: TetherTokenfiles: # The events of the contracts listed below can be combined together at this address.- path: ./contracts/TetherToken.solcontractName: TetherTokencompilerVersion: 0.4.18provider:type: webSocket
You can deploy your integration using the following CLI command.
henesis integration:deploy
If the integration has been successfully deployed, you will see something like this:
Deploying... !tether-tutorial-jrweu has been deployedDeploying... done
You can check the state of the integration through the CLI command. If the state
is marked as Available
, the integration is successfully deployed.
henesis integration:status
Id Name Platform Network Version Provider Statetether-tutorial-jrweu tether-tutorial ethereum mainnet v1 webSocket Available
To subscribe the event data of blockchain through Henesis, you need the following information:
CLIENT_ID
: You can check it through the henesis account:describe
command.
INTEGRATION_ID
: You can check it through the henesis account:describe
command.
The ClientId can be checked using the following CLI command.
henesis account:describe
Email: haechi@haechi.ioName: haechiOrganization: haechi-labsClientId: a481485a958f1b82ac210ec4eea27943
The IntegrationId can be checked using the following CLI command.
henesis integration:status
Id Name Platform Network Version Provider Statetether-tutorial-jrweu tether-tutorial ethereum mainnet v1 webSocket Available
Enter the ClientId and IntegrationId in the .env
configuration file.
CLIENT_ID=<your client id>INTEGRATION_ID=<your integration id>
Build your source code using npm.
$ npm run build:standalone
Run your API server.
$ node index
Check http://locahost:3000 in your browser and make sure you are subscribed to the Event data.
See here for raw data of subscribed blockchain data..