Call
export class Call {
constructor(
public to: Address,
public from: Address,
public block: Block,
public transaction: Transaction,
public inputValues: Array<EventParam>,
public outputValues: Array<EventParam>,
) {}
}
Fields and Use Cases
to
- Description: Address of the contract in which the function was called. This is equivalent to
event.address
anddataSource.address
. - Use Case: Used to filter and track specific contract interactions and create relationships between calls and contract entities.
from
- Description: The immediate caller address (EOA or contract) that executed the function call. Note that this may differ from
transaction.from
in cases involving contract-to-contract calls.- For direct calls: This will be the same as
transaction.from
- For internal calls: This will be the address of the intermediate contract making the call
- For direct calls: This will be the same as
- Use Case: Used to create relationships between calls and account entities, track user interactions, and analyze contract-to-contract calls in your subgraph mappings.
Example:
// When EOA1 calls contract1, which then calls function1 on contract2:
// For the function1 call:
call.transaction.from == EOA1.address // Original transaction initiator
call.from == contract1.address // Immediate caller
block
- Description: The block in which the function call was included.
- Use Case: Provides temporal context for calls, enables time-based analytics, and helps maintain data consistency during chain reorganizations in your subgraph.
transaction
- Description: The transaction in which the function call occurred.
- Use Case: Links call entities with their parent transaction entities and provides access to transaction metadata in your mapping functions.
inputValues
- Description: The parameters passed to the function call as input data, stored as an array of
EventParam
objects containingname
andvalue
pairs. - Use Case: Used to decode and process function arguments, filter calls based on specific parameter values, and create detailed analytics about contract usage patterns.
You can access input parameters in two ways:
// Method 1: Using array index and EventParam construction
const param = new ethereum.EventParam(
call.inputValues[0].name,
call.inputValues[0].value
)
const value = param.value.toString()
// Method 2: Direct access using parameter name (if known)
const value = call.inputs._parameterName
outputValues
- Description: The return values of the function call after execution.
- Use Case: Used to capture and index function results, create derived data based on contract responses, and track successful contract interactions.
You can access output parameters in two ways:
// Method 1: Using array index and EventParam construction
const param = new ethereum.EventParam(
call.outputValues[0].name,
call.outputValues[0].value
)
const value = param.value.toString()
// Method 2: Direct access using parameter name (if known)
const value = call.outputs._parameterName
Important Notes
- Function calls can be used alongside events to create a more complete picture of contract interactions in your subgraph.
- Input and output values can be accessed by name and cast to appropriate types in your mapping functions.