This article provides an independent engineering checklist for AI agents interacting with established Ethereum standards. All example controls and tests are proposed designs, not claims about deployed products.
The callback is a contract boundary, not agent consent
ERC-3156 standardizes interfaces for lenders and borrowers in single-asset flash loans. The borrower receives funds during a transaction and must return principal plus any fee before the transaction ends. This mechanism is powerful in automated workflows, but it should not be confused with an AI agent having general authority to borrow. The standard was created on November 15, 2020. Its borrower callback, onFlashLoan, includes initiator, token, amount, fee, and arbitrary data. Those parameters are inputs to verify, not instructions to obey blindly. A treasury assistant may recommend an operation, but a separate policy contract must define the assets, counterparties, permitted protocols, and maximum loss. Without that division, a prompt or contaminated data feed could become a transaction-authorizing event. The first release gate is therefore proof that the AI recommendation cannot change the lender whitelist or callback acceptance rules.
Verify origin, token and amount before acting
The ERC’s security section warns that callback arguments cannot be assumed genuine without checks. An attacker may call a receiver directly and supply fabricated amounts or data. Test the receiver with an unauthorized lender, an unexpected token, a zero-value amount, an excessive amount, and a fee inconsistent with the lender’s flashFee response. Require a trusted msg.sender and an expected initiator; verify a transaction-specific nonce or intent hash when appropriate. Do not merely compare the callback hash returned by the receiver: that identifies the expected interface response but does not establish economic legitimacy. Place your approval limits in explicit configuration and never let a language-model output become a Solidity parameter without validation. Record who approved an expansion of the token list and which audit reviewed it.
Model approvals as temporary liabilities
For ERC-3156, the receiver normally approves the lender to take principal plus fee before the end of the callback. A careless implementation can leave unlimited allowances, and unrelated code may later consume those permissions. Create an allowance matrix for each token and lender: previous allowance, required amount, expected post-transaction allowance, and cleanup outcome. Test a lender that reverts, a token with unusual allowance behavior, and a callback that exits early. In a sandbox, snapshot balances before and after the full transaction and assert that the expected invariant holds. If the loan transaction fails, no partial accounting entry should be treated as a completed business event. This is where agent orchestration often confuses attempted activity with final settlement. The actual result must come from confirmed chain state, not the AI’s explanation.
Guard oracle-dependent decisions from a one-block illusion
Ethereum’s security guidance describes how flash loans can be used to manipulate spot prices and exploit contracts that rely on fragile oracles. That makes an AI agent’s apparent success in a local simulation especially misleading if the simulation reads a single transient DEX price. Define independent price-deviation and freshness constraints before the model selects a strategy. Use a suitable time-weighted or other robust price source where the use case justifies it, and compare multiple information paths. Then run a test in which a large temporary trade distorts a spot value. The expected outcome is a blocked or separately reviewed decision, not a larger trade. A successful flash-loan callback demonstrates contract execution, not sustainable profit or safe valuation. Separate slippage, gas, loan fee, and oracle uncertainty in reports.
Use a six-case failure matrix instead of a demo
The minimum matrix includes malicious direct callback, unapproved lender, fee tampering, nonstandard token approval, manipulated oracle, and profitable-looking trade that becomes unprofitable after gas. For each case specify the precondition, contract invariant, expected revert or alert, and a reproducible transaction trace. Run the tests against the actual chain environment whenever differences in token behavior matter; a unit-test mock can hide approval quirks. Use fixed seeds for fuzzing and disclose which assumptions were not covered. In particular, a test that only runs against an honest lender cannot justify a claim of general security. Engineers should report both false positives that block legitimate strategies and false negatives that permit unsafe ones. Agent safety is not measured solely by whether transactions completed.
What treasury operators should approve
Before production, require an operator-readable receipt containing the intended asset, lender, amount, fee ceiling, estimated gas, destination, expected net outcome, simulation hash, and policy decision. Freeze the policy version during execution so a later model turn cannot quietly alter the terms. A kill switch must be tested independently of the agent’s chat interface. Reviewers should sign off on allowance cleanup and oracle assumptions, then recheck them after an upgrade. ERC-3156 provides interoperability rules; it does not certify a strategy or guarantee returns. A treasury system earns trust by demonstrating that an AI suggestion can be rejected safely, not by granting it unrestricted control over capital. This analysis is educational engineering guidance rather than financial advice.
Sources
- ERC-3156 Flash Loans (created November 15, 2020)
- Ethereum.org, Smart Contract Security (accessed November 13, 2026)
Cover photo: Egor Komarov / Unsplash. Examples are hypothetical tests, not market data or investment advice.