Crates.io | inoutflow |
lib.rs | inoutflow |
version | 1.0.0 |
source | src |
created_at | 2022-05-05 12:14:06.996021 |
updated_at | 2022-05-05 12:14:06.996021 |
description | Command line program to calculate in/out flow of native tokens of EVM-based chains (BSC, Ethereum, and Polygon) for target wallet/contract address |
homepage | |
repository | https://github.com/haxpor/inoutflow |
max_upload_size | |
id | 580970 |
size | 42,990 |
A command line program to compute and print out in/out flow of native tokens of EVM-based chains (BSC, Ethereum, and Polygon) of the wallet/contract address
It will involve utilizing 3 related APIs of provided by upstream API platforms (bscscan.com, etherscan.io, or polygonscan.com)
in order to have an understanding of native token (BNB, ETH, or MATIC) and balance respectively for each type of transaction as well as final balance for entire address.
We can manually compute balance of target address ourselves without requesting to balance API by sum in/out flow of native tokens from normal, and internal transactions, and subtract by fees from normal transactions.
We have no need to try to get fees from internal transactions because internal
transaction is part of normal transaction, and its gasPrice
and gasUsed
fields
are not available as part of API returned. So only fees from normal transactions
are enough.
In short,
Address balance = in/out of native-token flow of normal txs + in/out of native-token flow of internal txs + fees of normal txs
NOTE: We have no need to involve ERC-20/BEP-20, and ERC-721/BEP-721 transactions here because
they are also as part of normal transaction as they shared the same transaction hash.
It just happens that for this type of transaction, it sends 0
native tokens but other tokens.
So normal transactions' fees cover everything we need.
INOUTFLOW_BSCSCAN_APIKEY
- for working with Binance Smart Chain (BSC)INOUTFLOW_ETHERSCAN_APIKEY
- for working with EthereumINOUTFLOW_POLYGONSCAN_APIKEY
- for working with Polygonsource ~/.bash_aliases
.inoutflow --chain <CHAIN> <ADDRESS>
where --chain
(or -c
)'s possible values are bsc
, ethereum
, or polygon
.
So the input address will be based on such specified chain.
Sample output
$ inoutflow 0x5a52e96bacdabb82fd05763e25335261b270efcb --chain bsc
Found 194 txs!
- BNB outflow: 500000.0001 BNBs
- BNB inflow: 507000.07693536405 BNBs
- Net in/out balance: 7000.076835364045 BNBs
Found 25 internal txs!
- BNB outflow: 0 BNBs
- BNB inflow: 0.000000339984886578 BNBs
- Net in/out balance: 0.000000339984886578 BNBs
Total balance: 7000.052775939041 BNBs
$ inoutflow 0x49a2dcc237a65cc1f412ed47e0594602f6141936 --chain ethereum
Found 3930 txs!
- ETH outflow: 253655.5178577849 ETHs
- ETH inflow: 51001.49522086296 ETHs
- Net in/out balance: -202654.02263692193 ETHs
Found 482 internal txs!
- ETH outflow: 0 ETHs
- ETH inflow: 203349.21092720772 ETHs
- Net in/out balance: 203349.21092720772 ETHs
Total balance: 643.5772304060517 ETHs
$ inoutflow 0xf89d7b9c864f589bbf53a82105107622b35eaa40 --chain polygon
Found 161 txs!
- MATIC outflow: 3258607.025878074 MATICs
- MATIC inflow: 0.001 MATICs
- Net in/out balance: -3258607.024878074 MATICs
Found 38 internal txs!
- MATIC outflow: 0 MATICs
- MATIC inflow: 4004106.7107583876 MATICs
- Net in/out balance: 4004106.7107583876 MATICs
Total balance: 745498.6568908329 MATICs
MIT, Wasin Thonkaew