Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

Overview

When owners want to automate trading with only a portion of their funds, they decide how much to allocate to trading and how much to retain. The starting point is to reflect that decision in where the funds are held, then automate operations on the trading funds transferred to a separate wallet.

Owner funds and operating funds

Suppose an owner has 100 units of funds and wants to use only 10 units for automated trading while retaining 90 units. If the owner gives a program the same key they use, the program can also access the remaining 90 units controlled by that key. The amount the owner intends to delegate no longer matches the authority actually granted.

An agent is a program that receives instructions, selects recipients or operations to call, and automatically requests their execution. To separate the agent's choice of operations from the scope of funds available for those operations, the owner first transfers the 10 operating units to a separate address. The owner does not share the key or withdrawal authority over the remaining 90 units and allows the agent to operate only on the transferred 10 units.

A smart wallet is a contract at that separate address that verifies signatures and conditions and moves funds. ERC8199 defines an interface for operating agents through a smart wallet isolated from the owner's account. Its official name is Sandboxed Smart Wallet.

In this example, the location of the funds is explicit: 90 units remain with the owner and 10 units are allocated to operations. This does not, however, prevent operations that could lose the 10 units transferred to the operating wallet. Restrictions on operating funds are incorporated into the validity period of registered keys and additional checks.

Agent operations and owner recovery

The owner registers the agent's signing key and the period during which it may be used in the operating wallet. The agent signs the operations it wants to execute, and the wallet checks the key's registration and validity period. If additional conditions have been configured, the wallet checks those too. If necessary, checks can be added to verify call destinations before execution and balances after execution.

To stop operations, the owner revokes the agent's registration. To retrieve remaining funds, the owner executes a separate transfer. Separating key removal from fund recovery means that the agent's key does not need the same authority as the owner's key.

The owner transfers funds to a separate account for the agent to manage, while retaining responsibility for revoking registration and recovering remaining funds

The original diagrams in this article are retained and may contain Japanese labels.

Accepting owner operations at all times is recommended, but recovery from every possible paused state is not mandated as common behavior. Recovery also applies only to assets that remain in the operating wallet and can actually be transferred. It is not a mechanism for reversing transfers of assets already sent to another party.

Motivation

The authority granted to automation depends on which keys are shared, which accounts can be used, and what checks apply to each operation. Separating the operating account combines a decision about where funds reside with verification of execution conditions.

Shared keys and the scope of funds

If owners and agents use the same key, they share the transfer and administrative operations permitted by that key. Requiring owner approval for every operation can restrict autonomous execution, but it also introduces a wait for the owner's response. For applications intended to trade without human intervention, this wait interferes with automation.

Another approach is to register a separate key with time or operation restrictions while continuing to use the same account. A key restricted by time or operation is called a session key. This allows the owner's funds to remain in the same account, while the account checks which operations are permitted and which combinations of calls are allowed.

By contrast, when separating the operating account, the owner transfers the funds to be made available in advance. If the owner transfers 10 units without granting authority to withdraw additional funds from the owner's account, the assets delegated to the agent can be held in that separate account. Fine-grained permissions within one account and transferring funds to a separate account differ in where they isolate the assets subject to operations.

Sharing a key for the same account and transferring funds to a separate account differ in where the assets operated on by the agent are held

Session key implementations can also restrict permitted destinations and amounts. Even if the account is separated, restrictions on operations involving the funds in that account remain a distinct concern. Rather than comparing security based solely on key terminology, check which balances the agent can access and which operations it can perform.

Account isolation and execution conditions

In approaches where an external service checks operations before signing, the service or execution environment responsible for that verification also becomes a trusted component. A TEE can be used to run programs in an isolated execution environment, but the trust assumptions depend on the service architecture. ERC8199 does not require that approach; it adds validity periods and additional checks to the contract holding the operating funds.

For example, even if deposits are limited to 10 units, the agent could lose those 10 units through an incorrect operation if it can transfer the entire balance to arbitrary recipients. The registration period can therefore be restricted, with an additional condition allowing only approved call destinations. The position of a check can be chosen according to what needs verification: the destination before execution, for example, or the asset balance after execution.

This design lets developers decide separately how to isolate the owner's account from the operating account and how to restrict operations in the latter. The wallet and checker contracts define the actual conditions and the mechanism for rejecting operations that violate them.

Specification

The specification defines interfaces for the keys and conditions registered by the owner, the operations submitted for each execution, and checks called before and after operations. Direct owner operations and requests using agent signatures differ in who is authorized to call them.

Direct owner operations and signed agent requests enter the same operating wallet through distinct authorization paths

SandboxedSmartWallet

The owner registers the keys available to agents together with their conditions of use in the wallet. For each request, the agent instead prepares an array of calls to execute and a signature. Conditions established at registration are checked separately against the request data that changes with each execution.

Registered keys and check conditions are distinct from the destinations, amounts, and data submitted for each execution

Agent

solidity
struct Agent {
    address agentKey;
    uint256 validityTimestamp; // pack( uint128 validAfter + uint128 validUntil )
    Check[] checkers;
}

This struct allows the owner to register which key may be used, until when, and under which conditions. Registering a signing address enables the wallet to verify whether a request signature corresponds to a registered agent.

  • Fields
Field Description
agentKey The address of the agent signing operations. It is distinct from the address relaying requests.
validityTimestamp A packed value containing the start and end timestamps during which the key is valid.
checkers An array for registering multiple check destinations and conditions. Each element represents one pair of destination and conditions.

The validity period represents the start and end using 128 bits each, packed into a 256-bit value. However, the specification does not fix whether the start or end occupies the high or low bits, or whether boundary timestamps are inclusive. Confirm the bit layout and equality handling against the wallet implementation's specification.

For example, with an illustrative start of 100 and end of 200, timestamp 99 is before the period, 150 is within it, and 201 is after it. Registration itself remains even outside the validity period, so presence in the registration list alone does not establish that a key is currently usable.

A key can remain registered without being active before or after its validity period

Check

solidity
struct Check {
    address to;
    bytes termsData;
}

This struct combines a checker selected by the owner with the condition data passed to it. It is included in the agent's registration data and used when the wallet invokes checks before or after execution.

  • Fields
Field Description
to The address of the checker contract that verifies conditions. Its purpose differs from that of target, which identifies the operation's execution destination.
termsData A byte sequence containing conditions interpreted by the specified checker.

In an implementation that restricts call destinations, the owner includes approved parties in the condition data, and the checker contract compares those parties with the intended call destinations. The format of the conditions is determined by each checker, so the same byte sequence may not be interpreted as the same condition by another checker.

AgentRegistered

solidity
event AgentRegistered(Agent calldata);

An event emitted when agent registration succeeds. Emitting the event on success is recommended, allowing external monitoring systems to track registration operations through logs.

  • Fields
Field Description
Agent Data representing the registered agent. Its contents are defined by the Agent struct. The specification does not provide a parameter name.

This declaration appears in the specification, but using calldata on an event parameter in this way does not produce a Solidity declaration that compiles as written. Without supplying a parameter name or indexing information, distinguish the intended recording of registration data from the requirements for deployable code. The log also represents an event at registration time; current usability, which may change after expiration or removal, must be checked separately.

AgentRemoved

solidity
event AgentRemoved(Agent calldata);

An event emitted when a registered agent is removed. Emission on successful removal is recommended and can be used to track externally which registration was removed.

  • Fields
Field Description
Agent Data for the agent being removed. No parameter name or indexed modifier is specified.

This declaration also contains calldata on an event parameter, so it cannot be treated as executable code. A removal log alone also does not establish that operating funds have returned to the owner. Verify the recovered assets and amounts from the actual transfer results.

registerAgents

solidity
function registerAgents(Agent[] calldata agents) external;

A function for the owner to register agents' keys and their conditions of use. Multiple agents can be passed as an array in a single call.

  1. Receive the registrations from the owner

    Receive an array of Agent records to register. Only the owner can call this function.

  2. Register the agents

    Register each key and its conditions in the wallet. When registering the same already-valid key again, a revert is recommended.

  3. Record successful registration in logs

    Emitting the AgentRegistered event on success is recommended.

  • Parameters
