contract_calls
Schema: public
Description
This table contains parsed information about calls made to smart contracts. This parsed data includes the name of each function called along with parameter names/values passed to those function calls. This is useful for understanding how users are invoking a particular contract and also for detecting anomalous inputs to a given contract.
Columns
Column Name | Data Type | Description |
---|---|---|
id | bpchar(44) | The unique identifier for the contract call. |
consensus_time | timestamptz | The timestamp of the contract call's consensus time. |
transaction_hash | text | The unique hash of the transaction containing the contract call. |
known_abi | bool | Indicates if the ABI of the contract is known. |
metric_name | text | The name of the metric associated with the contract call. |
parameter_name | text | The name of the parameter associated with the contract call. |
parameter_type | text | The type of the parameter associated with the contract call. |
val | numeric | The value associated with the contract call. |
string_val | text | The string value associated with the contract call. |
args | jsonb | The arguments of the contract call. |
chain | text | The blockchain this contract call belongs to. |
contract_parser | public.contract_parser | The contract parser associated with the contract call. |
contract | text | The address of the smart contract. |
block_hash | text | The unique hash of the block containing the contract call. |
Examples
Get minimum and maximum transferFrom
values for an ERC20 token
with decimals as (
select (am.context->>'decimals')::int as decimals
from address_metadata am
where am.account = '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7'
)
select
time_bucket('1 hour'::interval, cc.consensus_time) as time,
min(lib_math.decimaled_amount(cc.val, d.decimals)) minimum_amount,
max(lib_math.decimaled_amount(cc.val, d.decimals)) maximum_amount
from contract_calls cc
cross join decimals d
where cc.consensus_time between now() - '12 hours'::interval and now()
and cc.contract = '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7'
and cc.metric_name = 'transferFrom'
and cc.parameter_name = '_amount'
group by time;
Note: this query uses our decimaled_amount function to convert from raw values to human-friendly decimal amounts.