Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tool to extract public keys and balances from ethereum. #106

Open
nutmix opened this issue Jun 20, 2018 · 1 comment
Open

tool to extract public keys and balances from ethereum. #106

nutmix opened this issue Jun 20, 2018 · 1 comment
Assignees

Comments

@nutmix
Copy link
Contributor

nutmix commented Jun 20, 2018

The requirement is to produce a file containing all the visible public keys, account numbers and balances for a given coin up to a given block. It should be a command line tool written in go.

Parameters it should accept include:

  1. block number. optional. If not supplied, use all available data. If supplied means up to and including this block.
  2. contract address for given token. Required.
  3. filename. If not supplied, output to stdout.

All errors and warnings should be written to stderr or appended to a log file. Errors should halt execution with detailed log output including block number, and full transaction details.

Output format will be further clarified, but for ease of manipulation (e.g. to sort and remove to p X) suggest simple CSV:

account number, public key, balance, number of transactions.

Presumably, for any account which has not done a transaction, the public key will be blank.

Number of transactions is nice to have to help reconciliation & testing., not mandatory.

This is the contract for TRX on the main net:

Contract TokenName Symbol Decimals Official Site
#1: 0xf230b790e05390fc8295f4d3f60332c93bed42e2 Tronix TRX 6 -

Optimisations:

  1. rather than start at block zero and work up, to save time it would be better to start form the block where the contract was created. This should either be a parameter passed in. The user who is running the script could get the block using etherscan.io, looking for the first transaction, and looking up its block (or is a better way?)
  2. initial balance (totalSupply). Because the tool will look for transactions into and out of accounts, it can keep track of balances. The only account(s) it cant do this for are the contracts initial accounts, which are given a balance in the code itself, not via a transaction. Usually, the entire "totalSupply" is allocated to the account of the contract. In this case, we can either extract the "totalSupply" from the contracts "totalSupply()" function, or simply have it as an optional parameter. Given this total supply, and assuming that it is all allocated to the contract account, we can then calculate the balance of the contract account at the required end block. However, it is perfectly acceptable for now to simply show a negative balance for this one (or possibly more) accounts with initial balances allocated via the code (not transaction).

The tools main file should be in the root of the project so that it works with "go install"

The work should be committed to a dir below services, e.g. "eth-balance-extractor"

This task is in progress by Sigma.

@gz-c
Copy link
Member

gz-c commented Jun 20, 2018

Use https://github.com/shopspring/decimal for math calculations when adding up balances.

Do not use floats

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants