I built Ledge because I kept seeing demos of AI agents with wallet keys in their .env files, and thought "this is going to end badly."
The core idea: put a policy layer between your agent and the wallet. Before any payment executes, it runs through 4 checks (technical validation, policy limits, context coherence, behavioral patterns). Agent can pay for APIs/data autonomously, but only within rules you set.
Example: your research agent has a $10 budget. It can pay $0.01 per API call for data feeds. But if it tries to send $50 to a random address, or hits the same endpoint 100 times in a minute, Ledge blocks or escalates it.
Built for x402 (pay-per-request protocol), but designed to be modular for other payment rails. Python SDK, supports KMS/Turnkey for production.
Main questions: - Is this solving a real problem or am I overthinking agent security? - What policies would you want that aren't here? - Anyone else building agents that need to pay for stuff?
GitHub: https://github.com/Devendra116/ledge
Would love feedback, especially from folks building autonomous agents or working with crypto payments.