Build Trading Agents on Base
Base·Thu, Apr 9, 2026, 12:00 AM
Learn how to build LLM-based trading agents on Base Links: README: https://github.com/base/demos/blob/master/agents/trading-agent/README.md SKILL: https://github.com/base/demos/blob/master/agents/trading-agent/SKILL.md #OnchainAppInsights #web3 #accountabstraction #erc4337 #onchain #onchainApps #gasless #base #basechain #coinbasewallet #crypto #web3 #apps #blockchainrewards #openclaw #clawdbot
Transcript
Hi everyone and welcome to this video where we will be talking about building trading agents on base. And so if you think about trading bots, they've existed since forever. We talk about MEV bots for example that arbitrage certain assets on chain. You can think about algorithmic trading and all of these bots usually are deterministic, they're algorithmic and they don't involve LLMs making decisions. This is a different pattern that I will be talking about today.
So this trading agent that we will be showing in this video uses LLMs to scan and make decisions about the the strategies. This is very experimental of course and I definitely would not recommend that you use this at least in the form that it is today in production. So you should definitely make sure that you test it more and more and more, but this is to kind of talk about what can you do in terms of experimenting with LLMs trading on base. And so I have this tool that I created that allows you to scaffold a very simple LangChain agent that can connect to multiple tools and protocols on base. And so let's see what it looks like and go through the flow of getting this set up.
So I'm opening a terminal here and I will be running the instructions that are detailed in this doc. Following just the readme that I'm sharing with you in the comments below. And so now that we have this npm install and then I will be running npm run dev and you will see the flow of scaffolding these agents. And so this is what it looks like. This is how the scaffolding tool looks like.
So we will be choosing um a name. So, let's call it perhaps uh trading agent one. The tool shows you three choices, either CDP server wallet, banker, or sponge wallet. I will be choosing CDP server wallet here, but just for example, if you choose banker, there are no more protocols that you would need to integrate. And if you choose sponge, uh there are maybe other tools that you can add, namely data tools.
Uh so, some of these wallets have integrated protocols and data tools. Some of these wallets come with the bare-bone kind of like infrastructure to interact with any protocol and any tool. I'll be using CDP wallet just to show you the vast amount and number of tools that are available that you can interact with. Uh and so here we have multiple protocols and tools. Uh CoinGecko, CoinMarketCap for data, Alchemy also for data.
Uh this uses X402 to pay for um the API. And so, AgentCash, for example, has multiple APIs that you can uh interact with and pay with uh using X402 and USDC. Nansen as well, AirDrop. So, let me choose, for example, Uniswap and let's say CoinGecko, okay? And so here, you would be putting your LLM provider uh API key afterwards.
Uh and let's see, let me choose OpenAI, for example. Uh let me choose GPT-4. And then, I will put the OpenAI key and show you the next steps. Okay, I got my OpenAI key. I'm just putting it here.
and then I'm using test mode here because this test mode just does more trades, gives you access to maybe even like with higher risk execution, and then you can put very little money for you to test some of your strategies. Uh and then this tool actually allows you to create self-updating agents. So, agents that update their own strategy following the data that they get from the market. Let's say yes. And then this gives you a strategy evaluation interval.
Um let's say, you know, 5 minutes. And then now you get to describe your trading strategy. I will describe a very simple trading strategy uh like follow the trend on ETH. And then using your key, there will be a critique that happens to your strategy and refinement and making it more uh I guess explicit with better guardrails. Uh and so, you can edit this refined strategy, you can approve it.
And then here, uh you can configure any additional experimental custom tools. Uh and you can add docs, you can add skills uh if you want some other tools to to have access uh with your agent. And so, I will say no here, and then there's an output directory that was created. And in the output directory, we will go and we will run it in a second. So, here you can see the output directory that we have.
Um you have an env example file to fill up uh all the other API keys that are necessary for your agent to run. And then you have the tools uh and you have, you know, multiple tools here that you selected. So, we selected Uniswap and we selected CoinGecko as as the tools that we want. Uh and so, yeah, you have scripts and this is your strategy file, uh which will be updated by the agent. Let's run a simple npm install and npm start to see how it works.
I'm done with the installation and I also updated the .env file that I'm not showing here for clear purposes and we can start the agent. So, we hit npm start. And with the first iteration of this agent, uh we will see that the agent, you know, spins up a wallet. The wallet has no uh ETH or USDC and we would need to fund the wallet to start the um strategy going.
And so, I will stop here, but as you can see, uh the agent is running. Uh you can put in some funds in the wallet that the agent uh spins up using CDP server wallets and then uh the agent will be executing trades in this case using Uniswap and fetching data using CoinGecko. And yeah, so this is uh this is pretty much uh the gist of it of how it works. Uh obviously, this is still very experimental and you should be very careful putting any amount of money in this tool, but this is the beginning of the exploration for you. Uh the goal is that maybe you can use your coding agents to update this LangChain agent to make it more efficient.
Uh you can think of a world where your LLM-based agent uh is the one that's writing code to develop more comprehensive, execution-optimized trading bots. Uh let me know what you think about this and see you soon in the next video.
Automatic transcript — names and jargon may be misspelled.