calls
usage:
ctc calls ADDRESS_AND_OR_FUNCTION [options]
description:
output the result of multiple contract eth_call's
This command can be used in two ways:
1) Multi-contract Calls: same call across multiple contracts
- This is indicated by the --addresses parameter
- Example: call <function> --addresses <addr1> <addr2> <addr3>
2) Multi-block Calls: same call across multiple blocks
- This is indicated by either of the --blocks or --time parameters
- Example: call <addr1> <function> --time 30d
in each case, <function> can be a name, a 4byte selector, or an ABI
## Multi-contract Calls
Example use case: Get a wallet's balances for many ERC20 tokens
Can use --block to select a specific block for calls
By default will use the first address's function abi for all calls
(Retrieve separate ABI's for each contract using --unique-abis)
## Multi-block Calls
Example use case: Get the total supply of an ERC20 over time
Can specify multi-block calls by blocks or by timestamps
Ranges are inclusive of start and end boundaries
### Specifying multi-block calls using --blocks
Example block specifications:
--blocks 16000 16010 16020 16030
--blocks 16010:16030:10
--blocks 16010:16030 -n 4
--blocks 16030:-20:10
--blocks latest:-20:10
(each of these examples would specify the same set of 4 blocks,
if the latest block were 16030)
Can also specify a block range sampled over a regular time interval:
--blocks 15000000:16000000:1d --> samples block range once per day
For block ranges with no interval specified, all blocks are used
### Specifying multi-block calls using --times
Example time specifications:
--times 20220701:20220730 -n 30
--times 20220701:20220730:1d
--times 20220701:29d -n 30
--times 29d:20220701 -n 30
(each of these examples specifies the same set of 30 timestamps)
Can also use the current time as an implicit default:
--times 100d::1d
--times 100d -n 101
--times 100d: -n 101
--times 100d:: -n 101
(each of these examples specifies the same set of 100 timestamps)
Can indicate timestamps using a variety of formats:
timestamp formats │ meaning │ examples
───────────────────────┼──────────────────┼───────────────────────
number + letter │ timelength │ 100d
(one of {yMdhms}) │ │ 24h
───────────────────────┼──────────────────┼───────────────────────
YYYY │ start of year │ 2018
│ │ 2022
───────────────────────┼──────────────────┼───────────────────────
YYYYMM │ start of month │ 201802
YYYY-MM │ │ 2022-06
───────────────────────┼──────────────────┼───────────────────────
YYYYMMDD │ start of day │ 20180228
YYYY-MM-DD │ │ 2022-06-01
───────────────────────┼──────────────────┼───────────────────────
YYYYMMDD_HHMMSS │ minute in day │ 20180228
YYYY-MM-DD_HH:MM │ │ 2022-06-01_04:30
───────────────────────┼──────────────────┼───────────────────────
YYYYMMDD_HHMMSS │ second in day │ 20180228
YYYY-MM-DD_HH:MM:SS │ │ 2022-06-01_04:30:40
───────────────────────┼──────────────────┼───────────────────────
large number │ unix timestamp │ 1600000000
│ │ 1700000000
See the tooltime package for more information about time specifications
A default of -n 25 is used if no -n is specified for time range
## Outputs
A table of outputs is displayed by default, omit with --no-table
Numerical outputs of multi-block calls are charted, omit with --no-chart
Use --export to output data to a json or csv file
More data is included when exporting to a file
examples:
# 1) multi-contract template: same call across multiple addresses
ctc calls <function> [<function_parameters>] --addresses <addresses>
# 2) multi-block template: same call across multiple blocks
ctc calls <address> <function> [<function_parameters>] --blocks <blocks>
# Balance of DAI, USDC, and USDT in Curve 3pool
ctc calls balanceOf 0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7 --addresses
0x6b175474e89094c44da98b954eedeac495271d0f 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
0xdac17f958d2ee523a2206206994597c13d831ec7 --normalize
# Weekly balance of DAI in Curve 3pool throughout year 2021
ctc calls 0x6b175474e89094c44da98b954eedeac495271d0f balanceOf 0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7 --times
2021:2022:1w --normalize
# Balance of DAI in Curve 3pool over the past 1 million blocks
ctc calls 0x6b175474e89094c44da98b954eedeac495271d0f balanceOf 0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7 --blocks
latest:-1000000 -n 20 --normalize
arguments:
ADDRESS_AND_OR_FUNCTION <see above>
-b, --blocks BLOCKS block list or block range (see above)
-t, --times TIMES timestamp list or time range (see above)
-n N number of calls to make in given range
-a, --addresses ADDRESSES addresses to point calls toward
--block BLOCK block number for calls
--unique-abis UNIQUE_ABIS retrieve separate ABI for each address
--export EXPORT file path for output (.json or .csv)
--overwrite specify that output path can be overwritten
--no-table do not output a table
--no-chart do not output a chart
--from FROM address that calls should come from
--normalize NORMALIZE normalize output by value, default is 1) erc20 decimals or 2) "1e18"
--blocks-gte-times find the blocks >= timestamps instead of <=