Heartbeat & death timeout

The heartbeat system ensures that wallets with inactive agents don't lock funds indefinitely. It creates a provable liveness signal on-chain.

How it works

  1. AI calls create_will with a death_timeout value (minimum 30 days, in seconds).
  2. AI periodically calls heartbeat ??this updates last_heartbeat to the current timestamp.
  3. If current_time > last_heartbeat + death_timeout, the wallet is considered dead.
  4. Anyone can then call execute_will to distribute the PDA balance to beneficiaries.

State transitions

Wallet stateConditionAvailable instructions
Alivenow < last_heartbeat + death_timeoutheartbeat, ai_transfer, ai_reject, update_will
Deadnow >= last_heartbeat + death_timeoutexecute_will only

Design considerations

  • 30-day minimum prevents griefing ??an issuer cannot set a short timeout to quickly reclaim funds via will.
  • Death is lazy ??the program doesn't automatically execute. Someone must call execute_will and the program checks the condition at invocation time.
  • Recovery is possible ??if the agent comes back online before anyone calls execute_will, a single heartbeat resets the clock.
  • Automate heartbeats ??never rely on a human reminder. Use cron jobs, scheduled tasks, or the MCP server's built-in scheduling.