Integrate policy-enforced guardrails into any autonomous agent. SDKs, code samples, and framework-specific guides.
Early Development Phase
SDKs are under active development in the monorepo. The API surface shown below represents the intended design — interfaces may change before the stable release.
Clone the monorepo and build the SDK
Deploy registry + policies to Base Sepolia
Register your agent with policy bindings
Wrap agent actions with validate() calls
# Clone the monorepo git clone https://github.com/incyashraj/bouclier.git && cd bouclier # Install & build npm install && cd contracts && forge build && cd ../sdk && npm run build # Deploy to Base Sepolia (set PRIVATE_KEY and BASE_SEPOLIA_RPC) cd ../contracts forge script script/DeployRegistry.s.sol --rpc-url $BASE_SEPOLIA_RPC --private-key $PRIVATE_KEY --broadcast # Run tests forge test -vvv
import { BouclierClient } from "@bouclier/sdk";
import { DynamicTool } from "langchain/tools";
const bouclier = new BouclierClient({ /* config */ });
// Wrap a tool with Bouclier validation
const safeTool = new DynamicTool({
name: "safe-transfer",
description: "Transfer tokens with policy enforcement",
func: async (input) => {
const action = parseTransferInput(input);
// Validate against all attached policies
const check = await bouclier.validate({
agentId: AGENT_ID,
target: action.contract,
value: action.value,
data: action.calldata,
});
if (!check.valid) {
return `Blocked: ${check.reason}`;
}
return await executeTransfer(action);
},
});import { BouclierClient } from "@bouclier/sdk";
const bouclier = new BouclierClient({ /* config */ });
// Agent execution loop
async function agentStep(agentId, action) {
// 1. Validate before execution
const result = await bouclier.validate({
agentId,
target: action.to,
value: action.value,
data: action.data,
});
if (!result.valid) {
console.error("Policy blocked:", result.reason);
return { success: false, reason: result.reason };
}
// 2. Execute the validated action
const tx = await wallet.sendTransaction(action);
return { success: true, hash: tx.hash };
}from web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://sepolia.base.org"))
# Load the registry contract
registry = w3.eth.contract(
address="0x...RegistryAddress",
abi=REGISTRY_ABI,
)
# Check if an agent is active
is_active = registry.functions.isActive(agent_id).call()
# Get attached policies
policies = registry.functions.getPolicies(agent_id).call()
# Validate via policy contract directly
policy = w3.eth.contract(address=policies[0], abi=POLICY_ABI)
is_valid = policy.functions.validate(
agent_id, target, value, calldata
).call()Core SDK for registering agents, attaching policies, and querying the registry. Built on viem.
View sourceReact hooks — useBouclier(), useAgent(), usePolicy(). Built on wagmi + the core SDK.
View sourceNative Rust client for sentinel nodes and high-performance contract interaction.
View sourcePython bindings for AI/ML pipelines. Integrates with web3.py for direct contract calls.
View sourceValidate every agent action before it hits the mempool. Block invalid transactions at the SDK layer.
Stack multiple policy contracts per agent. Transfer limits + scope restrictions + rate limiters — all enforced together.
Works with LangChain, AutoGPT, CrewAI, or any custom agent. One validate() call wraps any outbound action.
Clone the repo, check the docs, and ship your first policy-enforced agent.