Skip to main content

Tx Explain: Open-Source AI Agent for EVM Transactions

· 4 min read

tx-explain.jpg

AI Agents are poised to take over the world. If you buy into the hype, they will be autonomous users of blockchains handling a huge variety of goals for users. OK, they probably won’t be taking over from hyper-optimized MEV bots any time soon, but AI Agents can already execute on trading strategies and simple defi interactions. And, by the way, they can even self-learn as Voyager taught us.

Introducing Tx Explain; an agent-like service that takes a transaction and returns a human-readable explanation. The code is open-source and available now:

AI Agents and Crypto

Agents are applications that take actions on behalf of users using LLM outputs. In the strictest definition, an Agent autonomously executes towards a user’s goal.

In the context of a game like Minecraft, Agents may repeatedly experiment and iterate towards a goal like crafting a certain item. But mistakes are expensive in crypto! There is an inherent risk combining indeterminate outputs from LLMs with deterministic systems of value.

As a community, we obviously aren’t comfortable letting Agents loose with our MetaMask accounts, but how do we get there? We could start with tools for LLMs to better understand their actions and give them the potential to generate combinations of actions with smart contracts.

Tx Explain, or what does this transaction do?

Ethereum transactions are not optimized for humans. They are optimized for the EVM, using techniques like hexadecimal encoding for function names and their parameters. Humans and current generation LLMs struggle to understand the raw transaction data, so the first challenge is to consistently generate human-readable outputs from EVM transactions.

Tx Explain accepts a transaction and returns a summary of the transaction as a zero-shot interaction.

Let’s look at an example of stETH staking on the Morpheus project. Tx Explain provides the following summary:

This transaction involves a user staking 0.18 stETH (Lido Staked Ether) on the Distribution contract through an ERC1967Proxy contract. The transaction is successful, and the staking operation is executed as expected.

Key Steps:
- The user (0x35f1bae79c4e74ee25354d326b42f809744f7e18) calls the `stake` function on the ERC1967Proxy contract, providing the pool ID (0) and the amount to stake (0.18 stETH).
- The ERC1967Proxy contract retrieves the implementation address (0x24c09a0c047e8a439f26682ea51c7157b3ccc20b) and forwards the `stake` call to it.
- The Distribution contract's `_getCurrentPoolRate` function is called to get the current pool rate.
- The Distribution contract's `_stake` function is called, with the user's address, pool ID, stake amount, and current pool rate as parameters, to execute the staking operation.

Technical Methodology

With a transaction hash, Tx Explain looks up the transaction object, simulates the transaction, including decoding logs and traces, then applies tags to addresses and inserts smart contract code if available. This context is passed to an LLM as a JSON object and a system prompt with instructions of what kinds of details to output.

Most of the technical work involves crafting a suitable prompt, collecting the right level of detailed data, evaluating the responses and iterating on the inputs. Different models handle the requests differently (just as humans might).

Compare these results to Etherscan, and even experienced blockchain analysts can benefit from using Tx Explain to better understand what a transaction actually does.

Accelerating AI for EVM Users

We are releasing TX Explain for free in its Beta form as just a first step towards creating the robust and reliable Smart Agents of the future.

While we already think this has enormous potential as both a research and security tool, we're even more excited about using TX Explain as a building block for creating safer and smarter models and autonomous agents.

Please use the tool to better understand transactions on the EVM chains of your choice and provide feedback via the in-built feedback form. We'll be continuously improving this tool over time.

Stay tuned as we bridge the open-source AI and crypto communities to build out the future of Smart Agents!