- squid-evm-typegen
- squid-substrate-typegen
- squid-ink-typegen
In order to make on-chain calls, one must set up a JSON-RPC endpoint using setRpcEndpoint(). We recommend using a private endpoint from e.g. BlastAPI or the SQD Cloud’s RPC addon, and set it via an environment variable:You can define the
The EVM contract state is accessed using the Now suppose we want to query our contract from the batch handler. To create a The arguments are as follows:
RPC_ETH_HTTP in three ways:- for local runs, simply update the local
.envfile; - for squids deployed to Cloud define it as a secret on your Cloud account;
- if you are using the RPC addon, leave it to the Cloud to define it for you.
Contract class
The EVM contract state is accessed using the Contract class generated by squid-evm-typegen. It takes a handler context and a contract address as constructor arguments. The state is always accessed at the context block height unless explicitly defined in the constructor.For example, assume that we index an ERC721 contract. Typescript ABI module generated with squid-evm-typegen will contain the following class:Contract pass the context object and the current Block to its constructor, then query the contract state at that block:Batch state queries
The MakerDAO Multicall contract was designed to batch multiple state queries into a single contract call. In the context of indexing, it normally significantly improves the indexing speed since JSON RPC calls are typically the bottleneck.Multicall contracts are deployed in many EVM chains, see the contract repo for addresses. You can use any of them with amulticall Typescript module that is generated when running squid-evm-typegen with --multicall option. The module exports a Multicall class with this method:func: the contract function to be calledcalls: an array of tuples[contractAddress: string, args]. Each specified contract will be called with the specified arguments.pagingan (optional) argument for the maximal number of calls to be batched into a single JSON PRC request. Note that large page sizes may cause timeouts.
src/main.ts