Create specialised onchain AI Agents
This is a 'Part 2' to the "Create an AI Agent with Replit & AgentKit" post
TLDR:
This post is a follow up to last week’s post where we created an onchain AI Agent with Coinbase’s AgentKit template for Replit, you should read that post first.
Starting from the Replit template we show how to create two different onchain agents: (1) wallet activity notifier; (2) smart contract analyser.
By using the Replit AI we can first get it to plan the development and then build the agent without needing to write any code ourselves.
With this knowledge you can go and create your own specialised onchain AI agent making something as simple or complex as you’d like.
Last week I showed how to create an onchain AI Agent with AgentKit and Replit, and I ended the post saying that in a future one I’d probably come up with some creative ideas of how you could specialise your agent.
Well you’re now reading that future post as I decided to continue from where I left off and create a couple of specific agents with the help of Replit’s AI.
If this post resonates with you and you enjoyed the content then please share it with friend and get rewarded for doing so!
This blog goes out weekly to almost 10,000 subscribers. Please message me if you’re interested in sponsorships or partnerships.
Onchain AI Agent
Last week I ran through how to create your very own onchain AI Agent with Replit and AgentKit.
If you didn’t check out last week’s post then I recommend doing so because today’s is essentially a part two that builds on top of what we did last week.
In that post we set up AgentKit’s templated onchain AI agent with Replit, and we ended up with an onchain agent who could perform a wide range of actions as shown below:
However, we’d not customised our agent beyond the templated version, and so today I decided to go one step further and show you how to make your agent more specialised, specifically we’ll make two different types of agent:
Wallet activity notifier - ie. an agent that tracks a wallet and notifies the user of any transactions that wallet does.
Smart contract analyser - ie. an agent that reads a smart contract and explains to you what the contract does in plain English.
If you did read and follow on with last week’s post then your starting point should look something like this with your base agent working on Replit with two available modes called “chat” and “auto”.
Now lets go and make these two specialised agents.
Wallet Activity Notifier
The goal for this agent will be to watch a specific onchain wallet address and generate notifications when it transacts. This is great for tracking many sorts of wallets such as personal wallets, whale wallets, influencer wallets, and so on.
So I started by asking the Replit AI to help us, first I put it in “Plan” mode so that I could speak with it without it building something for me immediately.
Next I needed to ask the Replit AI how to make our wallet activity notifier, so I asked the following:
“I want to make our agent able to track a specific onchain wallet address and when that address does something it’ll create a notification and be able to take a specific onchain action. Can you build a plan to implement this?”
This led it to build a comprehensive plan for implementing wallet tracking with automated notifications that it laid out like this:
This first plan it came up with seemed very robust but also quite complex and full of superfluous implementation details like notifications through both email and SMS. So I made a follow up request still in “Plan” mode:
“Can you refine the plan and come up with something much simpler please, where you’ll be able to implement it without too much complexity or moving pieces being introduced.”
Replit’s AI came up with a great suggestion of having a 3rd mode beyond the current “chat” and “auto” modes that would be called “monitor”.
In its own words this implementation was much simpler introducing some only 50 lines of code and giving all these benefits:
I thought this was much better and went with that by switching into “Build” mode and typing - “This latest plan is great can you please implement it”.
It then took around 3-5 minutes to go through and create this 3rd mode called “monitor” that appeared as below in the console:
However, after selecting “3” and inputting my own afox.eth address I got the following:
Noticeably the agent complained saying: “I currently cannot access transaction data directly. You can get this information by using a blockchain explorer for Base Sepolia or implementing it yourself using the CDP SDK. I recommend checking out the documentation at docs.cdp.coinbase.com for more information on how to retrieve transaction details.”
So I asked the Replit AI to fix this error using the CDP SDK, and after another 3-5 minutes it came back saying that it had successfully implemented the integration!
When I tried to select “3” and input my own afox.eth address again a new error came up and I did the same thing asking Replit to fix the error. Finally after a couple of follow ups with the Replit AI it fixed all the errors and worked as intended:
As a test I made a transaction that sent ETH over to the agent’s own wallet - 0x31889b805eCcAc3a4eBa8Eb1479edd99b0294B3D, and it gave the following output:
Success!
As you can see through prompting the Replit AI we successfully created an agent mode that can monitor a specific wallet for onchain transactions, and we could easily make it take a follow up onchain action after that if we wanted to.
For now though let’s move onto the second agent type.
Smart Contract Analyser
The goal with this next mode was to get the agent to be able to read a smart contract live on chain and tell us what it does in plain english.
So I began by asking the Replit AI to make a new 4th mode called “analyser”, with the specific request as such:
Ok now let’s plan for a 4th mode that we’ll call “analyser” that will take a smart contract address and return in plain english what it does. For example if its a token smart contract it will say the name, the number of tokens, and the rest.
And I got the following output:
This looked good so I switched the Replit AI into “Build” mode and let it do its thing, this time it took some 16 minutes and it clearly showed that there were lots of code changes and it was quite a costly operation!
Importantly though our “analyser” mode had been created and it got it right first time.
So I then had our onchain agent go into “chat” mode to create an ERC20 contract for a token called “Analyser” and an ERC721 contract called “AgentKitNFT”.
As you can see below I needed a couple of prompts because of some internal error, but I ended with these two contracts created:
Now I selected the new “analyser” mode inputting those very same contracts that I’d just created, starting with the Analyser ERC20 token, and got the following output:
This output was great, I then ran the same analysis for the NFT contract created, which also accurately described the NFT contract as shown below:
In summary this agent mode we created allows the agent to read any onchain token contract address and generate a simple explanation of what that contract does.
What we created here is great for non-technical people trying to understand any smart contracts they plan on interacting with.
Now you can make your own Agent
Now that you’ve seen how you can use Replit and AgentKit to make your own highly specialised agent you can go and do the same yourself!
As long as you’re not trying to make your agent super complicated its quite simple to do, as I showed above, and if you do want to do something more complicated then its entirely possible too, much as we’ve done with our own AI Agent platform Yield Seeker.
Yield Seeker began with us building off of AgentKit, and we’ve since built out an entire platform with over 2000 live agents and counting. These agents are highly specialised and can do complex juggling of USDC funds between DeFi pools for users.
However, its important to note that building a platform like this is a lot more complex than what we did above as you’ll need to write code and you won’t be able to just rely on the AI.
Nonetheless, you now know how to make your own specialised onchain AI Agent with the help of Replit’s AI and can go much further than what we originally discussed in last week’s post - use your newfound knowledge wisely!
Whenever you’re ready, these are the main ways I can help you:
Want high returns? Earn up to 14% APY with Yield Seeker!
Love Web3 insights? Follow @afoxinweb3 on X!
New to crypto? Join our beginners community to master crypto fast!
Building a Web3 app? Get our expert product development support!