Putting a robot on a budget you can actually revoke
Agent on a Leash takes an agent-wallet discussion out of a slide deck and puts it next to a big orange button. I deployed the vault on Whitechain Sepolia with 0.12 test WBT. The robot paid 0.07 WBT for a battery and 0.02
Agent on a Leash takes an agent-wallet discussion out of a slide deck and puts it next to a big orange button. I deployed the vault on Whitechain Sepolia with 0.12 test WBT. The robot paid 0.07 WBT for a battery and 0.02 WBT for a bolt. Both purchases showed Whitechain receipts and the vault had 0.03 WBT left. The EchoKit DIY connected over USB once I moved the cable from TTL to OTG.
The robot is scripted. Every action maps to a small catalog owned by the host. The wallet-free rehearsal starts at 12 resettable credits. With LEASH_WBT_PER_CREDIT=0.01, the Whitechain mode keeps the same catalog ratios and settles allowed purchases in native test WBT.
Turn an allowance into a visible state machine
The operator deploys the Solidity vault with a starting balance and two fixed roles. The robot key can purchase from one approved supplier. The operator key can pause spending and reclaim the leftover balance after pause. The robot can choose amount and order ID through the contract, while every transfer still goes to the approved recipient and counts against the remaining budget. The catalog is a demo interface layered on top of those constraints.
This is the intended sequence for a fresh vault. Save the bolt for the post-pause check.
The budget is stored in native units as a uint256. Each successful purchase records its fixed order ID and deducts the amount before forwarding native test WBT. A failed recipient call reverts the entire purchase. If a receipt response gets lost, another submission of the same order ID cannot pay twice. Different order IDs still share the same budget.
paid[order] = true;
remaining -= amount;
(bool ok,) = payable(recipient).call{value: amount}("");
if (!ok) revert TransferFailed();
emit Purchased(order, recipient, amount, remaining);
Keep three outcomes distinct
The host uses viem to simulate before it submits a transaction. A preflight rejection shows the contract rule without consuming testnet gas. When a transaction is submitted, the log shows its hash while waiting for inclusion. A matching successful receipt earns the success label. A timeout leaves the outcome open for the operator to check in the explorer.
await requireTestnet(reader);
const { request } = await reader.simulateContract({
...vault, functionName, args, account,
});
const hash = await walletClient(account).writeContract(request);
return await confirmed(reader, hash, callbacks);
The host reads Whitechain Sepolia chain ID before writes and compares the deployed runtime with the locally compiled contract, allowing for constructor immutables. It also checks the configured signers against the vault role getters. The constructor refuses any chain ID other than 1874.
Two setup fixes from the live run
Fund the signer. The faucet funded the supplier, and the agent received test WBT for purchase gas. The operator still had zero, so deploying the vault failed during gas estimation. Moving test WBT to the operator fixed it. The deploy script now prints which address plays each role and checks balances before attempting deployment. Use npm run deploy -- --check to see those values without broadcasting.
Open the runtime USB port. The LCD displayed Waiting for host while the Node process held /dev/cu.usbserial-110, the TTL bridge on this setup. The Arduino build maps its serial protocol to native USB CDC. Moving the cable to OTG and starting with the Mac's /dev/cu.usbmodem⦠device fixed the connection.
arduino-cli board list
ECHOKIT_PORT=/dev/cu.usbmodemXXXX npm start
K0 sends an event over USB to the same host that serves the browser. The host uses the operator key and shows Pause requested until it verifies the on-chain state. A purchase already in flight can land ahead of pause. Any purchase executing after pause will revert. Six local EVM tests cover vault behavior. The two live purchase receipts and LCD connection are confirmed. A live K0 pause receipt remains to be checked.
For repeat runs, reset in rehearsal mode or deploy a fresh testnet vault. Pause is permanent for a specific deployment. After pause, the operator can reclaim the unused balance.
Code & more: https://www.dailybuild.xyz/project/329-agent-on-a-leash
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.