The AI Understood My Payment Request. My Rust Code Refused It.
An AI that can read "send 0.05 SOL to Ada for lunch" is useful. An AI that can decide to send money is a liability. For the MLH Solana Hackathon, I built SpendGuard , a payment agent for Solana Devnet. You talk to it in plain English. An LLM turns your words into a payment proposal. Deterministic Rust code then decides whether that payment is allowed. You approve the exact transaction, and only…
In the MLH Solana Hackathon, the author developed a payment agent named SpendGuard for the Solana Devnet. SpendGuard allows users to communicate with it in plain English, and an LLM converts those words into a payment proposal. The decision on whether the payment is allowed is made through deterministic Rust code. The user then approves the exact transaction before it is signed and submitted to the Solana Devnet.
The author highlights that the AI understands the payment request, but the Rust code refuses it if it violates predefined rules. For example, a request to send 5 SOL to a recipient fails due to the per-transaction limit of 0.1 SOL. Similarly, a request to send SOL to an unauthorized address is blocked as well.
The LLM's role is to understand the request, while the Rust policy engine is responsible for deciding whether the payment is allowed. The human user provides the final approval before the transaction is signed and submitted. The author emphasizes the importance of separating the understanding of the request from the authorization of the payment, as the LLM can misinterpret instructions or be manipulated, while the Rust policy engine enforces the application's rules.
The author lists four challenges in developing SpendGuard:
1. Concurrency: Similar to card-authorization systems, SpendGuard reserves payment amounts before seeking approval to prevent simultaneous transactions from exceeding the spending limit.
2. Confirmation: The system records transactions as "Submitted" before making the network call, addressing the issue of network timeouts and ensuring that transactions are only declared failed after a certain period with no record on the cluster.
3. Approval prompt construction: The approval prompt is built from the actual transaction message rather than the AI's summary, ensuring that the approved transaction is the same as the one being signed.
4. Money is integers: The author parses decimal text directly instead of using floating-point arithmetic, employing checked operations to prevent arithmetic errors and overflow issues that could lead to silently wrapping around values.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.