skip to content

A Cognitive Layer for Web3

/ 8 min read

Read the full article on Moonsong Labs

Introduction

If you have read the two previous installments of this series, you will know by now that we started Unravel.wtf to test how LLMs would perform in intent decoding for Ethereum transactions. Unravel uses AI to analyze transactions by examining contract sources and deriving human-readable explanations of their intent, allowing us to compare the usefulness of LLM predictions against current state of the art algorithmic labellers like Etherscan.

A secondary objective was to acquire hands on experience in the challenges involving:

the ability to recognise user intents from transaction inputs (what outcome was the user trying to accomplish) the ability to interpret contracts and functions as actions to address user intents (how did a contract call contribute to addressing an intent) One of our assumptions was that the real value of decoding transaction intents might reside in the data we acquire through it, which would be extremely useful for the reverse journey, that is predicting and actioning users’ intents as on-chain actions.

As you saw in our previous blog post, whenever we Unraveled a transaction, we would interpret each new contract (version) and functions to derive a much more dense intermediate representation including its stated goal and how it can be used as part of an intent.

This intermediate representation provided a compressed set of signals useful in multi-call intent inference, both to minimize hallucinations, reducing latency and context size.

This same intermediate representation however is in itself valuable, as it can be searched by an LLM looking to action a user intent.

The Agentic Cognitive Layer

Large Language Model Actions and the autonomy they offer to developers, in particular with patterns like “agent-oriented programming”, has been an area of research and high conviction for us.

In our previous writings, we refer to this part of the stack as the LLM integration layer of these new types of applications, or to use a more evocative term, the cognitive layer of LLM applications. This layer, alongside the application logic, is where developers can add the most value in harnessing intelligence in genuinely useful ways.

A helpful way to conceptualize how most agentic libraries (or custom implementations) model this layer is to imagine it as a graph. In this graph, each agent is a vertex. An agent functions as a client of a large language model (LLM), sending inputs and receiving outputs. It has a defined role within the system (imagine a prompt) and some degree of memory, either short-term or long-term. Agents are “connected” to other agents or tools via edges.

Tools or plugins also act as vertices, representing internal or external instructions that agents can act upon to gather information or execute code (e.g., vector search, code sandbox, web search, etc.).

Edges connect agents and tools, allowing them to delegate tasks to other agents or invoke tools to perform specific actions. The set of tools available to an agent is often called its “action space” which encompasses the range of options the agent can consider in order to fulfill its objectives.

Agent Graph

Now with this simplified definition, you can already imagine how giving the ability to an agent to search among options or dynamically retrieve information allows you to build systems with new levels of autonomy:

Automation Levels

within fully observable and constrained environments (think of a system able to select among just a few options, like a list of allowed contracts) or in dynamic environments (think of a system capable of partially observing the environment first to search for relevant information and options), closer to what we would refer as full autonomy ​​

This cognitive layer holds incredible potential both to serve Web3 as a new interaction paradigm and as a consumer of Web3 services, let us make the case for it.

A case for a cognitive layer using Web3

Some of the core principles of blockchains revolve around three key capabilities:

  • Open and transparent networks: Facilitating permissionless participation
  • Programmable settlements: Enabling value representation and exchange of any type
  • Permissionless runtime composability: Allowing seamless runtime contract to contract composability

Blockchains sacrifice some of the conveniences of vertically integrated systems in exchange for a unified, standardized settlement layer. This layer, built around permissionless accounts and system-wide interoperability, provides a foundational infrastructure that would be extremely difficult for any individual developer to create independently and hard to bootstrap even for large incumbents (without some obvious incentive misalignments, e.g. App Store).

However, realizing the value of these properties is not straightforward. What makes a system flexible often introduces complexity. Today’s critique of Web3 is that it is both daunting (and noisy!) to navigate for users and hard to work on as developers, and this is somewhat a reflection of its fundamental design that also makes it compelling.

What if we have looked at it incorrectly, what if the extreme transparency and composability that might get in the way for human interfaces is simply a perfect playground for machine to machine interactions?

In machine learning, a simple principle to extrapolate progress is that anything that can be measured, can be learned. By interpreting (“unraveling”) on chain actions and data through a denser intermediate representation, we can open up blockchains to be universally accessible and directly useful to the agentic cognitive layer.

An LLM ready representation can give developers and machine learning engineers (not just web3 developers) a fertile playground to push the boundaries of agentic action autonomy and native economic interactions. This can work with today’s frameworks and AI models (and their present context size limitation).

Web3 offers great advantages to many top-of-the-stack use cases experimenting with this level of autonomy. A key point worth stressing, this intermediate representation – what makes any on-chain action easily accessible by an agent as a “tool” – is possible only because of some of the properties that web3 offers.

For example:

  • In blockchains, we can provably tie the code with its run time, rooting the action intent interpretation to a direct code analysis of the code that will be invoked with the action.
  • In blockchains, we can predict and iteratively refine (via reinforced learning) what state change the code will affect, using the execution flow & data that contract has generated in its entire history (imagine doing that with a proprietary API you don’t own).
  • In the short term, while prediction accuracy might be good for action selection but perhaps not sufficient for a user or system value exchanges, we even can simulate (with tools like Anvil) the full transaction execution on a parallel production branch of the network to introduce human supervision.

Alongside an LLM ready action and data space, blockchains already come out of the box with:

  • the ability to create and control smart contract wallets across most EVM chains (an agent can be, and own things across state machines on behalf of the developer)
  • the ability to design a provable derivative identity tied to the legal entity behind it (ENS) to facilitate Agent to Agent economic activity
  • the ability to send and receive value, easily manage a budget and deploy that budget to other services

Conclusion

Our work with Unravel highlights the large potential at the intersection of AI and Web3 and re-affirms our direction of travel with our Venture Studio. Through decoding Ethereum transactions, we’ve found that LLMs have the capability to transform complex blockchain data into human-readable formats, making it accessible to everyday users. As the permissionless nature of blockchain outpaces the precision of algorithmic labeling, a learned approach – using Machine Learning to infer labels – is likely to prevail in the long term.

We also shared insights on measuring and engineering for quality when developing LLM applications and shed some light on the challenges involved in interpreting on chain contract data and the present need of intermediate representations.

Looking ahead, we can see a future where an LLM-friendly data and action space for Web3, combined with its existing machine-native properties that comes out of the box, can enable a compelling platform for autonomous agent systems, more so than any alternatives we have explored so far.

Anything that is measurable, will be eventually learned by a neural network if there are strong enough incentives to do so, and blockchains are fully observable by design, is just a question of when!

Every platform shift presents an opportunity to reshuffle the stack and compete for new aspects of the emerging value chain. We believe agentic systems will inevitably move towards autonomy and will drive large amounts of economic activity. The stack that powers value exchange between agents is going to be a critical battleground, we think blockchains and startups in our space have a credible chance to underpin it.