GOAT Network
AgentKit

Quick Start

This guide gives you two entry paths into GOAT Network agent infrastructure:

  • Manual installation when you want to add AgentKit to an existing agent, app, or runtime
  • CLI scaffolding when you want a ready-to-run starter project

After that, you can configure the runtime, attach a wallet provider, and execute your first on-chain action.

The official AgentKit product page positions manual installation as the recommended path for existing agents and apps. Use the CLI when you want a generated starter project.

Prerequisites

  • Node.js 18+ and pnpm (or npm)
  • A GOAT Network RPC endpoint. Use mainnet by default at https://rpc.goat.network; use testnet examples with https://rpc.testnet3.goat.network.

Choose Your Start Path

Terminal
npm install @goatnetwork/agentkit
Terminal
npm create goat-agent
# Follow prompts: project name → preset (minimal/defi/full) → network
cd my-agent && pnpm start

AgentKit bundles its core dependencies (ethers, viem, zod, ioredis) so you do not need to install them separately.

Use this path when your agent or app already exists and you need to add GOAT Network capabilities without replacing your runtime.

Create the ActionProvider and register actions

The ActionProvider is the central registry for all actions your agent can perform.

src/index.ts
import { ActionProvider } from '@goatnetwork/agentkit/providers';
import { walletBalanceAction, NoopWalletReadAdapter } from '@goatnetwork/agentkit/plugins';

const provider = new ActionProvider();

// Register wallet balance action with a read adapter
const walletRead = new NoopWalletReadAdapter();
provider.register(walletBalanceAction(walletRead));

// See all registered actions
console.log('Actions:', provider.list().map(a => a.name));

Configure the Policy Engine

The PolicyEngine gates every action execution based on network, risk level, and write permissions.

src/index.ts
import { PolicyEngine } from '@goatnetwork/agentkit/core';

const policy = new PolicyEngine({
  allowedNetworks: ['goat-testnet'],
  maxRiskWithoutConfirm: 'low',   // 'read' | 'low' | 'medium' | 'high'
  writeEnabled: true,
});

Create the ExecutionRuntime

The runtime wraps policy evaluation, input validation, retries, idempotency, timeout, and metrics into a single run() call.

src/index.ts
import { ExecutionRuntime } from '@goatnetwork/agentkit/core';

const runtime = new ExecutionRuntime(policy, {
  maxRetries: 2,
  retryDelayMs: 200,
});

Execute an action

Every action runs through the runtime with a context object and input parameters.

src/index.ts
const context = {
  traceId: 'trace_001',
  network: 'goat-testnet',
  now: Date.now(),
  caller: 'my-agent',
};

const result = await runtime.run(
  provider.get('wallet.balance'),
  context,
  { address: '0x000000000000000000000000000000000000dEaD' }
);

console.log(result);
// { ok: true, output: { address: '0x...', balance: '0' }, traceId: 'trace_001', action: 'wallet.balance', attempts: 1 }

CLI Scaffolding Path

The published create-goat-agent CLI generates a ready-to-run starter project with the correct AgentKit structure.

It will prompt you for:

  1. Project name -- your agent project folder
  2. Preset -- minimal (wallet only), defi (wallet + bridge + bitcoin), or full (all 13 plugins)
  3. Network -- goat-testnet or goat-mainnet

The CLI generates a complete project with package.json, tsconfig.json, .env.example, and a src/index.ts with all chosen plugins pre-registered.

If you choose the CLI path, use the generated project as your baseline and then continue with the runtime, wallet, and plugin setup above.

Full Minimal Example

Here is the complete working example that combines all the steps above:

src/index.ts
import { ActionProvider } from '@goatnetwork/agentkit/providers';
import { PolicyEngine, ExecutionRuntime } from '@goatnetwork/agentkit/core';
import { walletBalanceAction, NoopWalletReadAdapter } from '@goatnetwork/agentkit/plugins';

// 1. Register actions
const provider = new ActionProvider();
provider.register(walletBalanceAction(new NoopWalletReadAdapter()));

// 2. Configure policy
const policy = new PolicyEngine({
  allowedNetworks: ['goat-testnet'],
  maxRiskWithoutConfirm: 'low',
  writeEnabled: true,
});

// 3. Create runtime
const runtime = new ExecutionRuntime(policy, {
  maxRetries: 2,
  retryDelayMs: 200,
});

// 4. Execute
const result = await runtime.run(
  provider.get('wallet.balance'),
  { traceId: 'trace_001', network: 'goat-testnet', now: Date.now() },
  { address: '0x000000000000000000000000000000000000dEaD' }
);

console.log(result);

Using a Real Wallet Provider

For production use, replace the Noop adapters with real wallet providers. AgentKit ships two implementations:

src/wallet.ts
import { JsonRpcProvider, Wallet } from 'ethers';
import { EvmWalletProvider } from '@goatnetwork/agentkit/core';

const provider = new JsonRpcProvider('https://rpc.testnet3.goat.network');
const signer = new Wallet(process.env.PRIVATE_KEY!, provider);

const wallet = new EvmWalletProvider(signer, provider, 'goat-testnet');
src/wallet.ts
import { privateKeyToAccount } from 'viem/accounts';
import { http } from 'viem';
import { ViemWalletProvider } from '@goatnetwork/agentkit/core';

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const chain = {
  id: 48816,
  name: 'goat-testnet',
  nativeCurrency: { name: 'BTC', symbol: 'BTC', decimals: 18 },
  rpcUrls: { default: { http: ['https://rpc.testnet3.goat.network'] } },
};

const wallet = new ViemWalletProvider(
  account,
  chain,
  http('https://rpc.testnet3.goat.network'),
  'goat-testnet'
);

NoopWalletProvider throws an error if used in production (NODE_ENV=production). Always use EvmWalletProvider or ViemWalletProvider for real deployments.

Environment Variables

Create a .env file based on the example:

.env
# GOAT Network RPC
GOAT_MAINNET_RPC_URL=https://rpc.goat.network
GOAT_TESTNET_RPC_URL=https://rpc.testnet3.goat.network

# Wallet
PRIVATE_KEY=0x...

# Idempotency store: memory | redis
AGENTKIT_IDEMPOTENCY_MODE=memory
# Used when mode is redis
AGENTKIT_REDIS_URL=redis://127.0.0.1:6379

# x402 Merchant gateway (if using payment features)
MERCHANT_API_BASE_URL=https://merchant.example.com
MERCHANT_API_KEY=

# x402 Merchant Portal (if using merchant management)
MERCHANT_PORTAL_BASE_URL=http://localhost:8080

# Prometheus metrics port
AGENTKIT_METRICS_PORT=9464

The latest AgentKit network config sets goat-testnet to chain ID 48816 and uses https://rpc.testnet3.goat.network as the default testnet RPC endpoint.

Export Tools for Your AI Framework

Once you have actions registered, export them as tools for your AI framework with a single call:

src/export-tools.ts
// Get tool definitions for any framework
const openaiTools = provider.openAITools();
const langchainDefs = provider.langChainToolDefs();
const mcpTools = provider.mcpTools();
const vercelTools = provider.vercelAITools();
const agentsSdkTools = provider.openAIAgentsTools();

console.log('OpenAI tools:', JSON.stringify(openaiTools, null, 2));

See the Frameworks guide for detailed integration instructions.

Next Steps

On this page