Data Loaders
Data Loaders are mechanisms designed to retrieve the required ABI and Contract Metadata for transaction decoding. Internally, they automatically batch and cache requests when processing logs and traces in parallel. Users are encouraged to create a persistent store to cache data, thus avoiding unnecessary API requests. Additionally, the custom store should include all proprietary contracts.
The AbiStore
and ContractMetadataStore
accept strategies that resolve data from third-party APIs when the data is missing from the store. Upon successful resolution, the data is cached in the store to prevent unnecessary API requests in the future.
The Loop Decoder implements various optimizations to reduce the number of API requests made to third-party APIs. For instance, if the ABI of a contract is resolved from Etherscan, the ABI is then cached in the store. Subsequently, if the ABI is requested again, the store will return the cached ABI instead of making another API request.
Contract metadata
Contract metadata is a collection of information about a contract, such as the contract’s name, symbol, and decimals.
Loop Decoder provides some strategies out of the box:
ERC20RPCStrategyResolver
- resolves the contract metadata of an ERC20 token from the RPCNFTRPCStrategyResolver
- resolves the contract metadata of an NFT token (ERC721, ERC1155) from the RPCProxyRPCStrategyResolver
- resolves the contract metadata of a Gnosis Safe proxy contract from the RPC
ABI Strategies
ABI strategies will receive the contract address, and event or function signature as input and would return the ABI as a stringified JSON. Loop Decoder provides some strategies out of the box:
EtherscanStrategyResolver
- resolves the ABI from EtherscanEtherscanV2StrategyResolver
- resolves the ABI from Etherscan v2SourcifyStrategyResolver
- resolves the ABI from SourcifyFourByteStrategyResolver
- resolves the ABI from 4byte.directoryOpenchainStrategyResolver
- resolves the ABI from OpenchainBlockscoutStrategyResolver
- resolves the ABI from Blockscout
You can create your strategy by implementing the GetContractABIStrategy
Effect RequestResolver.