Integrating Zetrix with Crossmint’s GOAT SDK for AI agents: A Technical Walkthrough
In this article, we’ll explore how to use the Zetrix plugin through Crossmint’s GOAT SDK. This allows developers to build AI agents that…
Integrating Zetrix with Crossmint’s GOAT SDK for AI agents: A Technical Walkthrough
In this article, we’ll explore how to use the Zetrix plugin through Crossmint’s GOAT SDK. This allows developers to build AI agents that are able to execute on-chain actions on Zetrix from leveraging AI-driven interactions through Vercel’s AI SDK.
What is Crossmint’s GOAT SDK?
Crossmint’s GOAT SDK is a framework that enables developers to build AI-powered agents capable of executing on-chain actions through various blockchain integrations. By creating a plugin for Zetrix, we allow these AI agents to interact with the Zetrix blockchain, facilitating transactions and other blockchain operations seamlessly.
Building the Zetrix Plugin for GOAT SDK
To integrate Zetrix with GOAT SDK, I built a plugin that essentially acts as a wrapper around the zetrix-sdk-nodejs package. This wrapper simplifies interactions with Zetrix’s blockchain by exposing functionalities in a way that aligns with GOAT SDK’s tooling system. By doing so, developers can seamlessly incorporate Zetrix on-chain actions into their AI-powered agents without needing to handle lower-level blockchain interactions manually.
Setting Up the Zetrix Chain Plugin
To integrate Zetrix with GOAT SDK, we use the zetrix-sdk-nodejs package along with @goat-sdk/wallet-zetrix to enable wallet interactions. Below is a sample implementation demonstrating how to initialize and use the plugin.
import readline from "node:readline";
import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";
import { getOnChainTools } from "@goat-sdk/adapter-vercel-ai";
import { zetrix, sendZETRIX } from "@goat-sdk/wallet-zetrix";
import ZtxChainSDK from "zetrix-sdk-nodejs";
require("dotenv").config();
(async () => {
const sdk = new ZtxChainSDK({
host: "test-node.zetrix.com", // "node.zetrix.com" for mainnet
secure: true,
});
// Get on-chain tools for Zetrix wallet
const tools = await getOnChainTools({
wallet: zetrix({
zetrixSDK: sdk,
zetrixAccount: process.env.ZETRIX_ACCOUNT as string,
zetrixAccountPrivateKey: process.env.ZETRIX_ACCOUNT_PRIVATE_KEY as string
}),
plugins: [sendZETRIX()],
});
// Create a readline interface
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
while (true) {
const prompt = await new Promise<string>((resolve) => {
rl.question('Enter your prompt (or "exit" to quit): ', resolve);
});
if (prompt === "exit") {
rl.close();
break;
}
console.log("\n-------------------\n");
console.log("TOOLS CALLED");
console.log("\n-------------------\n");
try {
const result = await generateText({
model: openai("gpt-4o-mini"),
tools: tools,
maxSteps: 10, // Maximum number of tool invocations per request
prompt: prompt,
onStepFinish: (event) => {
console.log(event.toolResults);
},
});
console.log("\n-------------------\n");
console.log("RESPONSE");
console.log("\n-------------------\n");
console.log(result.text);
} catch (error) {
console.error(error);
}
console.log("\n-------------------\n");
}
Understanding zetrix and sendZETRIX
The zetrix function initializes a wallet client for the Zetrix blockchain. It acts as a wrapper around the zetrix-sdk-nodejs, enabling seamless interaction with the blockchain. The ZetrixWalletClient class extends WalletClientBase from GOAT SDK, providing functionalities such as:
- Retrieving the wallet address (
getAddress) - Signing messages (
signMessage) - Submitting transactions (
sendTransaction) - Checking the balance of an address (
balanceOf) - Fetching the nonce for an account (
getNonce)
The sendZETRIX function is a plugin that allows the AI agent to send the native ZETRIX coin. It extends PluginBase and defines a tool for sending the native coin. This tool:
- Takes recipient address (
to) and amount (amount) as input - Builds the transaction blob
- Signs the transaction
- Submits the transaction to the Zetrix blockchain
- Returns the transaction hash as confirmation
Understanding *generateText* from Vercel’s AI SDK
The generateText function from Vercel’s AI SDK is a key component of our implementation. It processes user prompts, interacts with AI models (like OpenAI’s GPT-4o-mini), and utilizes defined tools (such as the Zetrix wallet plugin) to execute blockchain actions.
Parameters Explained
**model**: Specifies the AI model being used (in this case, OpenAI’s GPT-4o-mini).**tools**: A collection of tools that the AI agent can use during execution. Here, we pass in the Zetrix wallet tools.**maxSteps**: Determines the maximum number of tool invocations allowed per request. If set to10, the agent can call on-chain tools up to ten times before completing the response.**prompt**: The user’s input that the AI processes.**onStepFinish**: A callback function that logs the results of each tool invocation, helping to track interactions.
How It Works
- The AI model processes the user’s prompt.
- If necessary, it calls tools (such as
sendZETRIX()) to execute on-chain transactions. - The
onStepFinishcallback logs intermediate results. - Once execution is complete,
generateTextreturns a response containing the AI’s text output and any relevant transaction details.
Conclusion
This integration showcases how developers can leverage AI-driven blockchain interactions using Vercel’s AI SDK and Crossmint’s GOAT SDK. By implementing a Zetrix plugin, we enable seamless execution of blockchain actions within AI-powered applications.
If you’re interested in building on Zetrix or expanding AI-agent capabilities, this setup provides a strong foundation to get started!
I will be adding further functionalities and refactoring the GOAT SDK for Zetrix, so stay tuned for updates!
메타데이터
- post_id
- 44e5a9b228cd
- slug
- integrating-zetrix-with-crossmints-goat-sdk-for-ai-agents-a-technical-walkthrough-44e5a9b228cd
- url
- https://medium.com/@izadimrantan/integrating-zetrix-with-crossmints-goat-sdk-for-ai-agents-a-technical-walkthrough-44e5a9b228cd
- canonical_url
- https://medium.com/@izadimrantan/integrating-zetrix-with-crossmints-goat-sdk-for-ai-agents-a-technical-walkthrough-44e5a9b228cd
- author_url
- https://medium.com/@izadimrantan
- status
- ok
- fetched_at
- 2026-07-10 04:31:59