Parameter Description
agents An array of Agent records to register. Each element includes the conditions of use for its key.
  • Execution conditions

  • The caller is the owner.

  • When re-registering the same valid agentKey, a revert is recommended.

  • The method of updating the same expired key is not specified.

  • Handling of an empty array is not specified.

  • Handling of duplicate keys within the array is not specified.

Successful registration and whether the registered key is currently active are separate determinations. If a key is registered with a start time in the future, its validity period must still be checked before use.

removeAgents

solidity
function removeAgents(Agent[] calldata agents) external;

A function for the owner to remove agents registered in the wallet. It is used to revoke registration without waiting for the validity period to end.

  1. Receive the removal targets from the owner

    Receive an array of agents to remove.

  2. Remove registered keys

    Remove keys with existing registrations. It is recommended not to revert solely because the key is before or after its validity period.

  3. Record successful removal in logs

    Emitting the AgentRemoved event on success is recommended. Transferring the balance to the owner is a separate operation.

  • Parameters
Parameter Description
agents An array of agents to remove. Agents whose registrations still exist can be specified even before or after their validity periods.
  • Execution conditions

  • The caller is the owner.

  • For a registered key, it is recommended not to reject removal solely because the key is outside its validity period.

  • Handling of an unregistered key is not specified.

  • The extent to which the supplied data must match the registration is not specified.

  • Handling of a failure partway through the array is not specified.

getAgents

solidity
function getAgents() external view returns (Agent[] memory);

A function that retrieves all agents registered in the wallet. Because it returns registrations without filtering by validity period, it can be used in administrative interfaces to inspect registration data.

  1. Read registered agents

    Access the registration data held by the wallet.

  2. Return all registrations as an array

    Return registered agents whether they are before, within, or after their validity periods.

  • Return values
Return value Description
agents The return type is Agent[]. It contains all registered agents.
  • Execution conditions

  • This is a view function that does not modify state. There is no restriction in the specification limiting it to the owner.

  • Array ordering is not specified.

  • Pagination is not specified.

  • The maximum number of registrations is not specified.

As the number of registrations increases, both the processing required and the data returned by retrieving the entire array at once increase. Paginated retrieval has been discussed, but is not included in this interface. When selecting usable keys from the returned list, also verify their validity periods.

isAgentActive

solidity
function isAgentActive(address agentKey) external view returns (bool);

A function that returns whether the specified key is registered and the current time falls within its validity period. Because it uses both registration and timing, it distinguishes active keys from keys that merely appear in the list.

  1. Check key registration

    Check the registration of the agent corresponding to the specified address.

  2. Compare the validity period and return the result

    Return true if the key is registered and within its validity period, or false if it is unregistered or outside that period.

  • Parameters
Parameter Description
agentKey The agent's signing address whose validity is being checked.
  • Return values
Return value Description
bool Returns true if both the registration and validity period conditions are satisfied.
  • Execution conditions

  • This is a view function, with no specified restriction on callers.

  • Confirm whether the exact start and end timestamps are inclusive in the wallet implementation.

This determination does not verify signatures for individual operations. Additional checks also handle permitted call destinations and amount restrictions. The decision to execute still requires verification of the submitted operations and signature.

Execution

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

A struct representing a single call to be executed from the wallet. An array of this struct is used both when an agent submits a request and when the owner operates the wallet directly.

  • Fields
Field Description
target The address to call for the operation. It is distinct from the checker destination.
value The amount of native tokens sent with the call.
data The byte sequence encoding the function to call and its arguments.

For a token transfer, the token contract is the execution destination and the recipient and amount are included in the function calldata. In this case, the token amount is included in data, so do not interpret value as the transfer amount for every kind of asset. Checker contracts can inspect the execution data to verify which party is called and what is passed to it.

invokeAgentExec

solidity
function invokeAgentExec(Execution[] calldata execs, bytes calldata signature) external;

