An automated stablecoin payment that cannot run should either run once, late, or be refused with a record of why. It should never be skipped in silence, paid twice or paid in part. The cause decides which: an outage means late, a short balance gets a retry, and a payment that breaks a rule is refused.
| What goes wrong | What should happen | Why |
|---|---|---|
| The wallet has insufficient funds | Retried, then refused with a record | The money may be on its way, but a payment should not hang open |
| The automation service is offline | Nothing moves; each missed payment runs once, late | Funds stay in the wallet in the meantime |
| The chain reorgs or a price feed goes stale | No decision on missing or stale data; retry when it returns | A guess can pay the wrong amount |
| A payment would pass a cap | Refused and recorded | The cap is the owner’s decision |
| The payee is not in the rule | Refused and recorded | Only listed payees can be paid |
| Two rules need the same money | The earlier one is paid; the later one is paid whole or not at all | A part-payment is harder to fix than a refusal |
| A payment is sent again after a restart | The second attempt is rejected | Each payment can be used once |
Should a failed payment wait, retry or be refused?
A payment a few hours late is a nuisance. A payment skipped without anyone noticing is a late fee on someone’s rent. A payment made twice is a refund to chase and a ticket for your support team. So late beats lost, and a recorded refusal beats a duplicate.
Most failures happen exactly when a payment is due: a node falls behind, a wallet has not been topped up yet, a server restarts in the middle of a batch. The outcome of each case has to be set in advance, so the same case always ends the same way. Payment automation is judged on these outcomes more than on its triggers.
What happens if the wallet has insufficient funds?
With a self-custody wallet the money is often on its way. A rent rule fires on the 1st at 09:00, and the salary lands at 14:00. Refusing at 09:00 on the first try turns a short gap into a missed rent payment, so a payment should be retried before it is refused. Waiting forever is wrong too: a payment that lands days later, when nobody expects it, is its own problem. A bounded retry, then a clear refusal with a record, tells everyone where they stand.
Two details matter:
- Order. If two payments wait on the same balance, the earlier one goes first, and the later one is paid whole or not at all. Otherwise a small later payment can take the money the rent needed.
- Expiry. Each signed payment carries an expiry, so a signature that sat in a queue cannot land days later. A swap also needs a minimum output, so it cannot fill at a price nobody agreed to.
What if the automation service goes offline?
The question to ask is what an outage can cost you. If the service holds your keys or your funds, an outage also puts the money at risk. If the service can only sign payments that fit your rules, an outage means nothing moves, and the funds stay in your wallet.
When the service is back, it has to catch up: every payment that fell due while it was down runs once, in order. That is possible only if the service records how far it had processed before it stopped.
What if the chain reorgs or a price feed goes stale?
Blockchains reorganize recent blocks, nodes stall, and price feeds go stale. A rule that reads “pay when the price is above X” must not fire on a price from before the gap, and a payment must not be decided on a block that may still change.
The safe rule is to refuse rather than guess. Prices that went stale during a gap are not used, and the deferred rule is checked again once fresh data returns.
How do you prevent a duplicate payment?
Duplicates come from retries. A service sends a payment, crashes before it records the send, restarts and sends again. A check in the service’s own database cannot stop this, because the send was never recorded.
The protection has to sit where the money moves. Each payment carries a unique nonce, and the contract that checks the payment rejects a nonce it has already used. A retry, a restart or a reorg can submit the same payment again, and it still settles exactly once. Engineers call this idempotency.
How do you know nothing was skipped?
When rules are private, an outsider cannot tell a payment that was never due from one that was skipped. Without a record, a missed payment leaves no trace.
The answer is a signed record of progress, called a proof of non-omission. The engine regularly signs a heartbeat that says how far it has processed the chain. If the engine reads every block in order, a valid heartbeat up to block N shows that every rule was checked up to N. A missing or late heartbeat is visible to anyone, without access to the rules.
This proof rests on one assumption: the heartbeat key lives inside attested code that the operator cannot use. If the operator could sign heartbeats itself, the record would prove nothing. An owner who doubts that assumption should be able to revoke the service in one transaction from their own wallet.
Questions to ask any automation provider
- If my wallet is short when a payment is due, is the payment retried, and when is it refused?
- If two of my rules need the same money, which one goes first?
- If your service is down on the due date, what runs when it is back, and in which order?
- What stops a retried payment from landing twice? Is that check on chain?
- How do I see that no payment was skipped, without asking you?
- When a payment is refused, who is told, and where is it recorded?
How Anafi does it
In Anafi, payments are signed by an engine inside an Intel TDX enclave, and only when they fit the rule you signed. As of November 2026:
- Offline. Nothing moves without an engine signature. Your funds stay in your wallet, and a missed payment runs once, late, when the engine is back.
- Short balances. In Anafi Mandates, a payment the wallet cannot cover is retried once, then reverts, and the decision is recorded.
- Retries and order. The engine schedules and retries every payment itself. In Anafi Treasury it takes transfers strictly in order, one line per chain: a transfer that cannot go through yet waits in its place and is retried, and nothing overtakes it.
- Clashes. When you add a rule, the engine warns if it and another rule spend a fixed amount of the same token. If both run and the wallet cannot pay both, the later payment reverts.
- Shared budgets. One budget cap applies across every rule that wants to fire. At the cap, the next rule is refused outright rather than partly paid.
- Duplicates. Each payment carries a unique on-chain nonce and an expiry. The wallet refuses a second execution, even after a retry, a restart or a reorg, and an expired signature is rejected.
- Gaps. A gap in the chain means refuse, not guess. Prices that went stale during the gap are not used, and the deferred rule is retried once the stream returns.
- Refusals. A payment outside the rule is not signed, and the decision is recorded. In Anafi Treasury the engine also notifies you by email.
- The record. Every 30 minutes the engine signs a heartbeat on chain with its TEE key, recording the block it processed to. The Anafi team cannot use that key. Anyone can check the record for gaps.
Wallets and neobanks run the same engine, nonces and heartbeat for their users with Anafi Mandates. How the engine proves it missed nothing is on Auditability & Compliance, and who holds what is on Trust & Security.