> For the complete documentation index, see [llms.txt](https://www.ankitavirani.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.ankitavirani.com/experience/protocols/ercs-and-eips/eip-5792.md).

# EIP-5792

## 📜 EIP-5792: Wallet Contract Interface

EIP-5792 introduces a standard interface for wallet contracts in the Ethereum ecosystem. This page provides a comprehensive overview of its architecture, core concepts, user flow, and implementation details.

### 🏗️ Architecture

The EIP-5792 standard defines a set of interfaces and functionalities for wallet contracts. Here's a high-level overview of the architecture:

<figure><img src="/files/VFwHOIvZFNRgeZ5b7DWA" alt=""><figcaption></figcaption></figure>

### 🧠 Core Concepts

#### 1. Wallet Contract 👛

A smart contract that implements the EIP-5792 interface, allowing it to act as a programmable wallet with advanced features.

#### 2. Signature Validation ✅

The ability to verify signatures, enabling secure transaction authorization.

#### 3. Transaction Execution 🚀

Methods for executing single and batch transactions, providing flexibility in wallet operations.

#### 4. Nonce Management 🔢

A mechanism to prevent replay attacks and ensure transaction uniqueness.

### 🚶 User Flow

Here's a typical user flow for interacting with an EIP-5792 wallet contract:

<figure><img src="/files/fZu09DtsSYOxI1HqEzU2" alt=""><figcaption></figcaption></figure>

### 💻 Implementation Details

#### Wallet Contract Interface

```solidity
interface IERC5792 {
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
    function executeCall(address to, uint256 value, bytes memory data) external payable returns (bytes memory);
    function executeBatch(address[] memory to, uint256[] memory value, bytes[] memory data) external payable returns (bytes[] memory);
    function nonce() external view returns (uint256);
}
```

#### Example Implementation

Here's a basic implementation of an ERC-5792 Wallet Contract:

```solidity
pragma solidity ^0.8.0;

import "./IERC5792.sol";

contract ERC5792Wallet is IERC5792 {
    address public owner;
    uint256 private _nonce;

    constructor(address _owner) {
        owner = _owner;
    }

    function isValidSignature(bytes32 hash, bytes memory signature) external view override returns (bytes4 magicValue) {
        if (recoverSigner(hash, signature) == owner) {
            return 0x1626ba7e; // EIP-1271 magic value
        }
        return 0xffffffff;
    }

    function executeCall(address to, uint256 value, bytes memory data) external payable override returns (bytes memory) {
        require(msg.sender == owner, "Not authorized");
        _nonce++;
        (bool success, bytes memory result) = to.call{value: value}(data);
        require(success, "Call failed");
        return result;
    }

    function executeBatch(address[] memory to, uint256[] memory value, bytes[] memory data) external payable override returns (bytes[] memory) {
        require(msg.sender == owner, "Not authorized");
        require(to.length == value.length && to.length == data.length, "Array length mismatch");
        _nonce++;
        bytes[] memory results = new bytes[](to.length);
        for (uint256 i = 0; i < to.length; i++) {
            (bool success, bytes memory result) = to[i].call{value: value[i]}(data[i]);
            require(success, "Call failed");
            results[i] = result;
        }
        return results;
    }

    function nonce() external view override returns (uint256) {
        return _nonce;
    }

    function recoverSigner(bytes32 hash, bytes memory signature) internal pure returns (address) {
        require(signature.length == 65, "Invalid signature length");
        bytes32 r;
        bytes32 s;
        uint8 v;
        assembly {
            r := mload(add(signature, 32))
            s := mload(add(signature, 64))
            v := byte(0, mload(add(signature, 96)))
        }
        if (v < 27) v += 27;
        require(v == 27 || v == 28, "Invalid signature 'v' value");
        return ecrecover(hash, v, r, s);
    }
}
```

### 🔑 Key Features

* 🔐 Secure signature validation for transaction authorization
* 🚀 Flexible execution of single and batch transactions
* 🔢 Nonce management to prevent replay attacks
* 🔌 Interoperability with existing Ethereum infrastructure
* 🧩 Extensibility for custom wallet implementations

EIP-5792 provides a robust framework for creating standardized wallet contracts, enabling developers to build sophisticated and secure wallet solutions. This standard paves the way for more user-friendly and feature-rich blockchain applications while maintaining high levels of security and flexibility.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.ankitavirani.com/experience/protocols/ercs-and-eips/eip-5792.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
