Skip to main content
The @prflght/sdk package is the lowest-level way to integrate Prflght into your agent. You call firewall.check() before sending any transaction, receive attestation instructions on allow, and catch FirewallDenyError on deny. Every other Prflght integration is built on top of this SDK.

Installation

Initialization

Create a Firewall instance once at startup and reuse it for every transaction check. You need two values:
  • apiUrl — the Prflght API base URL: https://api.prflght.xyz
  • agentId — your agent’s Solana wallet public key as a base58 string

The check() method

Call firewall.check() before sending any transaction. Pass the transaction as a base64-encoded serialized VersionedTransaction. On allow, check() returns an object with an instructions array — these are attestation instructions you must prepend to your transaction before submitting it on-chain. On deny, check() throws a FirewallDenyError with a .reason string describing why the transaction was blocked.
You must prepend the returned attestation instructions to your transaction before sending. The Prflght on-chain program verifies the attestation at execution time — submitting without them will cause the transaction to fail.

Full example

To serialize a VersionedTransaction to base64, use:
Make sure you serialize the transaction after signing but before calling check().

Error handling

FirewallDenyError is thrown whenever Prflght blocks a transaction. Catch it separately from other errors so you can handle policy denials without masking unexpected failures. Common reason strings include:
  • "notional exceeds policy limit" — the transaction value exceeds your agent’s configured spending cap
  • "program not in allowlist" — the transaction calls a Solana program your policy does not permit
  • "slippage exceeds policy limit" — the swap slippage tolerance is above your configured threshold
  • "protocol health check failed" — the DeFi protocol involved has TVL below your minimum health threshold