npm package: @proofgate/goat-plugin
Description: ProofGate transaction validation plugin for GOAT SDK - secure your AI agents
Author: 0xCR6
Latest version: 0.1.0

# @proofgate/goat-plugin

> Transaction validation guardrails for GOAT AI agents 🐐🛡️

[![npm version](https://badge.fury.io/js/@proofgate%2Fgoat-plugin.svg)](https://www.npmjs.com/package/@proofgate/goat-plugin)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## What is this?

This plugin adds **transaction validation** to your GOAT-powered AI agents. Before any blockchain transaction executes, ProofGate checks it against your security guardrails.

Prevents:
- 🚫 Wallet drains from prompt injection
- 🚫 Infinite token approvals
- 🚫 Interactions with unknown contracts
- 🚫 Transactions exceeding your limits

## Installation

```bash
npm install @proofgate/goat-plugin
# or
pnpm add @proofgate/goat-plugin
```

## Quick Start

```typescript
import { proofgate } from '@proofgate/goat-plugin';
import { uniswap } from '@goat-sdk/plugin-uniswap';
import { createGoatAgent } from '@goat-sdk/core';

const agent = createGoatAgent({
  plugins: [
    // Add ProofGate for transaction validation
    proofgate({ 
      apiKey: 'pg_live_xxx', // Get from www.proofgate.xyz
    }),
    // Your other plugins
    uniswap({ ... }),
  ],
});
```

## How It Works

The plugin provides two tools to your agent:

### 1. `proofgate_validate_transaction`

Full validation with detailed checks:

```typescript
// Agent can call this before any transaction
const result = await agent.tools.proofgate_validate_transaction({
  to: '0xContractAddress',
  data: '0x095ea7b3...', // Approval calldata
  value: '0',
});

// Returns:
{
  validationId: 'val_abc123',
  result: 'PASS', // or 'FAIL'
  safe: true,
  reason: 'All checks passed',
  checks: [
    { check: 'chain_support', passed: true, message: '...' },
    { check: 'infinite_approval', passed: true, message: '...' },
  ],
}
```

### 2. `proofgate_is_transaction_safe`

Quick yes/no check:

```typescript
const { safe, reason } = await agent.tools.proofgate_is_transaction_safe({
  to: '0xContractAddress',
  data: '0x...',
});

if (safe) {
  // Execute transaction
} else {
  console.log('Blocked:', reason);
}
```

## Configuration

```typescript
proofgate({
  // Required: Your API key from www.proofgate.xyz
  apiKey: 'pg_live_xxx',
  
  // Optional: Use a specific guardrail for stricter rules
  guardrailId: 'my-guardrail-id',
  
  // Optional: Auto-throw on unsafe transactions (default: true)
  autoBlock: true,
  
  // Optional: Enable debug logging
  debug: false,
});
```

## Supported Chains

All EVM chains supported by GOAT, including:
- Ethereum (1)
- Base (8453)
- Arbitrum (42161)
- Polygon (137)
- Optimism (10)
- And 14 more...

## Creating Guardrails

Define custom security rules at [www.proofgate.xyz/guardrails](https://www.proofgate.xyz/guardrails):

- **Contract whitelists** — Only allow Uniswap, Aave, etc.
- **Approval limits** — Max 1000 USDC per approval
- **Daily spending caps** — $10k/day maximum
- **Slippage protection** — Block trades with >2% slippage

## Pricing

| Tier | Validations/mo | Price |
|------|----------------|-------|
| Free | 100 | $0 |
| Pro | 10,000 | $49/mo |
| Enterprise | Unlimited | Contact |

## Example: Protected DEX Trading

```typescript
import { proofgate } from '@proofgate/goat-plugin';
import { uniswap } from '@goat-sdk/plugin-uniswap';
import { erc20 } from '@goat-sdk/plugin-erc20';

const agent = createGoatAgent({
  plugins: [
    proofgate({ 
      apiKey: process.env.PROOFGATE_API_KEY!,
      guardrailId: 'defi-trading', // Your guardrail
    }),
    uniswap({ ... }),
    erc20(),
  ],
});

// Now your agent's trades are protected!
// ProofGate validates every transaction before execution.
```

## Links

- **Website:** [www.proofgate.xyz](https://www.proofgate.xyz)
- **Get API Key:** [www.proofgate.xyz/dashboard](https://www.proofgate.xyz/dashboard)
- **Guardrails:** [www.proofgate.xyz/guardrails](https://www.proofgate.xyz/guardrails)
- **GOAT SDK:** [github.com/goat-sdk/goat](https://github.com/goat-sdk/goat)

## License

MIT © [0xCR6](https://twitter.com/0xCR6)