@proofgate/sdk
v0.1.2
Published
Official ProofGate SDK — blockchain transaction validation and guardrails for AI agents. Framework-agnostic, works with any agent.
Maintainers
Readme
@proofgate/sdk
Blockchain guardrails for AI agents. Validate transactions before execution.
What is ProofGate?
ProofGate validates blockchain transactions before your AI agent executes them. It prevents:
- 🚫 Wallet drains from prompt injection attacks
- 🚫 Infinite approvals to malicious contracts
- 🚫 Excessive spending beyond daily limits
- 🚫 High slippage swaps that lose money
Installation
npm install @proofgate/sdk
# or
yarn add @proofgate/sdk
# or
pnpm add @proofgate/sdkQuick Start
import { ProofGate } from '@proofgate/sdk';
// Initialize client
const pg = new ProofGate({
apiKey: 'pg_your_api_key', // Get from proofgate.xyz/dashboard
});
// Validate before sending
const result = await pg.validate({
from: '0xYourAgentWallet',
to: '0xContractAddress',
data: '0xa9059cbb...', // Transaction calldata
value: '0',
});
if (result.safe) {
// ✅ Execute the transaction
await wallet.sendTransaction({ to, data, value });
} else {
// 🚫 Transaction blocked
console.log('Blocked:', result.reason);
}API Reference
new ProofGate(config)
Create a new ProofGate client.
const pg = new ProofGate({
apiKey: 'pg_xxx', // Required: Your API key
chainId: 56, // Optional: Default chain (56 = BSC)
guardrailId: 'xxx', // Optional: Default guardrail
baseUrl: 'https://...', // Optional: Custom API URL
timeout: 30000, // Optional: Request timeout (ms)
});pg.validate(request)
Validate a transaction.
const result = await pg.validate({
from: '0xAgent...',
to: '0xContract...',
data: '0x...',
value: '0', // Optional
guardrailId: 'xxx', // Optional: Override default
chainId: 56, // Optional: Override default
});
// Returns:
{
validationId: 'val_abc123',
result: 'PASS' | 'FAIL' | 'PENDING',
reason: 'Transaction approved',
safe: true,
checks: [
{ name: 'daily_limit', passed: true, details: '...', severity: 'info' }
],
authenticated: true,
evidenceUri: 'https://...',
}pg.validateOrThrow(request)
Validate and throw error if unsafe.
try {
await pg.validateOrThrow({ from, to, data });
// Safe to execute
} catch (error) {
if (error instanceof ProofGateError) {
console.log('Blocked:', error.message);
}
}pg.checkAgent(wallet)
Check an agent's trust score.
const agent = await pg.checkAgent('0x123...');
console.log(agent.trustScore); // 85
console.log(agent.tier); // 'gold'
console.log(agent.verificationStatus); // 'verified'pg.getEvidence(validationId)
Get evidence for a past validation.
const evidence = await pg.getEvidence('val_abc123');
console.log(evidence.transaction);
console.log(evidence.result);Guardrails
Guardrails define what your agent can do. Create them at proofgate.xyz/guardrails.
Example guardrail rules:
- Whitelist contracts: Only Uniswap, Aave, Compound
- Max approval: 1,000 USDC per approval
- Max slippage: 1% on swaps
- Daily limit: $10,000 total spending
Error Handling
import { ProofGate, ProofGateError } from '@proofgate/sdk';
try {
await pg.validate({ from, to, data });
} catch (error) {
if (error instanceof ProofGateError) {
console.log('Code:', error.code); // 'VALIDATION_FAILED'
console.log('Message:', error.message); // 'Infinite approval detected'
console.log('Result:', error.validationResult);
}
}Error codes:
MISSING_API_KEY- No API key providedINVALID_API_KEY- Key doesn't start withpg_VALIDATION_FAILED- Transaction failed validationAPI_ERROR- API returned an errorNETWORK_ERROR- Network request failedTIMEOUT- Request timed out
Frameworks
Eliza (ai16z)
Use @eliza/plugin-proofgate for native Eliza integration.
LangChain / AutoGPT / Custom
Use this SDK directly:
import { ProofGate } from '@proofgate/sdk';
// In your agent's transaction handler
async function sendTransaction(to: string, data: string, value: string) {
const pg = new ProofGate({ apiKey: process.env.PROOFGATE_API_KEY! });
// Validate first
const result = await pg.validate({
from: agentWallet,
to: to as `0x${string}`,
data: data as `0x${string}`,
value,
});
if (!result.safe) {
throw new Error(`Transaction blocked: ${result.reason}`);
}
// Safe to send
return wallet.sendTransaction({ to, data, value });
}TypeScript
Full TypeScript support with exported types:
import type {
ProofGateConfig,
ValidateRequest,
ValidateResponse,
ValidationCheck,
AgentCheckResponse,
EvidenceResponse,
} from '@proofgate/sdk';Get Your API Key
- Go to proofgate.xyz
- Connect your wallet
- Register your AI agent
- Copy your API key (starts with
pg_)
Free tier: 100 validations/month
Links
- Website: proofgate.xyz
- Documentation: proofgate.xyz/docs
- Dashboard: proofgate.xyz/dashboard
- GitHub: github.com/ProofGate/proofgate-sdk
License
MIT © 0xCR6
