🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@goat-sdk/core

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@goat-sdk/core - npm Package Compare versions

Comparing version
0.4.7
to
0.4.8
+26
dist/utils/env.d.mts
import { z } from 'zod';
/**
* Validates required environment variables and provides helpful error messages.
* @param requiredVars Array of required environment variable names
* @throws Error if any required variables are missing
*/
declare const validateEnvVars: (requiredVars: string[]) => void;
/**
* Common environment variable schemas for validation
*/
declare const envSchemas: {
openai: z.ZodString;
evmPrivateKey: z.ZodString;
solanaPrivateKey: z.ZodString;
rpcUrl: z.ZodString;
apiKey: z.ZodString;
};
/**
* Validates environment variables against predefined schemas
* @param vars Object mapping environment variable names to their schema types
* @throws Error if any variables fail validation
*/
declare const validateEnvVarFormats: (vars: Record<string, keyof typeof envSchemas>) => void;
export { envSchemas, validateEnvVarFormats, validateEnvVars };
import { z } from 'zod';
/**
* Validates required environment variables and provides helpful error messages.
* @param requiredVars Array of required environment variable names
* @throws Error if any required variables are missing
*/
declare const validateEnvVars: (requiredVars: string[]) => void;
/**
* Common environment variable schemas for validation
*/
declare const envSchemas: {
openai: z.ZodString;
evmPrivateKey: z.ZodString;
solanaPrivateKey: z.ZodString;
rpcUrl: z.ZodString;
apiKey: z.ZodString;
};
/**
* Validates environment variables against predefined schemas
* @param vars Object mapping environment variable names to their schema types
* @throws Error if any variables fail validation
*/
declare const validateEnvVarFormats: (vars: Record<string, keyof typeof envSchemas>) => void;
export { envSchemas, validateEnvVarFormats, validateEnvVars };
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEI7MMDWYjs = require('../chunk-EI7MMDWY.js');var _zod = require('zod');var l=_chunkEI7MMDWYjs.a.call(void 0, s=>{let e=s.filter(n=>!process.env[n]);if(e.length>0)throw new Error(`Missing required environment variables: ${e.join(", ")}
See docs/environment-variables.mdx for setup instructions`)},"validateEnvVars"),c= exports.envSchemas ={openai:_zod.z.string().startsWith("sk-"),evmPrivateKey:_zod.z.string().startsWith("0x").length(66),solanaPrivateKey:_zod.z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/),rpcUrl:_zod.z.string().url(),apiKey:_zod.z.string().min(32)},f= exports.validateEnvVarFormats =_chunkEI7MMDWYjs.a.call(void 0, s=>{let e=[];for(let[n,a]of Object.entries(s)){let o=process.env[n];if(!o)continue;let i=c[a].safeParse(o);i.success||e.push(`Invalid format for ${n}: ${i.error.message}`)}if(e.length>0)throw new Error(`Environment variable format validation failed:
${e.join(`
`)}
See docs/environment-variables.mdx for correct formats`)},"validateEnvVarFormats");exports.envSchemas = c; exports.validateEnvVarFormats = f; exports.validateEnvVars = l;
import{a as t}from"../chunk-YSXGDEY5.mjs";import{z as r}from"zod";var f=t(s=>{let e=s.filter(n=>!process.env[n]);if(e.length>0)throw new Error(`Missing required environment variables: ${e.join(", ")}
See docs/environment-variables.mdx for setup instructions`)},"validateEnvVars"),c={openai:r.string().startsWith("sk-"),evmPrivateKey:r.string().startsWith("0x").length(66),solanaPrivateKey:r.string().regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/),rpcUrl:r.string().url(),apiKey:r.string().min(32)},g=t(s=>{let e=[];for(let[n,a]of Object.entries(s)){let o=process.env[n];if(!o)continue;let i=c[a].safeParse(o);i.success||e.push(`Invalid format for ${n}: ${i.error.message}`)}if(e.length>0)throw new Error(`Environment variable format validation failed:
${e.join(`
`)}
See docs/environment-variables.mdx for correct formats`)},"validateEnvVarFormats");export{c as envSchemas,g as validateEnvVarFormats,f as validateEnvVars};
+1
-1

