Skip to main content

Official ProofGate SDK — blockchain transaction validation and guardrails for AI agents

Project description

proofgate

Blockchain guardrails for AI agents. Validate transactions before execution.

PyPI version Python 3.8+ License: MIT

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

pip install proofgate

Quick Start

Synchronous Usage

from proofgate import ProofGate

# Initialize client
pg = ProofGate(api_key="pg_your_api_key")  # Get from proofgate.xyz/dashboard

# Validate before sending
result = pg.validate(
    from_address="0xYourAgentWallet",
    to="0xContractAddress",
    data="0xa9059cbb...",  # Transaction calldata
    value="0",
)

if result.safe:
    # ✅ Execute the transaction
    wallet.send_transaction(to=to, data=data, value=value)
else:
    # 🚫 Transaction blocked
    print(f"Blocked: {result.reason}")

Async Usage

from proofgate import AsyncProofGate

async def main():
    async with AsyncProofGate(api_key="pg_your_api_key") as pg:
        result = await pg.validate(
            from_address="0xYourAgentWallet",
            to="0xContractAddress",
            data="0xa9059cbb...",
        )
        
        if result.safe:
            # Execute transaction
            pass

API Reference

ProofGate(config) / AsyncProofGate(config)

Create a new ProofGate client.

pg = ProofGate(
    api_key="pg_xxx",           # Required: Your API key
    chain_id=56,                 # Optional: Default chain (56 = BSC)
    guardrail_id="xxx",          # Optional: Default guardrail
    base_url="https://...",      # Optional: Custom API URL
    timeout=30.0,                # Optional: Request timeout (seconds)
)

pg.validate(request)

Validate a transaction.

result = pg.validate(
    from_address="0xAgent...",
    to="0xContract...",
    data="0x...",
    value="0",           # Optional
    guardrail_id="xxx",  # Optional: Override default
    chain_id=56,         # Optional: Override default
)

# Returns ValidateResponse with:
# - validation_id: str
# - result: "PASS" | "FAIL" | "PENDING"
# - reason: str
# - safe: bool
# - checks: List[ValidationCheck]
# - authenticated: bool
# - evidence_uri: str

pg.validate_or_throw(request)

Validate and raise exception if unsafe.

from proofgate import ProofGateError

try:
    pg.validate_or_throw(
        from_address=from_addr,
        to=to_addr,
        data=calldata,
    )
    # Safe to execute
except ProofGateError as e:
    print(f"Blocked: {e.message}")

pg.check_agent(wallet)

Check an agent's trust score.

agent = pg.check_agent("0x123...")

print(agent.trust_score)         # 85
print(agent.tier)                # "gold"
print(agent.verification_status) # "verified"

pg.get_evidence(validation_id)

Get evidence for a past validation.

evidence = pg.get_evidence("val_abc123")
print(evidence.transaction)
print(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

from proofgate import ProofGate, ProofGateError

try:
    pg.validate(from_address=from_addr, to=to_addr, data=calldata)
except ProofGateError as e:
    print(f"Code: {e.code}")          # "VALIDATION_FAILED"
    print(f"Message: {e.message}")    # "Infinite approval detected"
    print(f"Result: {e.validation_result}")

Error codes:

  • MISSING_API_KEY - No API key provided
  • INVALID_API_KEY - Key doesn't start with pg_
  • VALIDATION_FAILED - Transaction failed validation
  • API_ERROR - API returned an error
  • NETWORK_ERROR - Network request failed
  • TIMEOUT - Request timed out

Type Hints

Full type hints included:

from proofgate import (
    ProofGateConfig,
    ValidateRequest,
    ValidateResponse,
    ValidationCheck,
    AgentCheckResponse,
    EvidenceResponse,
)

Get Your API Key

  1. Go to proofgate.xyz
  2. Connect your wallet
  3. Register your AI agent
  4. Copy your API key (starts with pg_)

Free tier: 100 validations/month

Links

License

MIT © 0xCR6

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

proofgate-0.1.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

proofgate-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file proofgate-0.1.0.tar.gz.

File metadata

  • Download URL: proofgate-0.1.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for proofgate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3fc4f15eaa08f3327dd26f6b74be1ee9eb11c9ea5469d42c0257b8ebedb15813
MD5 e2bff49f5576d09628a2b67c477adc5d
BLAKE2b-256 cb4985607393d1c0caad45149ed2c16cb6a1990a4490867b484f27f64c8d345b

See more details on using hashes here.

File details

Details for the file proofgate-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: proofgate-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for proofgate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e053df73e6a1806808a852e82c77902302a0a2dfd02631fd8cc8f30f781f821
MD5 d60c9c1efaa0111d5db4172a3a9878bf
BLAKE2b-256 931e17d78ccbc0c35c14e5e13685f8df867e9d96831975dae072d2e61f64015f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page