A function that submits an array of operations signed by an agent to the wallet. Anyone can relay the request, so the transaction sender is not necessarily the agent itself.

  1. Receive operations and a signature

    A relayer sends the array of operations and signature to the wallet. The signature data includes a signature produced by the registered agent's key.

  2. Verify the signature and conditions of use

    The wallet implementation verifies the signature and checks the key's registration and validity period. If checks are configured, call preCheck before execution.

  3. Execute operations from the wallet

    Send the execution data to the specified destinations. If checks are configured, call postCheck after execution. The scope of rollback when individual calls or checks fail depends on the chosen implementation.

  • Parameters
Parameter Description
execs An array of operations requested for execution. Each element represents one call.
signature A byte sequence containing a signature from the agent's key. It may also include an expiration time specific to that signature if needed.
  • Execution conditions

  • The relayer is not restricted to the owner or the agent itself.

  • Preventing execution outside the key's validity period and preventing reuse of the same signature are recommended.

  • The message to sign and the data format containing that signature are not specified.

  • The exact order of the checks is not specified.

The agent that signs the operations can be separate from the relayer that delivers the signature to the wallet

Separating the relayer does not replace the basis for authorizing an operation with the relayer's own address. The wallet implementation defines how the received signature is bound to the execution data and which registered key it is verified against. Adding a signature expiration time and preventing repeated acceptance of the same signature are also distinct design decisions.

owner

solidity
function owner() external view returns (address);

A function that retrieves the owner address of the operating wallet. This address is used to authorize agent registration and removal, as well as direct execution by the owner.

ERC173 is the basic standard for exposing the current owner through a common function. ERC8199 follows that owner lookup interface. However, exposing this function alone does not imply that the ownership transfer functions and events of ERC173 have also been implemented.

For more on ERC173, see the following article.

[ERC173] Understanding Contract Ownership Control

  1. Read the current owner

    Read the address that the wallet treats as its owner.

  2. Return the owner address

    Return the address used to identify the owner to the caller.

  • Return values
Return value Description
address The wallet's current owner address. Its role differs from that of the agent's signing key.
  • Execution conditions

  • This is a view function, with no specified restriction on callers.

  • The function itself does not include a procedure for changing the owner.

executeFromOwner

solidity
function executeFromOwner(Execution[] calldata execs) external;

A function that allows the owner to execute arbitrary operations directly from the operating wallet. A transfer to recover remaining funds to the owner can also be performed by passing the corresponding execution data to this function.

  1. Accept an operation from the current owner

    Verify that the caller is the address returned by owner. Accept the operation under authority distinct from a signed agent request.

  2. Execute the specified operations

    Execute the calls specified by the owner from the wallet. To recover funds, specify an operation transferring the relevant asset to the owner.

  3. Verify execution results

    If the transfer succeeds, confirm recovery using the asset balance or transfer results.

  • Parameters
Parameter Description
execs An array of operations executed directly by the owner, including transfers and calls to other contracts.
  • Execution conditions

  • Only the address returned by owner can call the function.

  • Accepting owner operations at all times is recommended, but the interaction with pause functionality is not mandated as common behavior.

  • Check the implementation for handling failures partway through the array.

  • Check the implementation to determine whether checks also apply to owner operations.

  • Check the implementation for handling failed transfers of the relevant assets.

Revoking a key's registration and recovering funds are separate operations performed by the owner

Removing an agent's registration leaves the funds in the operating wallet. Recovery requires the owner to execute a separate transfer call. This is also distinct from retrieving funds that have already been transferred outside the wallet.

Checker

A checker contract verifies specified conditions before and after operations. The wallet passes both the execution array and the condition data associated with the checker to each check.

For example, if the conditions concern approved call destinations and balances resulting from a swap, an implementation can verify the former before the operation and the latter afterward. Both checks receive the same pair of inputs, but the balances and state they can inspect change between the pre- and post-execution phases.

The checker receives the same execution data and conditions but can verify different conditions before and after operations

preCheck

solidity
function preCheck(Execution[] calldata execs, bytes calldata termsData) external returns (bool);

A function that checks whether the execution data satisfies the conditions before operations are performed. In an example that verifies approved call destinations, it compares intended destinations with the condition data.

  1. Receive inputs before operations

    Receive execution data and condition data from the wallet.

  2. Verify conditions and return the result

    The checker interprets the conditions and returns a Boolean indicating whether the inputs pass or fail.

  • Parameters
