---
eip: 8199
label: ERC-8199
title: Sandboxed Smart Wallet
status: Draft
type: Standards Track
category: ERC
created: 2026-03-19
requires: 165, 173, 8023
official: https://eips.ethereum.org/EIPS/eip-8199
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-8199.md
canonical: https://eips.huatuo.xyz/eip-8199/
lang: en
tldr: "A draft interface for a separate smart wallet that AI agents can operate within time windows and pluggable pre/post checks, while the owner's main wallet keeps one-way control to withdraw funds or revoke agents."
tags: [wallet, ai-agents, smart-account, permissions, security]
---

# ERC-8199: Sandboxed Smart Wallet

> Secure agentic automation with time-gated, granular check hooks per agentic invoke

**TL;DR:** A draft interface for a separate smart wallet that AI agents can operate within time windows and pluggable pre/post checks, while the owner's main wallet keeps one-way control to withdraw funds or revoke agents.

## What problem does it solve?

Letting an autonomous agent (for example a trading bot or an AI agent) act from your wallet is risky. The spec looks at the common options and their trade-offs:

- **Session keys** share your main wallet; unless tightly whitelisted, permissions can be evaded, and tight whitelists limit what the agent can do.
- **TEE-based policy engines** are convenient but rely on central trust.
- **Sharing the account key** gives the agent unlimited access unless you approve every action, which defeats automation.

ERC-8199 proposes a different model: put the agent in its **own** smart wallet, fund it with only what the agent should manage, and keep the owner's main wallet completely separate. A bug, compromise or hallucinating agent can then only affect the sandbox, never the owner account.

## How it works

- **One-way relationship.** The sandbox has an `owner()` (as in [ERC-173](/eip-173/)). The owner can call `executeFromOwner` at any time to withdraw assets or run arbitrary calls. The sandbox has no rights over the owner wallet. The spec recommends funding it by transfer rather than token approvals, so there is no link back to the owner.
- **Registered agents.** The owner calls `registerAgents` / `removeAgents`. Each `Agent` has an `agentKey`, a packed validity window (`validAfter` and `validUntil`, two `uint128`s in one `uint256`), and a list of checks.
- **Checks.** Each `Check` points to a `Checker` contract plus `termsData`. Before and after every agent execution, the wallet calls `preCheck` and `postCheck`; either can veto the batch. This is where spending limits or allowed targets live.
- **Agent execution.** `invokeAgentExec(execs, signature)` runs a batch of calls signed by an active agent key. Anyone can relay it, so the agent doesn't need its own gas.
- Several agents can share one sandbox, sharing its assets, address and history. Being a smart wallet also allows gas abstraction, batching and parallel nonces.

## Sample code

A simple `Checker` that only allows calls to an allow-listed set of targets (illustrative):

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

struct Execution { address target; uint256 value; bytes data; }

contract TargetAllowlistChecker {
    // termsData = abi.encode(address[] allowedTargets, uint256 maxValuePerCall)
    function preCheck(Execution[] calldata execs, bytes calldata termsData) external pure returns (bool) {
        (address[] memory allowed, uint256 maxValue) = abi.decode(termsData, (address[], uint256));
        for (uint256 i; i < execs.length; i++) {
            if (execs[i].value > maxValue) return false;
            bool ok;
            for (uint256 j; j < allowed.length; j++) {
                if (execs[i].target == allowed[j]) { ok = true; break; }
            }
            if (!ok) return false;
        }
        return true;
    }

    function postCheck(Execution[] calldata, bytes calldata) external pure returns (bool) {
        return true; // no post-state checks in this example
    }
}
```

Packing an agent's validity window when registering it:

```solidity
uint256 validity = (uint256(validAfter) << 128) | uint256(validUntil);
```

## Things to know

- **Status: Draft.** The interface may change, and backwards compatibility is still marked TBD. The spec doesn't fix which half of `validityTimestamp` holds which value, so check the final version before relying on the packing above.
- The interface leaves out replay protection details; the spec says wallets **should** make agent signatures non-replayable and recommends time-boxed signatures.
- `isAgentActive` should return true only inside the agent's validity window, and agents must be rejected outside it.
- For checker terms, prefer allow-lists over block-lists.
- Gas abstraction (for example via [ERC-4337](/eip-4337/)) is left to the wallet implementer. Ownership can follow ERC-173 or the multi-step [ERC-8023](/eip-8023/).


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-8199
