Member-only story
AI, Cryptocurrency, Ethereum, NFT
Enhancing Coinbase AgentKit with Hex Data Transfers Using Zod and Ethers.js for a New Formal Tool
Refining my previous post about on-chain Ethscription-style NFTs via the Coinbase AgentKit
A few days back, I explored adding hex data to Ethereum transactions via Coinbase AgentKit. (That article is here.) While functional, my initial approach relied on rigid prompt parsing. Today, I’ll demonstrate how to implement this feature more seamlessly via the LLM using Zod, a schema validation library, and the AgentKit’s tool-based architecture.
With a surprisingly low amount of refactoring, I was able to implement this same functionality as a new “tool” in the AgentKit — which is the more formal and recommended approach of doing this. So, I wanted to talk about that today briefly.
Why Zod Matters
Mainly, I was missing Zod, which ensures that all input data conforms to a predefined schema, combining TypeScript’s compile-time safety with runtime validation. For LLM-driven applications, this eliminates ambiguities, ensuring robust and predictable tool execution. That is to say, using Zod literally allows AgentKit to interact with the LLM. (I’ll touch on this a bit more, below.)