Parameter Description
execs An array of operations scheduled for execution. It is used to verify whether each call meets the registered conditions.
termsData Condition data interpreted by this checker.
  • Return values
Return value Description
bool Indicates whether the pre-execution check passed or failed.
  • Execution conditions

  • This check is called before wallet operations.

  • Check the implementation to determine whether addresses allowed to call the checker are restricted.

  • Check the implementation for the impact of state changes caused by checks.

  • Check the implementation for handling failed external calls.

Returning false and having the wallet revert the entire request are separate actions. How the wallet rejects an operation after receiving the check result is not determined by this function signature alone.

postCheck

solidity
function postCheck(Execution[] calldata execs, bytes calldata termsData) external returns (bool);

A function that verifies results after operations have executed, based on the execution data and conditions. An implementation that checks a swap can read balances after the destination calls finish and verify that the remaining amounts satisfy its conditions.

  1. Receive inputs after operations

    Receive execution data and condition data from the wallet.

  2. Verify post-execution conditions

    If balances are a condition, the checker implementation reads post-execution balances and determines whether they satisfy the condition.

  3. Return the check result

    Return a Boolean indicating success or failure, which the wallet then processes.

  • Parameters
Parameter Description
execs An array of operations to check. Its format does not automatically include pre-execution balances or call return values.
termsData Data conveying post-execution conditions to the checker. The checker determines the format.
  • Return values
Return value Description
bool Indicates whether the post-execution check passed or failed.
  • Execution conditions

  • This check is called after wallet operations.

  • If pre-execution values are needed, the implementation determines how they are recorded and accessed.

  • The scope of rollback when false is returned or the checker fails is not specified.

Additional considerations

Having multiple agents use the same wallet differs from distributing funds across multiple wallets in terms of which balances are shared. Bundling operations into an array should also be distinguished from any guarantee that requests execute in parallel.

Shared balances and multiple agents

When multiple keys are registered in a single operating wallet, the agents use the same balance. They also share the transaction history associated with the wallet address and external assessments of that address. When one agent spends funds, the balance available to another agent changes.

Multiple agents using a single wallet share its funds and address history

To separate operating funds themselves, the owner transfers funds individually to multiple wallets. Registering multiple keys does not automatically create a balance or allocation for each key. If individual budget limits are desired, additional conditions or balance accounting must be implemented.

Multiple operations and parallel execution

Because execution data is an array, multiple calls can be included in a single request. However, whether all operations are rolled back if a call fails partway through, or whether partial success is allowed, is a separate design decision. Consult the wallet implementation for the exact order of calls and whether checks are applied to the entire array or to individual elements.

A number used to prevent repeated execution of the same signature is called a nonce. When multiple agents use the same account, a single sequential counter requires coordination of those numbers across requests. Using two-dimensional numbering in a smart wallet is one option for separating that coordination.

This option does not mean that ERC8199 guarantees a common nonce format or parallel execution. The chosen implementation handles conflicts between requests using the same balance, along with state changes at execution destinations.

Compatibility

Owner lookup is standardized, but ownership transfers, interface discovery, and fee handling remain implementation choices. Distinguish the ability of external tools to call a function with a common name from the availability of additional functionality.

Owner lookup and additional ownership management

An administrative interface can use the current owner address returned by the operating wallet to determine which address holds administrative authority. However, the operation for changing the owner is not defined by that lookup function alone. Check any additional mechanisms implemented for ownership transfer separately.

ERC8023, in which the existing owner initiates and confirms a transfer and the new owner accepts it, can optionally be combined with this design. Under that approach, the current owner retains authority until the new owner's acceptance is complete. An address that has merely been recorded as a prospective owner has no administrative authority.

For more on ERC8023, see the following article.

[ERC8023] Understanding Secure Three-Step Contract Ownership Transfers

A standardized owner lookup does not guarantee compatibility with existing wallets without modification. The backward compatibility section of ERC8199 is marked TBD, and specific migration conditions have not been documented. Check not only the functions available on the target wallet but also how the implementation determines and changes the current owner.

Interface discovery and fee handling

