NaturalChain: Revolutionizing Blockchain Interaction Through AI (ETHGlobal Lisbon Hackathon)

Hey there! Over the past weekend, our team at Cenit Finance joined forces with our friend Jesús Ligero and participated in the ETHGlobal Lisbon Hackathon (May 2023) earning us eight different sponsor prizes, including the “Most innovative dApp” prize from Gnosis Chain.

Our project for the hackathon was NaturalChain, an AI toolkit for the Blockchain. At Cenit, we’ve been keenly following the incredible progress of language models these past few months, which is revolutionizing the way humans interact with machines. With NaturalChain, we wanted to bring that revolution into our ecosystem by giving Blockchain superpowers to Large Language Models (LLMs) like ChatGPT.

Over the weekend, we developed an AI agent capable of signing transactions, writing and deploying Smart Contracts, querying from APIs like The Graph and CoinMarketCap, as well as utilizing the full JSON-RPC API. You can ask it to do things for you like:

  • “Write and deploy a Smart Contract to Gnosis Chain that does…”
  • “What are the top pools in Uniswap that have X token?”
  • “Send X ETH to address…”
  • “How much of X token could I buy on Uniswap if I have Y DAI?”

Let us tell you all about it!

Create your own in-depth tokenomics simulations and get valuable insights in less than 15 minutes with the Cenit Simulator tool
Tokenomics design simulator

Powering up AI

Over the past few months, Large Language Models have showcased astounding advancements. The combination of high quantities of data, parameter size, and computing power used during training, seems to result in the emergence of capabilities like reasoning and planning. 

While many of us have been leveraging these capabilities to facilitate our daily lives and work, these models are limited to interaction through chat by default. They can answer our questions, but they can’t act directly. A possible solution to this is to teach the models to use tools with which to carry out our requests. OpenAI, the creators of ChatGPT, are already working on this with their release of ChatGPT plugins.

That is already a huge powerup for Large Language models, but we can go even further! LangChain is an up and coming Open Source framework for creating AI applications. Using it we can create our own tools for Large Language Models, and compose AI agents capable of using these tools.

This was our main objective with NaturalChain: bring natural language interactivity to the blockchain by creating tools that let Large Language Models like ChatGPT interact with the Blockchain and related applications.

The NaturalChain Toolkit

Throughout this hackathon we managed to create 8 different tools for interaction between Large Language Models and blockchain. We had ideas for many more, but time was limited! Our main focus was on interactivity with EVM-compatible chains, since we were at ETHGlobal. The tools we developed were:

  • RPC API tool: used for interacting with an RPC endpoint, from any EVM-compatible chain. Models like ChatGPT have “read” the API docs, so they know how to handle and make use of most functions in the RPC.
  • Coinmarketcap API tool: used for getting coin prices and other info from Coinmarketcap
  • The Graph tool: used for querying from subgraphs from The Graph using GraphQL. This one could be improved by combining it with an “address book” tool of useful subgraphs and their schema.
  • Signer tool: we gave the model access to its own private key, so it could use this tool to sign transactions in an EVM-compatible chain. We also want to add interaction with browser wallets in order to be able to handle and propose transactions for the user.
  • Smart Contract Writer: this is a particularly interesting tool, because it calls another LLM to handle the creation of a Solidity smart contract from a natural language description.
  • Smart Contract Compiler: used for compiling solidity into bytecode.
  • Smart Contract Deployer: used for deploying a Smart Contract into an EVM-compatible chain.
  • Calculator: we also added a calculator tool so that it could easily perform mathematical computations in order to transform inputs or outputs for the various other tools, which is useful for things like base transforms or unit changes.

Besides the actual code to execute these functions, each tool includes a natural language description of its utility in order to let the model know what it is used for. We found that the model understood very easily how to use each of the individual tools, handling multiple input parameters and, in some cases, complex output syntax. 

However, one of the main difficulties we encountered was how to make the model understand when to use one tool instead of another in a complex task flow. This required a lot of prompt engineering and interactive adjustment.

The NaturalChain Agent

So, how did we actually set up the model to make use of these tools? We set up an agent, which essentially means wrapping the user’s query to the model with pre-set instructions indicating how to handle the request and teaching the model what tools it has at its disposal and how to use them.

There are two main types of agents that can make use of tools: action-agents, which decide on an action to take (i.e. calling a tool) one at a time, and plan-and-execute agents, which first decide on a plan to solve the user’s query, and then execute that plan one action at a time. We could implement either for NaturalChain, but we decided to go with action-agents for the hackathon, which are good for small tasks and faster to execute, since they require less calls to the language model.

In either case, each consecutive “decision” by the agent is actually a call to a Large Language Model. In our case we decided to use the ChatGPT 3.5 API, since it is fast, cheap, and readily available. However, since we are using the LangChain framework under the hood, switching out to a different model would be just plug and play with a different API.

The diagram below shows how the various elements interact.

  1. The user sends a query to the agent, for example: “Write a smart contract for an ERC20 token named NaturalChain and deploy it on Gnosis Chain. Give me the contract address”.
  2. If the agent cannot solve the request directly, it decides on which action to take to achieve that by utilizing the available tools. For example, the Smart Contract Writer tool.
  3. Each call to a tool sends back an observation to the agent. In our example, this would be the path to the Solidity file that the Smart Contract Writer tool created.
  4. The agent uses the observation from the tool to decide on what to do next, which can either be another call to a tool, or to answer the user.
  5. The agent therefore chains calls to the various tools until it solves the user’s original request. Once done, it sends back the answer.

By combining and chaining all of the various tools, the agent is capable of answering complex requests, like creating and deploying a smart contract as in our example above.

Chat with the Blockchain

NaturalChain is designed as an extensible and composable framework for anyone to easily build their own tools and agents on top of. That said, we wanted to play with it ourselves! Therefore, for the hackathon we also created a very simple web app in Streamlit where we could interact with the agent using a chat interface, like ChatGPT. 

Here is an example of that:

And you can see the resulting contract yourself here:

The future of NaturalChain

In conclusion, the future is bright for NaturalChain! Our experience at the ETHGlobal Lisbon Hackathon has solidified our belief that AI and Blockchain together have immense potential to revolutionize the way we interact with technology. We're not just talking about making things easier; we're talking about empowering individuals, fostering creativity, and unlocking new possibilities.

We're excited about the progress we've made, but we're even more thrilled about the road ahead. We envision NaturalChain evolving into a tool that not only simplifies blockchain interaction but also acts as a bridge connecting more people to this revolutionary technology.

We're eager to continue expanding and refining our toolkit, integrating more powerful models, and experimenting with a variety of agents. But we can't do it alone. We invite you to join us in our journey by trying out our demo at and contributing to our open-source code at

In the meantime, we will continue leveraging these revolutionary tools in our own work modeling and stress-testing tokenomics at Cenit Finance. Stay tuned for more updates!