This application contains multiple scripts to retrieve the EWT token balance of an account dynamically or for specific months or blocks from Energy Web Chain.
The following instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Please make sure you've already installed following dependencies:
npm >=6.11.3
node >=10.16.3
Follow the steps below to have development environment running:
- Clone the repository:
git clone https://github.com/olisystems/ewt-balance.git
- Change directory to the cloned folder and install all requisite npm packages (as listed in
package.json
):
cd ewt-balance
npm install
- To get the balance up to 01-07-2020, run the following command in the terminal:
$ npm run balanceByBlock
- Run the following command in the terminal to get the balance for specific timestamps:
$ npm run balanceByMonth
- Currently, to get the balance dynamically requires a much longer time (up to several days). To get the balance dynamically, run the following command in the terminal:
$ npm run dynamic
-
Instead of starting from an early block, use the last known block number as a starting point and get the block number for next month using the
getBlockNumber.js
. Then put this block number intoblocks
array ofblock-balance.js
script.For example, we can see from the
block-balance.js
that the last calculated block number is6505859
. We can use this block number as a starting point in thegetBlockNumber.js
file and use the next month astimestamp
. Hence we will get the block number for the next month that we can use in theblock-balance.js
script.Run the following command to get the block number for the specified timestamp:
$ npm run getBlockNumber
- Run
node getBlockNumber.js
- Copy block numbers from console to
BLOCKS.js
array - Run
node block-balance.js
Pull requests are welcome.
- Fork the repository.
- Create your new feature branch:
git checkout -b new-feature-branch
- Stage your changes:
git add .
- Commit the changes:
git commit -m "add commit message"
push
to the branch:git push origin new-feature-branch
- Submit a
pull request
.