Skip to main content

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 NameData TypeDescription
idbpchar(44)The unique identifier for the contract call.
consensus_timetimestamptzThe timestamp of the contract call's consensus time.
transaction_hashtextThe unique hash of the transaction containing the contract call.
known_abiboolIndicates if the ABI of the contract is known.
metric_nametextThe name of the metric associated with the contract call.
parameter_nametextThe name of the parameter associated with the contract call.
parameter_typetextThe type of the parameter associated with the contract call.
valnumericThe value associated with the contract call.
string_valtextThe string value associated with the contract call.
argsjsonbThe arguments of the contract call.
chaintextThe blockchain this contract call belongs to.
contract_parserpublic.contract_parserThe contract parser associated with the contract call.
contracttextThe address of the smart contract.
block_hashtextThe 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.