@goat-sdk/core
Advanced tools
+1
-1
@@ -5,3 +5,3 @@ export { PluginBase } from './classes/PluginBase.mjs'; | ||
| export { Tool, ToolDecoratorParams } from './decorators/Tool.mjs'; | ||
| export { AptosChain, Chain, ChromiaChain, CosmosChain, EvmChain, FuelChain, SolanaChain, SuiChain, ZilliqaChain } from './types/Chain.mjs'; | ||
| export { AptosChain, Chain, ChromiaChain, CosmosChain, EvmChain, FuelChain, RadixChain, SolanaChain, StarknetChain, SuiChain, ZilliqaChain } from './types/Chain.mjs'; | ||
| export { addParametersToDescription } from './utils/addParametersToDescription.mjs'; | ||
@@ -8,0 +8,0 @@ export { ToolParametersStatic, createToolParameters } from './utils/createToolParameters.mjs'; |
+1
-1
@@ -5,3 +5,3 @@ export { PluginBase } from './classes/PluginBase.js'; | ||
| export { Tool, ToolDecoratorParams } from './decorators/Tool.js'; | ||
| export { AptosChain, Chain, ChromiaChain, CosmosChain, EvmChain, FuelChain, SolanaChain, SuiChain, ZilliqaChain } from './types/Chain.js'; | ||
| export { AptosChain, Chain, ChromiaChain, CosmosChain, EvmChain, FuelChain, RadixChain, SolanaChain, StarknetChain, SuiChain, ZilliqaChain } from './types/Chain.js'; | ||
| export { addParametersToDescription } from './utils/addParametersToDescription.js'; | ||
@@ -8,0 +8,0 @@ export { ToolParametersStatic, createToolParameters } from './utils/createToolParameters.js'; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-B35TULQO.js');require('./chunk-U76ID4TS.js');var _chunkYNASICHOjs = require('./chunk-YNASICHO.js');var _chunkCPCEGD5Wjs = require('./chunk-CPCEGD5W.js');var _chunkXO6KYZAXjs = require('./chunk-XO6KYZAX.js');require('./chunk-JSCNTAIC.js');var _chunk2FIGR6PKjs = require('./chunk-2FIGR6PK.js');require('./chunk-ATIUG4XD.js');var _chunk6KPO4VDXjs = require('./chunk-6KPO4VDX.js');var _chunk2BFBJULLjs = require('./chunk-2BFBJULL.js');require('./chunk-EI7MMDWY.js');require('./chunk-4E4OVKBT.js');exports.PluginBase = _chunk2FIGR6PKjs.c; exports.Tool = _chunk2FIGR6PKjs.b; exports.ToolBase = _chunk2BFBJULLjs.a; exports.WalletClientBase = _chunk6KPO4VDXjs.a; exports.addParametersToDescription = _chunkYNASICHOjs.a; exports.createTool = _chunk2BFBJULLjs.b; exports.createToolParameters = _chunkCPCEGD5Wjs.a; exports.getTools = _chunkXO6KYZAXjs.a; | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-U76ID4TS.js');var _chunkCPCEGD5Wjs = require('./chunk-CPCEGD5W.js');var _chunkXO6KYZAXjs = require('./chunk-XO6KYZAX.js');require('./chunk-B35TULQO.js');require('./chunk-4E4OVKBT.js');require('./chunk-JSCNTAIC.js');var _chunk2FIGR6PKjs = require('./chunk-2FIGR6PK.js');require('./chunk-ATIUG4XD.js');var _chunk6KPO4VDXjs = require('./chunk-6KPO4VDX.js');var _chunk2BFBJULLjs = require('./chunk-2BFBJULL.js');var _chunkYNASICHOjs = require('./chunk-YNASICHO.js');require('./chunk-EI7MMDWY.js');exports.PluginBase = _chunk2FIGR6PKjs.c; exports.Tool = _chunk2FIGR6PKjs.b; exports.ToolBase = _chunk2BFBJULLjs.a; exports.WalletClientBase = _chunk6KPO4VDXjs.a; exports.addParametersToDescription = _chunkYNASICHOjs.a; exports.createTool = _chunk2BFBJULLjs.b; exports.createToolParameters = _chunkCPCEGD5Wjs.a; exports.getTools = _chunkXO6KYZAXjs.a; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| import"./chunk-6OLNVKT6.mjs";import"./chunk-WWU25UQ4.mjs";import{a as p}from"./chunk-LXZJARMM.mjs";import{a as t}from"./chunk-YJFN5KUX.mjs";import{a as x}from"./chunk-MQPJMYH2.mjs";import"./chunk-BWIGWQOY.mjs";import{b as o,c as f}from"./chunk-XYIQNSA3.mjs";import"./chunk-QBUWP7NA.mjs";import{a as m}from"./chunk-N6ZU3WNV.mjs";import{a as r,b as e}from"./chunk-ETCR2PPB.mjs";import"./chunk-YSXGDEY5.mjs";import"./chunk-XNUWQIHY.mjs";export{f as PluginBase,o as Tool,r as ToolBase,m as WalletClientBase,p as addParametersToDescription,e as createTool,t as createToolParameters,x as getTools}; | ||
| import"./chunk-WWU25UQ4.mjs";import{a as t}from"./chunk-YJFN5KUX.mjs";import{a as x}from"./chunk-MQPJMYH2.mjs";import"./chunk-6OLNVKT6.mjs";import"./chunk-XNUWQIHY.mjs";import"./chunk-BWIGWQOY.mjs";import{b as o,c as f}from"./chunk-XYIQNSA3.mjs";import"./chunk-QBUWP7NA.mjs";import{a as m}from"./chunk-N6ZU3WNV.mjs";import{a as r,b as e}from"./chunk-ETCR2PPB.mjs";import{a as p}from"./chunk-LXZJARMM.mjs";import"./chunk-YSXGDEY5.mjs";export{f as PluginBase,o as Tool,r as ToolBase,m as WalletClientBase,p as addParametersToDescription,e as createTool,t as createToolParameters,x as getTools}; |
@@ -5,3 +5,3 @@ /** | ||
| */ | ||
| type Chain = EvmChain | SolanaChain | AptosChain | ChromiaChain | FuelChain | SuiChain | ZilliqaChain | CosmosChain; | ||
| type Chain = EvmChain | SolanaChain | AptosChain | ChromiaChain | FuelChain | SuiChain | ZilliqaChain | CosmosChain | StarknetChain | RadixChain; | ||
| type SuiChain = { | ||
@@ -34,3 +34,10 @@ type: "sui"; | ||
| }; | ||
| type StarknetChain = { | ||
| type: "starknet"; | ||
| }; | ||
| type RadixChain = { | ||
| type: "radix"; | ||
| id: number; | ||
| }; | ||
| export type { AptosChain, Chain, ChromiaChain, CosmosChain, EvmChain, FuelChain, SolanaChain, SuiChain, ZilliqaChain }; | ||
| export type { AptosChain, Chain, ChromiaChain, CosmosChain, EvmChain, FuelChain, RadixChain, SolanaChain, StarknetChain, SuiChain, ZilliqaChain }; |
@@ -5,3 +5,3 @@ /** | ||
| */ | ||
| type Chain = EvmChain | SolanaChain | AptosChain | ChromiaChain | FuelChain | SuiChain | ZilliqaChain | CosmosChain; | ||
| type Chain = EvmChain | SolanaChain | AptosChain | ChromiaChain | FuelChain | SuiChain | ZilliqaChain | CosmosChain | StarknetChain | RadixChain; | ||
| type SuiChain = { | ||
@@ -34,3 +34,10 @@ type: "sui"; | ||
| }; | ||
| type StarknetChain = { | ||
| type: "starknet"; | ||
| }; | ||
| type RadixChain = { | ||
| type: "radix"; | ||
| id: number; | ||
| }; | ||
| export type { AptosChain, Chain, ChromiaChain, CosmosChain, EvmChain, FuelChain, SolanaChain, SuiChain, ZilliqaChain }; | ||
| export type { AptosChain, Chain, ChromiaChain, CosmosChain, EvmChain, FuelChain, RadixChain, SolanaChain, StarknetChain, SuiChain, ZilliqaChain }; |
@@ -1,1 +0,1 @@ | ||
| export { AptosChain, Chain, ChromiaChain, CosmosChain, EvmChain, FuelChain, SolanaChain, SuiChain, ZilliqaChain } from './Chain.mjs'; | ||
| export { AptosChain, Chain, ChromiaChain, CosmosChain, EvmChain, FuelChain, RadixChain, SolanaChain, StarknetChain, SuiChain, ZilliqaChain } from './Chain.mjs'; |
@@ -1,1 +0,1 @@ | ||
| export { AptosChain, Chain, ChromiaChain, CosmosChain, EvmChain, FuelChain, SolanaChain, SuiChain, ZilliqaChain } from './Chain.js'; | ||
| export { AptosChain, Chain, ChromiaChain, CosmosChain, EvmChain, FuelChain, RadixChain, SolanaChain, StarknetChain, SuiChain, ZilliqaChain } from './Chain.js'; |
@@ -1,1 +0,1 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-U76ID4TS.js');var _chunkYNASICHOjs = require('../chunk-YNASICHO.js');var _chunkCPCEGD5Wjs = require('../chunk-CPCEGD5W.js');var _chunkXO6KYZAXjs = require('../chunk-XO6KYZAX.js');require('../chunk-EI7MMDWY.js');exports.addParametersToDescription = _chunkYNASICHOjs.a; exports.createToolParameters = _chunkCPCEGD5Wjs.a; exports.getTools = _chunkXO6KYZAXjs.a; | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-U76ID4TS.js');var _chunkCPCEGD5Wjs = require('../chunk-CPCEGD5W.js');var _chunkXO6KYZAXjs = require('../chunk-XO6KYZAX.js');var _chunkYNASICHOjs = require('../chunk-YNASICHO.js');require('../chunk-EI7MMDWY.js');exports.addParametersToDescription = _chunkYNASICHOjs.a; exports.createToolParameters = _chunkCPCEGD5Wjs.a; exports.getTools = _chunkXO6KYZAXjs.a; |
@@ -1,1 +0,1 @@ | ||
| import"../chunk-WWU25UQ4.mjs";import{a}from"../chunk-LXZJARMM.mjs";import{a as b}from"../chunk-YJFN5KUX.mjs";import{a as c}from"../chunk-MQPJMYH2.mjs";import"../chunk-YSXGDEY5.mjs";export{a as addParametersToDescription,b as createToolParameters,c as getTools}; | ||
| import"../chunk-WWU25UQ4.mjs";import{a as b}from"../chunk-YJFN5KUX.mjs";import{a as c}from"../chunk-MQPJMYH2.mjs";import{a}from"../chunk-LXZJARMM.mjs";import"../chunk-YSXGDEY5.mjs";export{a as addParametersToDescription,b as createToolParameters,c as getTools}; |
+1
-1
| { | ||
| "name": "@goat-sdk/core", | ||
| "version": "0.4.6", | ||
| "version": "0.4.7", | ||
| "sideEffects": false, | ||
@@ -5,0 +5,0 @@ "files": [ |
+420
-60
| <div align="center"> | ||
| Go out and eat some grass. | ||
| [Docs](https://ohmygoat.dev) | [Examples](https://github.com/goat-sdk/goat/tree/main/typescript/examples) | [Discord](https://discord.gg/goat-sdk) | ||
| [Website](https://ohmygoat.dev) | [X](https://x.com/goat_sdk) | [Discord](https://discord.gg/goat-sdk) | ||
| GOAT is sponsored by [Crossmint](https://www.crossmint.com) | ||
| </div> | ||
| GOAT is free software, MIT licensed, sponsored by [Crossmint](https://www.crossmint.com) | ||
| ## Goat π | ||
| GOAT π (Great Onchain Agent Toolkit) is an open-source framework for adding blockchain tools such as wallets, being able to hold or trade tokens, or interacting with blockchain smart contracts, to your AI agent. | ||
|  | ||
|  | ||
| **Problem**: | ||
|  | ||
| Making agents perform onchain actions is tedious. The ecosystem is heavily fragmented, spanning 5+ popular agent development frameworks, multiple programming languages, and dozens of different blockchains and wallet architectures. | ||
| For developers without blockchain expertise, finding clear instructions to perform simple actions - like sending USDC payments or placing Polymarket bets - is nearly impossible. | ||
| **Solution**: | ||
| </div> | ||
| GOAT solves this by providing an open-source, provider-agnostic framework that abstracts away all these combinations. | ||
| # GOAT π (Typescript) | ||
|  | ||
| - **For agent developers**: GOAT offers an always-growing catalog of ready made blockchain actions (sending tokens, using a DeFi protocol, ...) that can be imported as tools into your existing agent. It works with the most popular agent frameworks (Langchain, Vercel's AI SDK, Eliza, etc), Typescript and Python, 30+ blockchains (Solana, Base, Polygon, Mode, ...), and many wallet providers. | ||
| - **For dApp / smart contract developers**: develop a plug-in in GOAT, and allow agents built with any of the most popular agent development frameworks to access your service. | ||
| GOAT (Great Onchain Agent Toolkit) is a library that adds more than +200 onchain tools to your AI agent. | ||
| ### Key features | ||
| 1. **Works Everywhere**: Compatible with Langchain, Vercelβs AI SDK, Eliza, and more. | ||
| 2. **Wallet Agnostic**: Supports all wallets, from your own key pairs to [Crossmint Smart Wallets](https://docs.crossmint.com/wallets/smart-wallets/overview) and Coinbase. | ||
| 3. **Multi-Chain**: Supports EVM chains and Solana (more coming π). | ||
| 4. **Customizable**: Use or build plugins for any onchain functionality (sending tokens, checking wallet balance, etc) and protocol (Polymarket, Uniswap, etc). | ||
| * **[+200 tools](#plugins)**: DeFi (Uniswap, Jupiter, KIM, Orca, etc.), minting (OpenSea, MagicEden, etc.), betting (Polymarket, etc.), analytics (CoinGecko, BirdEye, Allora, etc.) and more | ||
| * **Chains**: EVM (Base, Polygon, Mode, Sei, etc.), Solana, Aptos, Chromia, Fuel, Sui, Starknet and Zilliqa | ||
| * **[Wallets](#wallets)**: keypair, smart wallets (Crossmint, etc.), LIT, MPC (Coinbase, etc.) | ||
| * **[Agent Frameworks](#agent-frameworks-adapters)**: AI SDK, Langchain, Eliza, ZerePy, GAME, ElevenLabs, etc. | ||
|  | ||
| ### How it works | ||
| GOAT plugs into your agents tool calling capabilities adding all the functions your agent needs to interact with the blockchain. | ||
| ## Table of Contens | ||
| - [See all plugins](#plugins) | ||
| - [Installation](#installation) | ||
| - [Usage](#usage) | ||
| - [Examples](https://github.com/goat-sdk/goat/tree/main/typescript/examples) | ||
| - [How to create a plugin](#how-to-create-a-plugin) | ||
| - [Using the plugin generator](#using-the-plugin-generator) | ||
| - [Manual creation](#manual-creation) | ||
| - [How to add a chain](#how-to-add-a-chain) | ||
| - [How to add a wallet provider](#how-to-add-a-wallet-provider) | ||
| - [Packages](#packages) | ||
| - [Plugins](#plugins) | ||
| - [Wallets](#wallets) | ||
| - [Adapters](#agent-framework-adapters) | ||
| High-level, here's how it works: | ||
| ## Installation | ||
| 1. Install the core package | ||
| ```bash | ||
| npm install @goat-sdk/core | ||
| ``` | ||
| 2. Depending on the type of wallet you want to use, install the corresponding wallet (see all wallets [here](#wallets)): | ||
| ```bash | ||
| npm install @goat-sdk/wallet-solana | ||
| ``` | ||
| 3. Install the plugins for the protocols you need (see all available plugins [here](#plugins)) | ||
| #### Configure the wallet you want to use | ||
| ```bash | ||
| npm install @goat-sdk/plugin-jupiter @goat-sdk/plugin-spl-tokens | ||
| ``` | ||
| 4. Install the adapter for the agent framework you want to use (see all available adapters [here](#adapters)) | ||
| ```bash | ||
| npm install @goat-sdk/adapter-ai-sdk | ||
| ``` | ||
| ## Usage | ||
| 1. Configure your wallet | ||
| ```typescript | ||
| // ... Code to connect your wallet (e.g createWalletClient from viem) | ||
| const wallet = ... | ||
| import { Connection, Keypair } from "@solana/web3.js"; | ||
| const tools = getOnChainTools({ | ||
| wallet: viem(wallet), | ||
| }) | ||
| const connection = new Connection(process.env.SOLANA_RPC_URL as string); | ||
| const keypair = Keypair.fromSecretKey(base58.decode(process.env.SOLANA_PRIVATE_KEY as string)); | ||
| ``` | ||
| #### Add the plugins you need to interact with the protocols you want | ||
| 2. Configure your tools for the framework you want to use | ||
| ```typescript | ||
| const wallet = ... | ||
| import { getOnChainTools } from "@goat-sdk/adapter-ai-sdk"; | ||
| import { solana, sendSOL } from "@goat-sdk/wallet-solana"; | ||
| import { jupiter } from "@goat-sdk/plugin-jupiter"; | ||
| import { splToken } from "@goat-sdk/plugin-spl-token"; | ||
| const tools = getOnChainTools({ | ||
| wallet: viem(wallet), | ||
| plugins: [ | ||
| sendETH(), | ||
| erc20({ tokens: [USDC, PEPE] }), | ||
| faucet(), | ||
| polymarket(), | ||
| // ... | ||
| ], | ||
| }) | ||
| const tools = await getOnChainTools({ | ||
| wallet: solana({ | ||
| keypair, | ||
| connection, | ||
| }), | ||
| plugins: [ | ||
| sendSOL(), | ||
| jupiter(), | ||
| splToken(), | ||
| ], | ||
| }); | ||
| ``` | ||
| #### Connect it to your agent framework of choice | ||
| 3. Plug into your agent framework | ||
| ```typescript | ||
| // ... Code to connect your wallet (e.g createWalletClient from viem) | ||
| const wallet = ... | ||
| const tools = getOnChainTools({ | ||
| wallet: viem(wallet), | ||
| plugins: [ | ||
| sendETH(), | ||
| erc20({ tokens: [USDC, PEPE] }), | ||
| faucet(), | ||
| polymarket(), | ||
| // ... | ||
| ], | ||
| }) | ||
| // Vercel's AI SDK | ||
| const result = await generateText({ | ||
| model: openai("gpt-4o-mini"), | ||
| tools: tools, | ||
| maxSteps: 5, | ||
| prompt: "Send 420 ETH to ohmygoat.eth", | ||
| maxSteps: 10, | ||
| prompt: "Swap 10 USDC for JLP", | ||
| }); | ||
| console.log(result); | ||
| ``` | ||
| See [here](https://github.com/goat-sdk/goat/tree/main/typescript/examples) for more examples. | ||
| ## How to create a plugin | ||
| GOAT plugins enable your agent to interact with various blockchain protocols. | ||
| Plugins can be chain-specific (EVM, Solana, etc.) or chain-agnostic. If a plugin is chain-specific it will fail to compile when being used with a wallet of a different chain. | ||
| You can see all available plugins [here](#plugins). | ||
| ### Using the Plugin Generator | ||
| Use the `create-plugin` command to generate all the necessary files and configuration for a new plugin | ||
| ```bash | ||
| # Create a plugin with default type (any) | ||
| pnpm create-plugin -n your-plugin-name | ||
| # Create a plugin for a specific chain type | ||
| pnpm create-plugin -n your-plugin-name -t evm # For EVM chains | ||
| pnpm create-plugin -n your-plugin-name -t solana # For Solana | ||
| ``` | ||
| The command will generate: | ||
| - A `package.json` with standard metadata and dependencies | ||
| - TypeScript configuration files (`tsconfig.json`, `tsup.config.ts`) | ||
| - A basic plugin structure in the `src` directory: | ||
| - `parameters.ts` - Example parameters using Zod schema | ||
| - `your-plugin-name.service.ts` - Service class with an example tool | ||
| - `your-plugin-name.plugin.ts` - Plugin class extending PluginBase | ||
| - `index.ts` - Exports for your plugin | ||
| ### Manual Creation | ||
| #### 1. Define your plugin extending the [PluginBase](https://github.com/goat-sdk/goat/tree/main/typescript/packages/core/src/classes/PluginBase.ts) class. | ||
| ```typescript | ||
| import { PluginBase, WalletClientBase } from "@goat-sdk/core"; | ||
| // For a chain-agnostic plugin we use the WalletClientBase interface, for a chain-specific plugin we use the EVMWalletClient, SolanaWalletClient, or corresponding interfaces | ||
| export class MyPlugin extends PluginBase<WalletClientBase> { | ||
| constructor() { | ||
| // We define the name of the plugin | ||
| super("myPlugin", []); | ||
| } | ||
| // We define the chain support for the plugin, in this case we support all chains | ||
| supportsChain = (chain: Chain) => true; | ||
| } | ||
| // We export a factory function to create a new instance of the plugin | ||
| export const myPlugin = () => new MyPlugin(); | ||
| ``` | ||
| #### 2. Add tools to the plugin | ||
| There are two ways to add tools to the plugin: | ||
| 1. Using the `@Tool` decorator on our own class | ||
| 2. Using the `getTools` and `createTool` functions to create tools dynamically | ||
| ##### Option 1: Using the `@Tool` decorator | ||
| The `@Tool` decorator is a way to create tools in a more declarative way. | ||
| You can create a class and decorate its methods with the `@Tool` decorator to create tools. | ||
| The tool methods will receive the wallet client as the first argument and the parameters as the second argument. | ||
| ```typescript | ||
| import { Tool } from "@goat-sdk/core"; | ||
| import { createToolParameters } from "@goat-sdk/core"; | ||
| import { z } from "zod"; | ||
| export class SignMessageParameters extends createToolParameters( | ||
| z.object({ | ||
| message: z.string(), | ||
| }), | ||
| ) {} | ||
| class MyTools { | ||
| @Tool({ | ||
| name: "sign_message", | ||
| description: "Sign a message", | ||
| }) | ||
| async signMessage(walletClient: WalletClientBase, parameters: SignMessageParameters) { | ||
| const signed = await walletClient.signMessage(parameters.message); | ||
| return signed.signedMessage; | ||
| } | ||
| } | ||
| ``` | ||
| Once we have our class we now need to import it in our plugin class. | ||
| ```typescript | ||
| export class MyPlugin extends PluginBase<WalletClientBase> { | ||
| constructor() { | ||
| // We define the name of the plugin | ||
| super("myPlugin", [new MyTools()]); | ||
| } | ||
| // We define the chain support for the plugin, in this case we support all chains | ||
| supportsChain = (chain: Chain) => true; | ||
| } | ||
| // We export a factory function to create a new instance of the plugin | ||
| export const myPlugin = () => new MyPlugin(); | ||
| ``` | ||
| ##### Option 2: Using the `getTools` and `createTool` functions | ||
| We will implement the `getTools` method in our plugin class. | ||
| Inside the method, we will return an array of tools created using the `createTool` function. | ||
| ```typescript | ||
| import { PluginBase, WalletClientBase, createTool } from "@goat-sdk/core"; | ||
| // Since we are creating a chain-agnostic plugin, we can use the WalletClientBase interface | ||
| export class MyPlugin extends PluginBase<WalletClientBase> { | ||
| constructor() { | ||
| // We define the name of the plugin | ||
| super("myPlugin", []); | ||
| } | ||
| // We define the chain support for the plugin, in this case we support all chains | ||
| supportsChain = (chain: Chain) => true; | ||
| getTools(walletClient: WalletClientBase) { | ||
| return [ | ||
| // Create tool requires two arguments: | ||
| // 1. The tool metadata (name, description, parameters) | ||
| // 2. The tool method (the function that will be executed when the tool is used) | ||
| createTool( | ||
| { | ||
| name: "sign_message", | ||
| description: "Sign a message", | ||
| parameters: z.object({ | ||
| message: z.string(), | ||
| }), | ||
| }, | ||
| async (parameters) => { | ||
| const signed = await walletClient.signMessage(parameters.message); | ||
| return signed.signedMessage; | ||
| }, | ||
| ), | ||
| ]; | ||
| } | ||
| } | ||
| // We export a factory function to create a new instance of the plugin | ||
| export const myPlugin = () => new MyPlugin(); | ||
| ``` | ||
| #### 3. Add the plugin to the agent | ||
| ```typescript | ||
| import { getOnChainTools } from '@goat-sdk/adapter-vercel-ai'; | ||
| import { myPlugin } from './your-plugin-path/signMessagePlugin'; // Path to your plugin | ||
| const wallet = /* Initialize your wallet client */; | ||
| const tools = getOnChainTools({ | ||
| wallet: viem(wallet), // or smartwallet(wallet), solana(wallet), etc. | ||
| plugins: [ | ||
| myPlugin(), | ||
| // ...other plugins | ||
| ], | ||
| }); | ||
| // Prompt: Sign the message "Sign the message 'Go out and eat grass π'" | ||
| ``` | ||
| #### Next steps | ||
| - Share your plugin with others! | ||
| - Open a PR to add it to the [plugins registry](https://github.com/goat-sdk/goat/tree/main/typescript/packages/plugins) in the [GOAT SDK](https://github.com/goat-sdk/goat). | ||
| ## How to add a chain | ||
| ### 1. Add the chain to the `Chain.ts` file | ||
| Add your chain to the `Chain.ts` file in the [core package](https://github.com/goat-sdk/goat/tree/main/typescript/packages/core/src/types/Chain.ts). | ||
| ```typescript | ||
| /** | ||
| * @param type - "evm" or "solana", extend this union as needed (e.g., "sui") | ||
| * @param id - Chain ID, optional for EVM | ||
| */ | ||
| export type Chain = EvmChain | SolanaChain | AptosChain | ChromiaChain | FuelChain | MyAwesomeChain; | ||
| export type MyAwesomeChain = { | ||
| type: "my-awesome-chain"; | ||
| }; | ||
| ``` | ||
| ### 2. Create a new wallet provider package | ||
| Create a new package in the [wallets directory](https://github.com/goat-sdk/goat/tree/main/typescript/packages/wallets) with the name of your chain (e.g. `my-awesome-chain`) or copy an existing one (e.g. `evm`). | ||
| In this package you will define the abstract class for your chain's wallet client which will extend the `WalletClientBase` class defined in the [core package](https://github.com/goat-sdk/goat/tree/main/typescript/packages/core/src/classes/WalletClientBase.ts). | ||
| WalletClientBase only includes the methods that are supported by all chains such as: | ||
| 1. `getAddress` | ||
| 2. `getChain` | ||
| 3. `signMessage` | ||
| 4. `balanceOf` | ||
| As well as includes the `getCoreTools` method which returns the core tools for the chain. | ||
| ```typescript | ||
| export abstract class MyAwesomeChainWalletClient extends WalletClientBase { | ||
| // Add your chain's methods here | ||
| abstract getChain(): MyAwesomeChain; | ||
| sendTransaction: (transaction: AwesomeChainTransaction) => Promise<Transaction>; | ||
| read: (query: AwesomeChainQuery) => Promise<AwesomeChainResponse>; | ||
| } | ||
| ``` | ||
| ### 3. Create a plugin to allow sending your native token to a wallet | ||
| Create a plugin to allow sending your native token to a wallet. Create a file in the same package as your wallet client and create a new file like `send<native-token>.plugin.ts`. | ||
| Implement the core plugin. | ||
| ```typescript | ||
| export class SendAWESOMETOKENPlugin extends PluginBase<MyAwesomeChainWalletClient> { | ||
| constructor() { | ||
| super("sendAWESOMETOKEN", []); | ||
| } | ||
| supportsChain = (chain: Chain) => chain.type === "my-awesome-chain"; | ||
| getTools(walletClient: MyAwesomeChainWalletClient) { | ||
| const sendTool = createTool( | ||
| { | ||
| name: `send_myawesometoken`, | ||
| description: `Send MYAWESOMETOKEN to an address.`, | ||
| parameters: sendAWESOMETOKENParametersSchema, // Define the parameters schema | ||
| }, | ||
| // Implement the method | ||
| (parameters: z.infer<typeof sendAWESOMETOKENParametersSchema>) => sendAWESOMETOKENMethod(walletClient, parameters), | ||
| ); | ||
| return [sendTool]; | ||
| } | ||
| } | ||
| ``` | ||
| ### 4. Implement the wallet client | ||
| Extend your abstract class with the methods you need to implement and create your first wallet client! (e.g `MyAwesomeChainKeyPairWalletClient`) | ||
| ```typescript | ||
| export class MyAwesomeChainKeyPairWalletClient extends MyAwesomeChainWalletClient { | ||
| // Implement the methods here | ||
| } | ||
| // Export the wallet client with a factory function | ||
| export const myAwesomeChain = () => new MyAwesomeChainKeyPairWalletClient(); | ||
| ``` | ||
| ### 5. Submit a PR | ||
| Submit a PR to add your wallet provider to the [wallets directory](https://github.com/goat-sdk/goat/tree/main/typescript/packages/wallets). | ||
| ## How to add a wallet provider | ||
| If you don't see your wallet provider supported, you can easily integrate it by implementing the specific [WalletClient](https://github.com/goat-sdk/goat/blob/main/typescript/packages/core/src/wallets/core.ts) interface for the chain and type of wallet you want to support: | ||
| 1. [EVMWalletClient](https://github.com/goat-sdk/goat/blob/main/typescript/packages/core/src/wallets/evm.ts) for all EVM chains | ||
| 2. [EVMSmartWalletClient](https://github.com/goat-sdk/goat/blob/main/typescript/packages/core/src/wallets/evm-smart-wallet.ts) for EVM smart wallets | ||
| 2. [SolanaWalletClient](https://github.com/goat-sdk/goat/blob/main/typescript/packages/core/src/wallets/solana.ts) for Solana | ||
| Checkout [here how the viem client implementation](https://github.com/goat-sdk/goat/blob/main/typescript/packages/wallets/viem/src/index.ts). | ||
| If you would like to see your wallet provider supported, please open an issue or submit a PR. | ||
| ## Packages | ||
| ### Core | ||
| | | NPM package | | ||
| | --- | --- | | ||
| | Core | [@goat-sdk/core](https://www.npmjs.com/package/@goat-sdk/core) | | ||
| ### Wallets | ||
| | Wallet | NPM package | | ||
| | --- | --- | | ||
| |EVM | [@goat-sdk/wallet-evm](https://www.npmjs.com/package/@goat-sdk/wallet-evm) | | ||
| |Viem | [@goat-sdk/wallet-evm-viem](https://www.npmjs.com/package/@goat-sdk/wallet-evm-viem) | [goat-sdk-wallet-evm](https://pypi.org/project/goat-sdk-wallet-evm/) | | ||
| | Solana | [@goat-sdk/wallet-solana](https://www.npmjs.com/package/@goat-sdk/wallet-solana) | [@goat-sdk-wallet-solana](https://pypi.org/project/goat-sdk-wallet-solana/) | | ||
| | Crossmint (smart and custodial wallets) | [@goat-sdk/wallet-crossmint](https://www.npmjs.com/package/@goat-sdk/wallet-crossmint) | [@goat-sdk-wallet-crossmint](https://pypi.org/project/goat-sdk-wallet-crossmint/) | | ||
| | Aptos | [@goat-sdk/wallet-aptos](https://www.npmjs.com/package/@goat-sdk/wallet-aptos) | | ||
| | Chromia | [@goat-sdk/wallet-chromia](https://www.npmjs.com/package/@goat-sdk/wallet-chromia) | | ||
| | Cosmos | [@goat-sdk/wallet-cosmos](https://www.npmjs.com/package/@goat-sdk/wallet-cosmos) | | ||
| | Fuel | [@goat-sdk/wallet-fuel](https://www.npmjs.com/package/@goat-sdk/wallet-fuel) | | ||
| | Sui | [@goat-sdk/wallet-sui](https://www.npmjs.com/package/@goat-sdk/wallet-sui) | | ||
| | Starknet | [@goat-sdk/wallet-starknet](https://www.npmjs.com/package/@goat-sdk/wallet-starknet) | | ||
| | Zilliqa | [@goat-sdk/wallet-zilliqa](https://www.npmjs.com/package/@goat-sdk/wallet-zilliqa) | | ||
| ### Agent Framework Adapters | ||
| | Adapter | NPM package | | ||
| | --- | --- | | ||
| | AI SDK | [@goat-sdk/adapter-ai-sdk](https://www.npmjs.com/package/@goat-sdk/adapter-ai-sdk) | | ||
| | Langchain | [@goat-sdk/adapter-langchain](https://www.npmjs.com/package/@goat-sdk/adapter-langchain) | | ||
| | ElevenLabs | [@goat-sdk/adapter-elevenlabs](https://www.npmjs.com/package/@goat-sdk/adapter-elevenlabs) | | | ||
| | LlamaIndex | [@goat-sdk/adapter-llamaindex](https://www.npmjs.com/package/@goat-sdk/adapter-llamaindex) | | | ||
| | Model Context Protocol | [@goat-sdk/adapter-model-context-protocol](https://www.npmjs.com/package/@goat-sdk/adapter-model-context-protocol) | | | ||
| **Eliza, ZerePy and GAME have direct integrations on their respective repos.* | ||
| ### Plugins | ||
| | Plugin | Tools | NPM package | | ||
| | --- | --- | --- | | ||
| | 0x | Get quotes and swap on 0x | [@goat-sdk/plugin-0x](https://www.npmjs.com/package/@goat-sdk/plugin-0x) | | ||
| | 1inch | Get the balances of a wallet using 1inch API | [@goat-sdk/plugin-1inch](https://www.npmjs.com/package/@goat-sdk/plugin-1inch) | | ||
| | Allora | Get price predictions using Allora API | [@goat-sdk/plugin-allora](https://www.npmjs.com/package/@goat-sdk/plugin-allora) | | ||
| | Avnu | Swap tokens on Starknet | [@goat-sdk/plugin-avnu](https://www.npmjs.com/package/@goat-sdk/plugin-avnu) | | ||
| | Balancer | Swap tokens and provide liquidity on Balancer | [@goat-sdk/plugin-balancer](https://www.npmjs.com/package/@goat-sdk/plugin-balancer) | | ||
| | Balmy | Swap tokens on Balmy | [@goat-sdk/plugin-balmy](https://www.npmjs.com/package/@goat-sdk/plugin-balmy) | | ||
| | BirdEye | Get token insights using BirdEye API | [@goat-sdk/plugin-birdeye](https://www.npmjs.com/package/@goat-sdk/plugin-birdeye) | | ||
| | CoinGecko | Get coin information using CoinGecko API | [@goat-sdk/plugin-coingecko](https://www.npmjs.com/package/@goat-sdk/plugin-coingecko) | | ||
| | Coinmarketcap | Get coin information using Coinmarketcap API | [@goat-sdk/plugin-coinmarketcap](https://www.npmjs.com/package/@goat-sdk/plugin-coinmarketcap) | | ||
| | Cosmosbank | Interact with Cosmos tokens | [@goat-sdk/plugin-cosmosbank](https://www.npmjs.com/package/@goat-sdk/plugin-cosmosbank) | | ||
| | Crossmint Headless Checkout | Purchase any NFT on any chain using Crossmint | [@goat-sdk/plugin-crossmint-headless-checkout](https://www.npmjs.com/package/@goat-sdk/plugin-crossmint-headless-checkout) | | ||
| | Crossmint Mint, Faucet, Wallets | Create a wallet, mint tokens and get test tokens on any chain using Crossmint | [@goat-sdk/plugin-crossmint-mint-faucet-wallets](https://www.npmjs.com/package/@goat-sdk/plugin-crossmint-mint-faucet-wallets) | | ||
| | DeBridge | Bridge tokens on DeBridge | [@goat-sdk/plugin-debridge](https://www.npmjs.com/package/@goat-sdk/plugin-debridge) | | ||
| | Dexscreener | Get token information using Dexscreener API | [@goat-sdk/plugin-dexscreener](https://www.npmjs.com/package/@goat-sdk/plugin-dexscreener) | | ||
| | ERC20 | Interact with any ERC20 token | [@goat-sdk/plugin-erc20](https://www.npmjs.com/package/@goat-sdk/plugin-erc20) | | ||
| | ERC721 | Interact with any ERC721 token | [@goat-sdk/plugin-erc721](https://www.npmjs.com/package/@goat-sdk/plugin-erc721) | | ||
| | Etherscan | Get transaction information using Etherscan API | [@goat-sdk/plugin-etherscan](https://www.npmjs.com/package/@goat-sdk/plugin-etherscan) | | ||
| | Farcaster | Read and post casts on Farcaster | [@goat-sdk/plugin-farcaster](https://www.npmjs.com/package/@goat-sdk/plugin-farcaster) | | ||
| | Ionic | Borrow and lend on Ionic | [@goat-sdk/plugin-ionic](https://www.npmjs.com/package/@goat-sdk/plugin-ionic) | | ||
| | Ironclad | Create positions on Ironclad | [@goat-sdk/plugin-ironclad](https://www.npmjs.com/package/@goat-sdk/plugin-ironclad) | | ||
| | JSON RPC | Call any JSON RPC endpoint |[@goat-sdk/plugin-json-rpc](https://www.npmjs.com/package/@goat-sdk/plugin-json-rpc) | | | ||
| | Jupiter | Swap tokens on Jupiter | [@goat-sdk/plugin-jupiter](https://www.npmjs.com/package/@goat-sdk/plugin-jupiter) | | ||
| | KIM | Swap tokens on KIM | [@goat-sdk/plugin-kim](https://www.npmjs.com/package/@goat-sdk/plugin-kim) | | ||
| | Lulo | Deposit USDC on Lulo | [@goat-sdk/plugin-lulo](https://www.npmjs.com/package/@goat-sdk/plugin-lulo) | | ||
| | Meteora | Create liquidity pools on Meteora | [@goat-sdk/plugin-meteora](https://www.npmjs.com/package/@goat-sdk/plugin-meteora) | | ||
| | Mode Governance | Create a governance proposal on Mode | [@goat-sdk/plugin-mode-governance](https://www.npmjs.com/package/@goat-sdk/plugin-mode-governance) | | ||
| | Mode Voting | Vote on a governance proposal on Mode | [@goat-sdk/plugin-mode-voting](https://www.npmjs.com/package/@goat-sdk/plugin-mode-voting) | | ||
| | Mode Spray | Spray tokens on Mode | [@goat-sdk/plugin-mode-spray](https://www.npmjs.com/package/@goat-sdk/plugin-mode-spray) | | ||
| | Nansen | Get Nansen information using Nansen API | [@goat-sdk/plugin-nansen](https://www.npmjs.com/package/@goat-sdk/plugin-nansen) | | ||
| | OpenSea | Get nft and sales information using OpenSea API | [@goat-sdk/plugin-opensea](https://www.npmjs.com/package/@goat-sdk/plugin-opensea) | | ||
| | Orca | Create positions on Orca | [@goat-sdk/plugin-orca](https://www.npmjs.com/package/@goat-sdk/plugin-orca) | | ||
| | Polymarket | Bet on Polymarket | [@goat-sdk/plugin-polymarket](https://www.npmjs.com/package/@goat-sdk/plugin-polymarket) | | ||
| | Pump.fun | Launch a token on Pump.fun | [@goat-sdk/plugin-pump-fun](https://www.npmjs.com/package/@goat-sdk/plugin-pump-fun) | | ||
| | Renzo | Create a position on Renzo | [@goat-sdk/plugin-renzo](https://www.npmjs.com/package/@goat-sdk/plugin-renzo) | | ||
| | Rugcheck | Check SPL token validity on Rugcheck | [@goat-sdk/plugin-rugcheck](https://www.npmjs.com/package/@goat-sdk/plugin-rugcheck) | | ||
| | SNS | Interact with SNS | [@goat-sdk/plugin-sns](https://www.npmjs.com/package/@goat-sdk/plugin-sns) | | ||
| | Solana Magic Eden | Purchase NFTs on Magic Eden | [@goat-sdk/plugin-solana-magiceden](https://www.npmjs.com/package/@goat-sdk/plugin-solana-magiceden) | | ||
| | Solana NFTs | Get NFT information using Solana NFTs API | [@goat-sdk/plugin-solana-nfts](https://www.npmjs.com/package/@goat-sdk/plugin-solana-nfts) | | | ||
| | SPL Tokens | Interact with SPL tokens | [@goat-sdk/plugin-spl-tokens](https://www.npmjs.com/package/@goat-sdk/plugin-spl-tokens) | | | ||
| | Starknet Token | Interact with Starknet tokens | [@goat-sdk/plugin-starknet-token](https://www.npmjs.com/package/@goat-sdk/plugin-starknet-token) | | | ||
| | Superfluid | Create streams with Superfluid | [@goat-sdk/plugin-superfluid](https://www.npmjs.com/package/@goat-sdk/plugin-superfluid) | | | ||
| | Tensor | Purchase tokens on Tensor | [@goat-sdk/plugin-tensor](https://www.npmjs.com/package/@goat-sdk/plugin-tensor) | | | ||
| | Uniswap | Swap tokens on Uniswap | [@goat-sdk/plugin-uniswap](https://www.npmjs.com/package/@goat-sdk/plugin-uniswap) | | | ||
| | Velodrome | Create a position on Velodrome | [@goat-sdk/plugin-velodrome](https://www.npmjs.com/package/@goat-sdk/plugin-velodrome) | | | ||
| | Worldstore | Purchase physical assets on Worldstore | [@goat-sdk/plugin-worldstore](https://www.npmjs.com/package/@goat-sdk/plugin-worldstore) | | | ||
| | ZeroDev Global Address | Create a global address on ZeroDev | [@goat-sdk/plugin-zero-dev-global-address](https://www.npmjs.com/package/@goat-sdk/plugin-zero-dev-global-address) | | | ||
| | Zilliqa | Interact with Zilliqa | [@goat-sdk/plugin-zilliqa](https://www.npmjs.com/package/@goat-sdk/plugin-zilliqa) | | | ||
60282
46.89%335
2.13%451
395.6%