4ban-old / EOS-demux-js-example

Example of using demux-js library for getting the transaction history (concrete actions) of specific contract and saving them into MongoDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

demux-service

The daemon to monitor the EOS producer and record committed transactions (actions) into the Mongo database.

There are 2 identical models and effects for them in case to demonstrate how easy to modify it if you want to use different actions, models, save functions

Description

This example tracks the transfer action for different contracts and store them into different collections in the Mongo database.

  • {contract account name 1}::transfer
  • {contract account name 2}::transfer

Install

Install dependencies: npm install Fill the .env file.

Available parameters:

# Mainnet
ENDPOINT=https://eos.greymass.com
# {server_address} is a ip address or domain name of the server
# EOS is a Mongo database name
MONGODB_URL=mongodb://{server_address}:27017/DBname

or

# Testnet
ENDPOINT=http://api.kylin.alohaeos.com
# {server_address} is a ip address or domain name of the server
# EOStest is a Mongo database name
MONGODB_URL=mongodb://{server_address}:27017/DBnameTest

Start | Stop points

# Start point of tracking
# 0 - is a "tail" mode, where service start at an offset of the most recent blocks.
START_AT=100
# Stop point of tracking
# 0 - means that it will not stop
STOP_AT=200

To handle the microfork issue enable the processing of irreversible blocks

# irreversible blocks only
IRREVERSIBLE=true

Accounts with contracts to track

ACCOUNT_1=eosio.token
ACCOUNT_2={contract_account_name 2}

Credentials

# Login and password from the database
MONGODB_USER={username}
MONGODB_PASS={password}

Usage

To run the service: npm start

Additional

For further use of the database, look at the example implementation of API example

About

Example of using demux-js library for getting the transaction history (concrete actions) of specific contract and saving them into MongoDB

License:MIT License


Languages

Language:JavaScript 100.0%