ERC165 provides a way for applications to query the set of functions supported by a contract. Interface discovery is optional under ERC8199, so not every applicable wallet can be required to respond to ERC165. Even when it is supported, a declaration of interface support is distinct from a determination that the implementation is secure.

For more on ERC165, see the following article.

[ERC165] Checking Whether a Contract Supports a Particular Interface

Wallet developers also choose the infrastructure for handling fees. One option is to add ERC4337, which supports combining mechanisms for bundling operation requests and having third parties pay fees. Adding this infrastructure is not a mandatory requirement of ERC8199.

For more on ERC4337, see the following article.

[ERC4337] Implementing Account Abstraction Without Protocol Changes

Owner lookup differs in purpose and whether it is required from extensions for ownership transfer, interface discovery, and fees

The fact that anyone can relay a signature does not automatically provide gas sponsorship. Distinguish the role of delivering signatures from the question of who pays gas fees.

Security

Even after operating funds are isolated in a separate account, check whether requests containing the same signature can be accepted repeatedly. Also verify from the implementation whether checks stop operations that violate conditions and under what conditions the owner can recover funds. Rather than relying on the mere presence of functions, relate these questions to accepted inputs and failure handling.

Signature reuse and two kinds of expiration

A relayer holding a signed request can submit the same request repeatedly. If the wallet accepts the same signature indefinitely, an operation intended to transfer funds only once may execute multiple times. Mechanisms to prevent signature reuse are therefore recommended.

For example, an implementation that rejects previously used numbers must determine which numbers to store, where to store them, and how to bind them to signatures over particular execution data. Neither that mechanism nor the format for binding a signature to a particular wallet or chain is fixed by the common specification. Consult the signature verification implementation to determine what is rejected when a request is resubmitted.

The validity period during which a key may be used is also distinct from an expiration time attached to an individual signature. Even if a key remains registered for a long period, attaching a short expiration to a particular request limits the window in which an old operation can be executed later. An expiration time alone, however, does not prevent an attack that submits the same signature twice within that time window.

Permitted operations and trust in checkers

Even if funds are isolated in an operating account, arbitrary calls could send its balance to unintended recipients. A strategy that blocks only known dangerous parties still permits operations involving other parties that have not been blocked. Allowlist-based conditions that accept only approved parties or operations are therefore recommended.

The implementation determines whether approved parties are specified by address. To restrict functions or amounts, add conditions for those as well. Checkers are external contracts, and their pre- and post-execution functions are not limited to functions that leave state unchanged. The wallet also handles failures of checkers and cases where a checker calls back into the wallet during a check.

An implementation that continues execution after a checker returns a failure cannot stop operations that violate conditions. Verify also whether reentrancy from external calls could cause operations to execute in an unexpected order. The mere existence of check calls cannot be treated as a guarantee that all operations will be rolled back if a condition is violated.

Owner recovery authority and isolation assumptions

If the owner's key is compromised, an attacker can also move operating funds as the owner. Restricting the keys granted to agents does not restrict the owner's own authority. Protect the owner, who holds the authority to revoke registrations and recover funds, including any additional ownership management mechanisms.

Approving token withdrawals from the owner's account by the operating wallet also changes the assumptions behind isolation. It gives the agent that was supposed to operate through a separate account authority to withdraw funds from the owner's side. Transferring initial funds in advance is recommended to avoid introducing this reverse-direction authority.

Recovery also assumes that the assets remain in the wallet and that the transfer succeeds. Accepting owner execution at all times is recommended, but the specification does not mandate how it interacts with pause functionality. Distinguish the existence of a recovery function from the ability to recover funds under every circumstance.

Even after isolating funds, verify signature replay protection, external check results, and owner recovery conditions in the wallet implementation

Conclusion

ERC8199 combines transferring funds delegated to agents into a separate wallet with time-limited keys and pre- and post-execution checks. The owner revokes registration and recovers remaining funds separately; the conditions under which recovery can execute must be verified in the implementation. Handling signature reuse and failed checks must likewise be verified in the chosen implementation.

The relationship between the owner and operating account, the complete interfaces, and the recommendations are documented in the official specification.