# ledgerhq/app-ethereum architecture

> Architecture diagram of the GitHub repository ledgerhq/app-ethereum, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ledgerhq/app-ethereum
- Repository: https://github.com/ledgerhq/app-ethereum

## Overview

This repository implements Ledger’s Ethereum wallet app, with a Python client for issuing APDUs and a device-side application that validates requests, prepares signing data, presents reviews, and returns results. The principal workflow is host requests → device APDU handling → transaction/message processing and user review → signing response. Separate branches cover dynamic metadata, address-book and swap flows, and contract plugins. The README documents these capabilities; some internal command-to-handler wiring is not visible in the sampled excerpts, so uncertain links are omitted.

Main entry points: [`client/src/ledger_app_clients/ethereum/client.py`](https://github.com/ledgerhq/app-ethereum/blob/master/client/src/ledger_app_clients/ethereum/client.py) (Ethereum Client), [`src/features/sign_tx/logic_sign_tx.c`](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/sign_tx/logic_sign_tx.c) (Transaction Signing), [`src/main.c`](https://github.com/ledgerhq/app-ethereum/blob/master/src/main.c) (APDU Dispatch), [`src/features/provide_network_info/network_info.c`](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/provide_network_info/network_info.c) (Network Configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["Host Protocol"]
  node_clientapi["Ethereum Client<br/>[client.py]"]
  node_apdu["APDU Dispatch<br/>[main.c]"]
  node_clientmeta["Metadata Client<br/>[client.py]"]
  node_response["Client Responses<br/>[response_parser.py]"]
end

subgraph group_signing["Signing Workflows"]
  node_txsign["Transaction Signing<br/>[logic_sign_tx.c]"]
  node_txparse["Calldata Parser<br/>[calldata.c]"]
  node_gcs["Generic Clear Signing<br/>[operation_ctx.h]"]
  node_eip712["Typed Data Signing<br/>[typed_data.h]"]
  node_eip712v1["EIP-712 V1 Session"]
  node_messages["Personal Messages<br/>[sign_message.h]"]
  node_auth7702["EIP-7702 Authorization<br/>[auth_7702.c]"]
end

subgraph group_metadata["Runtime Metadata"]
  node_network["Network Configuration<br/>[network_info.c]"]
  node_trusted["Trusted Names<br/>[trusted_name.c]"]
  node_simulation["Transaction Check"]
  node_safe["Safe Accounts<br/>[safe_descriptor.c]"]
  node_gating["Gating Data<br/>[cmd_get_gating.c]"]
  node_networkstate["Network State<br/>[network.c]"]
end

subgraph group_device["Device Integrations"]
  node_review["Review UI<br/>[ui_approve_tx.c]"]
  node_gcsui["Clear-Sign UI<br/>[ui_gcs.c]"]
  node_authui["Authorization UI"]
  node_addressbook["Address Book<br/>[handle_contacts.c]"]
end

subgraph group_extensions["Integrations"]
  node_swap["Swap Support"]
  node_plugins["Contract Plugins"]
end

node_host(("Wallet Client"))

node_host -->|"requests"| node_clientapi
node_clientapi -->|"sends APDUs"| node_apdu
node_apdu -->|"dispatches signing"| node_txsign
node_txsign -->|"parses calldata"| node_txparse
node_txsign -->|"uses clear signing"| node_gcs
node_apdu -->|"handles typed data"| node_eip712
node_eip712v1 -->|"initializes typed data"| node_eip712
node_apdu -->|"handles messages"| node_messages
node_apdu -->|"handles authorization"| node_auth7702
node_authui -->|"confirms or cancels"| node_auth7702
node_gcsui -->|"renders review"| node_gcs
node_clientmeta -->|"uses client transport"| node_clientapi
node_clientapi -->|"parses replies"| node_response
node_clientapi -->|"provides network info"| node_network
node_clientapi -->|"provides trusted names"| node_trusted
node_clientapi -->|"provides simulation"| node_simulation
node_clientapi -->|"provides Safe data"| node_safe
node_clientapi -->|"provides gating"| node_gating
node_network -.->|"updates network state"| node_networkstate
node_txsign -.->|"requests review"| node_review
node_txsign -->|"invokes plugin handling"| node_plugins
node_host -->|"manages contacts"| node_addressbook
node_host -->|"starts swap flow"| node_swap
node_swap -->|"signs swap transaction"| node_txsign

click node_clientapi "https://github.com/ledgerhq/app-ethereum/blob/master/client/src/ledger_app_clients/ethereum/client.py"
click node_apdu "https://github.com/ledgerhq/app-ethereum/blob/master/src/main.c"
click node_txsign "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/sign_tx/logic_sign_tx.c"
click node_txparse "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/generic_tx_parser/calldata.c"
click node_gcs "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/gcs/operation_ctx.h"
click node_eip712 "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/sign_message_eip712/typed_data.h"
click node_eip712v1 "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/sign_message_eip712/eip712_v1_context.c"
click node_messages "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/sign_message/sign_message.h"
click node_auth7702 "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/sign_authorization_eip7702/auth_7702.c"
click node_review "https://github.com/ledgerhq/app-ethereum/blob/master/src/nbgl/ui_approve_tx.c"
click node_gcsui "https://github.com/ledgerhq/app-ethereum/blob/master/src/nbgl/ui_gcs.c"
click node_authui "https://github.com/ledgerhq/app-ethereum/blob/master/src/nbgl/ui_sign_authorization_7702.c"
click node_network "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/provide_network_info/network_info.c"
click node_trusted "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/provide_trusted_name/trusted_name.c"
click node_simulation "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/provide_tx_simulation/cmd_get_tx_simulation.c"
click node_safe "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/provide_safe_account/safe_descriptor.c"
click node_gating "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/provide_gating/cmd_get_gating.c"
click node_addressbook "https://github.com/ledgerhq/app-ethereum/blob/master/src/features/address_book/handle_contacts.c"
click node_swap "https://github.com/ledgerhq/app-ethereum/blob/master/src/swap/handle_swap_sign_transaction.c"
click node_plugins "https://github.com/ledgerhq/app-ethereum/blob/master/src/plugins/eth_plugin_handler.c"
click node_clientmeta "https://github.com/ledgerhq/app-ethereum/blob/master/client/src/ledger_app_clients/ethereum/client.py"
click node_response "https://github.com/ledgerhq/app-ethereum/blob/master/client/src/ledger_app_clients/ethereum/response_parser.py"
click node_networkstate "https://github.com/ledgerhq/app-ethereum/blob/master/src/network.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_clientapi,node_apdu,node_clientmeta,node_response,node_host toneBlue
class node_txsign,node_txparse,node_gcs,node_eip712,node_eip712v1,node_messages,node_auth7702 toneAmber
class node_network,node_trusted,node_simulation,node_safe,node_gating,node_networkstate toneMint
class node_review,node_gcsui,node_authui,node_addressbook toneRose
class node_swap,node_plugins toneIndigo
```

## Components

### Host Protocol

- [Ethereum Client](https://github.com/ledgerhq/app-ethereum/blob/master/client/src/ledger_app_clients/ethereum/client.py): `client/src/ledger_app_clients/ethereum/client.py`
- [APDU Dispatch](https://github.com/ledgerhq/app-ethereum/blob/master/src/main.c): `src/main.c`
- [Metadata Client](https://github.com/ledgerhq/app-ethereum/blob/master/client/src/ledger_app_clients/ethereum/client.py): `client/src/ledger_app_clients/ethereum/client.py`
- [Client Responses](https://github.com/ledgerhq/app-ethereum/blob/master/client/src/ledger_app_clients/ethereum/response_parser.py): `client/src/ledger_app_clients/ethereum/response_parser.py`

### Signing Workflows

- [Transaction Signing](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/sign_tx/logic_sign_tx.c): `src/features/sign_tx/logic_sign_tx.c`
- [Calldata Parser](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/generic_tx_parser/calldata.c): `src/features/generic_tx_parser/calldata.c`
- [Generic Clear Signing](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/gcs/operation_ctx.h): `src/features/gcs/operation_ctx.h`
- [Typed Data Signing](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/sign_message_eip712/typed_data.h): `src/features/sign_message_eip712/typed_data.h`
- [EIP-712 V1 Session](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/sign_message_eip712/eip712_v1_context.c): `src/features/sign_message_eip712/eip712_v1_context.c`
- [Personal Messages](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/sign_message/sign_message.h): `src/features/sign_message/sign_message.h`
- [EIP-7702 Authorization](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/sign_authorization_eip7702/auth_7702.c): `src/features/sign_authorization_eip7702/auth_7702.c`

### Runtime Metadata

- [Network Configuration](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/provide_network_info/network_info.c): `src/features/provide_network_info/network_info.c`
- [Trusted Names](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/provide_trusted_name/trusted_name.c): `src/features/provide_trusted_name/trusted_name.c`
- [Transaction Check](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/provide_tx_simulation/cmd_get_tx_simulation.c): `src/features/provide_tx_simulation/cmd_get_tx_simulation.c`
- [Safe Accounts](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/provide_safe_account/safe_descriptor.c): `src/features/provide_safe_account/safe_descriptor.c`
- [Gating Data](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/provide_gating/cmd_get_gating.c): `src/features/provide_gating/cmd_get_gating.c`
- [Network State](https://github.com/ledgerhq/app-ethereum/blob/master/src/network.c): `src/network.c`

### Device Integrations

- [Review UI](https://github.com/ledgerhq/app-ethereum/blob/master/src/nbgl/ui_approve_tx.c): `src/nbgl/ui_approve_tx.c`
- [Clear-Sign UI](https://github.com/ledgerhq/app-ethereum/blob/master/src/nbgl/ui_gcs.c): `src/nbgl/ui_gcs.c`
- [Authorization UI](https://github.com/ledgerhq/app-ethereum/blob/master/src/nbgl/ui_sign_authorization_7702.c): `src/nbgl/ui_sign_authorization_7702.c`
- [Address Book](https://github.com/ledgerhq/app-ethereum/blob/master/src/features/address_book/handle_contacts.c): `src/features/address_book/handle_contacts.c`

### Integrations

- [Swap Support](https://github.com/ledgerhq/app-ethereum/blob/master/src/swap/handle_swap_sign_transaction.c): `src/swap/handle_swap_sign_transaction.c`
- [Contract Plugins](https://github.com/ledgerhq/app-ethereum/blob/master/src/plugins/eth_plugin_handler.c): `src/plugins/eth_plugin_handler.c`

### Other components

- **Wallet Client**

## Connections

- Wallet Client → Ethereum Client: requests (evidence: `README.md`)
- Ethereum Client → APDU Dispatch: sends APDUs (evidence: `client/src/ledger_app_clients/ethereum/client.py`)
- APDU Dispatch → Transaction Signing: dispatches signing (evidence: `src/main.c`)
- Transaction Signing → Calldata Parser: parses calldata (evidence: `src/features/sign_tx/logic_sign_tx.c`)
- Transaction Signing → Generic Clear Signing: uses clear signing (evidence: `src/features/sign_tx/logic_sign_tx.c`)
- APDU Dispatch → Typed Data Signing: handles typed data (evidence: `src/main.c`)
- EIP-712 V1 Session → Typed Data Signing: initializes typed data (evidence: `src/features/sign_message_eip712/eip712_v1_context.c`)
- APDU Dispatch → Personal Messages: handles messages (evidence: `src/main.c`)
- APDU Dispatch → EIP-7702 Authorization: handles authorization
- Authorization UI → EIP-7702 Authorization: confirms or cancels (evidence: `src/nbgl/ui_sign_authorization_7702.c`)
- Clear-Sign UI → Generic Clear Signing: renders review (evidence: `src/nbgl/ui_gcs.c`)
- Metadata Client → Ethereum Client: uses client transport (evidence: `client/src/ledger_app_clients/ethereum/client.py`)
- Ethereum Client → Client Responses: parses replies (evidence: `client/src/ledger_app_clients/ethereum/client.py`)
- Ethereum Client → Network Configuration: provides network info (evidence: `client/src/ledger_app_clients/ethereum/client.py`)
- Ethereum Client → Trusted Names: provides trusted names (evidence: `client/src/ledger_app_clients/ethereum/client.py`)
- Ethereum Client → Transaction Check: provides simulation (evidence: `README.md`)
- Ethereum Client → Safe Accounts: provides Safe data (evidence: `README.md`)
- Ethereum Client → Gating Data: provides gating
- Network Configuration → Network State: updates network state
- Transaction Signing → Review UI: requests review
- Transaction Signing → Contract Plugins: invokes plugin handling (evidence: `src/features/sign_tx/logic_sign_tx.c`)
- Wallet Client → Address Book: manages contacts (evidence: `README.md`)
- Wallet Client → Swap Support: starts swap flow (evidence: `README.md`)
- Swap Support → Transaction Signing: signs swap transaction (evidence: `src/swap/handle_swap_sign_transaction.c`)
