Create a getPublicClient function that accepts a chain ID and returns an object with ViemPublicClient.
For detailed configuration options and trace API settings, see the RPC Provider documentation.
2. ABI Data Store
The ABI Data Store handles:
Fetching ABIs using predefined strategies (e.g., Etherscan, 4byte). Some strategies like Etherscan require an API key. See the full list of strategies in Data Loaders (ABI Strategies)
Caching fetched ABIs
To create a custom ABI Data Store, implement the VanillaAbiStore interface:
Example: an ABI data store with Etherscan and 4byte data loaders and in-memory cache
3. Contract Metadata Store
The Contract Metadata Store handles:
Fetching contract metadata using predefined strategies (e.g., ERC20, NFT). See the full list of strategies in Data Loaders (Contract Metadata)
Caching fetched contract metadata
To create a custom Contract Metadata Store, implement the VanillaContractMetaStore interface:
Example: a Contract Metadata Store with ERC20 data loader and in-memory cache
4. Initializing Loop Decoder
Finally, you can create a new instance of the TransactionDecoder class:
Example: Decoding a Transaction
Once the TransactionDecoder is set up, you can use it to decode a transaction by calling the decodeTransaction method:
Check the full expected output in our Playground or see it below:
Try it live
Try decoding the above or any other transactions in the our playground here.