Conversational AI Agent with Blockchain Actions on Rootstock
Imagine being able to ask your app, “What’s my token balance?” or “Send 0.01 tRBTC to this address,” and it just… does it. No forms, no buttons—just a conversation with an AI agent that knows how to talk to the blockchain.
In this guide, we will build a lightweight dApp that connects a conversational AI agent to the Rootstock testnet, allowing users to perform DeFi actions like checking token balances and sending tRBTC simply by chatting. This is not just a chatbot—it is a minimal DeFi agent that can reason over wallet data, maintain conversational context, and issue token actions with a human-like touch.
The tech stack used in this tutorial is:
- NextJS as the development framework.
- The Rootstock Next Reown starter kit and Wagmi to handle wallet connections and blockchain interactions.
- Groq’s LLM API, for the natural language interface.
- Shadcn as UI library.
What you'll learn
By the end of this tutorial, you will have:
- A connected wallet UI running on Rootstock testnet
- A chat interface powered by an LLM (via Groq SDK)
- A fully functioning AI agent that can interpret user intent and call blockchain methods accordingly
Let’s dive into how AI and decentralized infrastructure can come together in a single-page app with real utility.
Prerequisites
Ensure you have the following installed:
- Node.js (v18+)
- Git
- A browser wallet like MetaMask connected to the Rootstock Testnet
- Some basic familiarity with Javascript/Typescript and smart contract interaction
Project Setup
Clone the Rootstock Reown & Next Starter Kit. Reown (previously WalletConnect) is a really popular tool in the web3 ecosystem that abstracts the wallet connection and management in decentralized applications (dApps). This starter kit comes already configured with Wagmi, Shadcn and Rootstock networks - testnet and mainnet.
Clone the project:
git clone https://github.com/rsksmart/reown-next-starter-kit.git
cd reown-next-starter-kit
Proceed to install dependencies:
npm install
# or
bun install
Find the full source code in the 🔗 AI Agents Rootstock GitHub repo Feel free to clone it, fork it, and build further on it.
Set up Environment Variables
Create a .env.local
file and set your environment variables based on the .env.example
file. You will find four of them:
NEXT_PUBLIC_PROJECT_ID
from Reown. Get it on Reown Cloud.NEXT_PUBLIC_RPC_MAINNET
is the mainnet RPC URL. Get it on the RPC API service.NEXT_PUBLIC_RPC_TESTNET
is the testnet RPC URL, also available at RPC API service.GROQ_API_KEY
that you can get at Groq’s website for free.
When the .env.local
file is ready then you can test if everything is on point by running the project.
npm run dev
# or
bun dev
If there is no error and the app is running correctly on the server, we are ready to start the project.