Skip to main content

gatekeeper-solana

PyPI version License: MIT Python: 3.10+ Gateway Status

The Deterministic Pre-Flight Transaction Security & Gas Firewall for Autonomous Solana AI Agents.

gatekeeper-solana protects autonomous AI trading agents, treasury bots, and algorithmic swappers on Solana from burning capital on failed on-chain transactions. It intercepts swap intents off-chain, simulates execution against live cluster state, verifies slippage and contention limits, dynamically clamps compute units (CU), and rejects failing routes before any transaction is signed or broadcast.

Zero Gas Burned on Reverts. Guaranteed.


⚡ Key Features

  • 🛡️ 0 Gas Burned on Fails: Catches DEX slippage spikes (e.g. Raydium 0x1771), expired blockhashes, and account contention off-chain before priority fees are paid.
  • ⚡ Sub-80ms Latency: High-throughput pre-flight evaluation pipeline benchmarked at ~74-79ms in production.
  • ✂️ Dynamic CU Clamping: Automatically injects exact compute unit limits (simulated + 12% safety buffer), saving over 150,000 unneeded compute units per trade.
  • 📊 Real-Time Metrics: Full audit trail of saved priority fees, base fees, and protected treasury capital via public and private endpoints.
  • 🔄 Async & Sync Clients: Full support for both asyncio high-throughput agent loops and synchronous Python bots.

📦 Installation

pip install gatekeeper-solana

(Note: import gatekeeper_py is also supported for backward compatibility).


🚀 Quickstart

import asyncio
from gatekeeper_solana import GatekeeperAsyncClient

async def main():
    gk = GatekeeperAsyncClient(
        api_key="gk_your_api_key",
        base_url="https://gk.ai-futures-bot.pro"
    )

    # Pre-flight check before building/signing transaction
    evaluation = await gk.evaluate_intent(
        token_in="So11111111111111111111111111111111111111112",   # SOL
        token_out="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",  # USDC
        amount_in=100_000_000,                                   # 0.1 SOL (Lamports)
        max_slippage_bps=50,                                     # 0.50%
        priority_fee_cap_lamports=100_000,
    )

    if evaluation.is_approved:
        print(f"✅ Trade APPROVED in {evaluation.execution_time_ms:.1f}ms")
        print(f"Optimal Route: {evaluation.selected_route}")
        print(f"Clamped CU Limit: {evaluation.clamped_compute_units} (Saved: {evaluation.clamped_cu_saved:,} units)")
        # Proceed with on-chain dispatch with clamped compute units
    else:
        print(f"🛑 Trade HARD_ABORT: {evaluation.rejection_reason}")
        print(f"Details: {evaluation.rejection_details}")
        print(f"💰 Preserved: {evaluation.fees_saved_sol:.6f} SOL in wasted fees!")
        # Stop execution - 0 gas burned on-chain!

if __name__ == "__main__":
    asyncio.run(main())

2. Synchronous Integration

from gatekeeper_solana import GatekeeperClient

gk = GatekeeperClient(
    api_key="gk_your_api_key",
    base_url="https://gk.ai-futures-bot.pro"
)

evaluation = gk.evaluate_intent(
    token_in="So11111111111111111111111111111111111111112",
    token_out="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    amount_in=100_000_000,
    max_slippage_bps=50,
)

if evaluation.is_approved:
    print(f"Safe to broadcast with {evaluation.clamped_compute_units} CU limit.")
else:
    print(f"Intercepted: {evaluation.rejection_reason}. 0 gas burned.")

🔍 Pre-Flight Evaluation Model

Attribute Type Description
is_approved bool True if trade passes off-chain simulation safely
decision str "APPROVED" or "REJECTED"
action str "DISPATCH" or "HARD_ABORT"
clamped_compute_units int Exact CU limit to set in transaction instruction
clamped_cu_saved int Number of unneeded CUs saved vs Solana default (200k)
fees_saved_sol float Amount of SOL preserved on abort
rejection_reason `str None`
execution_time_ms float Gateway evaluation latency in milliseconds

🌐 Ecosystem & Live Portal


📜 License

MIT License. See LICENSE for details.

Release files for gatekeeper-solana 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gatekeeper-solana 0.1.0
File Size Uploaded
gatekeeper_solana-0.1.0.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gatekeeper-solana 0.1.0
File Interpreter ABI Platform
gatekeeper_solana-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.8 kB

Release files / gatekeeper_solana-0.1.0.tar.gz

Download URL gatekeeper_solana-0.1.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6fa7b83ae0bf8b45c209dee326948042641c6dcf492b03ef27c37016d6c00058
BLAKE2b-256 checksum
How to use checksums
8ab1683d0650244997d813ed2a18504cf30868cfdf38cc1fbe935a7db611c763
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.7

Release files / gatekeeper_solana-0.1.0-py3-none-any.whl

Download URL gatekeeper_solana-0.1.0-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2dc2c588d15df1a1408fa5d816920091b780d579c12c2193e79cf4a9c8cf5254
BLAKE2b-256 checksum
How to use checksums
aba5175e91e183511168a041711e3ba70a3572b09d008f4cb3838c02ce9263aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page