@@ -1,1 +0,1 @@

"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;
"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;

@@ -1,1 +0,1 @@

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};
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};

@@ -1,1 +0,1 @@

"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;
"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;

@@ -1,1 +0,1 @@

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};
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};
{
"name": "@goat-sdk/core",
"version": "0.4.7",
"version": "0.4.8",
"sideEffects": false,

@@ -5,0 +5,0 @@ "files": [

+84
-427

@@ -0,450 +1,107 @@

<div>
<img src="https://github.com/user-attachments/assets/4821833e-52e5-4126-a2a1-59e9fa9bebd7" alt="GOAT" width="100%" height="auto" style="object-fit: contain; max-width: 800px;">
<div align="center">
<div>
<img src="https://img.shields.io/npm/dm/%40goat-sdk%2Fcore" alt="NPM Downloads">
[Website](https://ohmygoat.dev) | [X](https://x.com/goat_sdk) | [Discord](https://discord.gg/goat-sdk)
<img src="https://img.shields.io/github/license/goat-sdk/goat" alt="GitHub License">
</div>
<div>
<img src="https://img.shields.io/badge/v20.12.2-1?label=typescript&color=blue" alt="Typescript Version">
GOAT is free software, MIT licensed, sponsored by [Crossmint](https://www.crossmint.com)
<img src="https://img.shields.io/pypi/pyversions/goat-sdk" alt="PyPI - Python Version">
</div>
![NPM Downloads](https://img.shields.io/npm/dm/%40goat-sdk%2Fcore)
![GitHub License](https://img.shields.io/github/license/goat-sdk/goat)
![Static Badge](https://img.shields.io/badge/v20.12.2-1?label=typescript&color=blue)
<br>
<div align="center">
<div style="margin-bottom: 5px;">
<b>Sponsored by</b>
</div>
<div>
<a href="https://www.crossmint.com" target="_blank"> <img src="https://github.com/user-attachments/assets/f3bdfbe3-2a87-48ec-aacb-a5e72737018c" alt="Crossmint logo" width="180px" height="auto" style="object-fit: contain;"></a>
</div>
</div>
# GOAT 🐐 (Typescript)
![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/goat-sdk)
## Table of Contents
- [🐐 Overview](#-overview)
- [🚀 Quickstarts](#-quickstarts)
- [🛠️ Supported tools and frameworks](#️-supported-tools-and-frameworks)
- [💻 Contributing](#-contributing)
- [🤝 Community](#-community)
GOAT (Great Onchain Agent Toolkit) is a library that adds more than +200 onchain tools to your AI agent.
# 🐐 Overview
GOAT (Great Onchain Agent Toolkit) is the **largest library of onchain tools** for your AI agent:
* **[+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.
1. Give your agent a **[wallet](https://github.com/goat-sdk/goat/tree/main#chains-and-wallets)**
2. Allow it to transact on **[any chain](https://github.com/goat-sdk/goat/tree/main#chains-and-wallets)**
3. Use more than **[+200 onchain tools](https://github.com/goat-sdk/goat/tree/main#tools)**
4. Use it with **[any agent framework](https://github.com/goat-sdk/goat/tree/main#agent-frameworks)** of your choice
See everything GOAT supports [here](https://github.com/goat-sdk/goat/tree/main#️-supported-tools-and-frameworks).
## 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)
**Create agents that can**
- Transfer funds between wallets
- Swap tokens
- Create and manage DeFi positions
- Create, buy and sell NFTs
- Purchase physical assets onchain with crypto
- Get onchain insights
## 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))
**Lightweight and extendable**
```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
```
Different from other agent kits, GOAT is designed to be lightweight and extendable by keeping its core minimal and allowing you to **install only the tools you need**.
## Usage
1. Configure your wallet
```typescript
import { Connection, Keypair } from "@solana/web3.js";
If you don't find what you need on our more than 200 integrations you can easily:
1. Create your own plugin
2. Integrate a new chain
3. Integrate a new wallet
4. Integrate a new agent framework
const connection = new Connection(process.env.SOLANA_RPC_URL as string);
const keypair = Keypair.fromSecretKey(base58.decode(process.env.SOLANA_PRIVATE_KEY as string));
See how to do it [here](#-contributing).
**License**
```
GOAT is free software, MIT licensed.
2. Configure your tools for the framework you want to use
```typescript
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";
# 🚀 Quickstarts
const tools = await getOnChainTools({
wallet: solana({
keypair,
connection,
}),
plugins: [
sendSOL(),
jupiter(),
splToken(),
],
});
```
***NOTE**: While a quickstart may be implemented for a specific chain, wallet and agent framework, GOAT's flexibility allows you to easily adapt it to any chain, wallet and agent framework without difficulty.*
3. Plug into your agent framework
```typescript
const result = await generateText({
model: openai("gpt-4o-mini"),
tools: tools,
maxSteps: 10,
prompt: "Swap 10 USDC for JLP",
});
- **By use case**
- Send and receive tokens [[EVM](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/evm-send-receive-tokens), [Solana](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/solana-send-receive-tokens), [Chromia](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/chromia-send-receive-tokens), [Cosmos](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/cosmos-send-receive-tokens), [Fuel](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/fuel-send-receive-tokens), [Radix](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/radix-send-receive-tokens)]
- Swap tokens [[EVM](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/evm-swap-tokens), [Solana](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/solana-swap-tokens)]
- Create and manage DeFi positions [[EVM](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/evm-defi-agent), [Solana](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/solana-defi-agent)]
- Mint NFTs [[EVM](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/evm-mint-nft), [Solana](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/solana-mint-nft)]
- Make bets on Polymarket [[EVM](https://github.com/goat-sdk/goat/tree/main/typescript/examples/vercel-ai/polymarket)]
- Launch a token on Pump.fun [[Solana](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-use-case/solana-launch-token)]
- Purchase physical assets [coming soon]
- **By framework**
- [Vercel AI](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-framework/vercel-ai)
- [Langchain](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-framework/langchain)
- [Eliza Agent](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-framework/eliza)
- [GAME Agent](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-framework/virtuals-game)
- [MCP (Model Context Protocol)](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-framework/model-context-protocol)
- [Voice agent with ElevenLabs](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-framework/eleven-labs)
- **By wallet**
- [Crossmint Smart Wallets](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-wallet/crossmint-smart-wallets)
- [Crossmint Custodial Wallets](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-wallet/crossmint-solana-custodial-wallets)
- [Lit](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-wallet/lit)
- [Safe](https://github.com/goat-sdk/goat/tree/main/typescript/examples/by-wallet/safe)
console.log(result);
```
- **See all typescript quickstarts [here](https://github.com/goat-sdk/goat/tree/main/typescript/examples).**
# 🛠️ Supported tools and frameworks
- See [here the full list of supported tools and frameworks](https://github.com/goat-sdk/goat/tree/main#️-supported-tools-and-frameworks)
## How to create a plugin
GOAT plugins enable your agent to interact with various blockchain protocols.
# 💻 Contributing
Do you want a protocol, chain, wallet or agent framework to be supported?
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.
See guides on how to do that here:
- [How to set up the project locally](https://github.com/goat-sdk/goat/tree/main/typescript/docs/2-set-up-the-project-locally.md)
- [How to create a plugin](https://github.com/goat-sdk/goat/tree/main/typescript/docs/3-create-a-plugin.md)
- [How to add a new chain](https://github.com/goat-sdk/goat/tree/main/typescript/docs/4-add-a-new-chain.md)
- [How to add a new wallet provider](https://github.com/goat-sdk/goat/tree/main/typescript/docs/5-add-a-wallet-provider.md)
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) | |
# 🤝 Community
- Follow us on [X](https://x.com/goat_sdk)
- Join our [Discord](https://discord.gg/goat-sdk)