RPC Client
ctc.rpc
is a low-level asynchronous RPC client that implements the EVM JSON-RPC standard. This standard consists of many methods such as eth_call
and eth_getCode
that query current and historical states of an EVM chain.
Implementation of Methods
For every method specified by the EVM JSON-RPC standard, ctc.rpc
implements five python functions:
constructor function: create method requests
digestor function: process method responses
executor function: perform construction, dispatching, and digestion all in one step
batch construct: create method requests in bulk
batch execute: execute method requests in bulk
(there are no batch digestor functions because they compose naturally from the scalar digestor functions)
RPC Providers
Unless otherwise specified, requests will be sent to the default RPC provider in ctc
’s config. Functions in ctc.rpc
that send RPC requests also take an optional provider
argument that can be used to specify other RPC providers.
For more details, see the RPC Provider section on the Data Sources page.
Typical RPC Request Lifecycle in ctc
a constructor function encodes request metadata and parameters into a
RpcRequest
pythondict
the request is dispatched to an rpc provider using
rpc.async_send_http()
the client
await
s until the rpc provider returns a responsea digestor function decodes the response
For requests that execute contract code (like eth_call
) or retrieve events (like eth_getLogs
), ctc
will encode/decode inputs/outputs using the relevant function abi’s and event abi’s.