Skip to content
项目

关于

Ethereum wallet application for Ledger devices

其他项目

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

app-ethereum

Ethereum wallet application for Ledger devices
« Explore the docs »

Report Bug · Request Feature · Request New Network


Guidelines Functional tests codecov Code style License: Apache-2.0


Table of Contents

About the project

Ethereum wallet application framework for Ledger devices.

Documentation

This app follows the specification available in the doc/ folder:

  • APDU protocol: list and coding of all the supported commands.
  • TLV structures: signed descriptors sent by the client (trusted names, networks, Generic Clear Signing, EIP-712 V2, ...).
  • EIP-712: typed data signing, V1 with filtering and V2.
  • Generic Clear Signing: implementation of the Generic Clear Signing flow.
  • Plugins: technical specifications of the legacy plugin interface.
  • Embedded contract support: contracts natively supported by the app.

To compile it and load it on a device, please check out our developer portal.

Features

Beyond the plain transaction and message signing, the app relies on signed metadata provided at runtime by the client (Ledger Wallet, DMK) to clear sign transactions without requiring an app update.

Generic Clear Signing

Contract calls are clear signed from an ERC-7730 description, sent by the client as signed TLV descriptors: PROVIDE OPERATION INFO describes the call, then each displayed field comes with a PROVIDE OPERATION FIELD DESCRIPTION. Additional descriptors resolve some of the values:

See doc/gcs.md for the implementation details.

Typed messages (EIP-712)

The app signs EIP-712 messages and computes their hashes itself. Two protocols are supported, see doc/eip712.md:

  • V1 streams the types and the values field by field. A signed filtering description chooses which fields to show and how, see EIP712 FILTERING.
  • V2 sends the schema and the values as two TLV payloads, with EIP712 SEND STRUCT DEFINITION and EIP712 SEND STRUCT IMPLEMENTATION. A signed message info and its field descriptors clear sign the message like a transaction, with the same formatters and from the same ERC-7730 description. Without them, every value is shown raw, which is blind signing. See EIP712 V2.

Trusted names

An address can be replaced on screen by a name (ENS domain, known contract, ...), provided as a signed descriptor with PROVIDE TRUSTED NAME.

EVM networks

Any EVM network can be used without updating the app: the client provides its configuration at runtime with the PROVIDE NETWORK INFO command.

  • The configuration (chain ID, name, ticker and icon hash) is a signed TLV descriptor, see NETWORK_INFO.
  • The icon is sent separately as raw bytes, and is only used on Stax, Flex and Apex P.
  • Provided networks stay in memory until the app exits. Sending a configuration for an already known chain ID replaces it.
  • When the network is unknown, the raw chain ID is displayed instead of its name.

The APDU coding is described in PROVIDE NETWORK INFO.

Adding a new network does not require any change in this repository: follow the procedure in ledger-network-icons.

Transaction Check

On Stax, Flex and Apex P, the client can provide a risk assessment of the transaction or message being signed, with PROVIDE TX SIMULATION. It is displayed during the review only when the Transaction Check setting is enabled (disabled by default); the client can trigger an opt-in flow to propose it.

Safe accounts

When signing for a Safe multisig account, the client provides the Safe account and its signers with PROVIDE SAFE ACCOUNT, so that the user can verify them.

Address book

The user can register contacts (a name associated with an address) and name their own Ledger accounts. The registered names are then displayed during the review in place of the addresses. This feature is provided by the SDK, see its specification.

Swap

The app can be called in library mode by the Exchange app, to check addresses, format amounts and sign the transaction of a swap, sell or fund operation.

Plugins

Plugins are no longer supported: new integrations must use Generic Clear Signing instead.

Quick start guide

With VSCode

You can quickly setup a convenient environment to build and test your application by using Ledger's VSCode developer tools extension which leverages the ledger-app-dev-tools docker image.

It will allow you, whether you are developing on macOS, Windows or Linux, to quickly build your apps, test them on Speculos and load them on any supported device.

  • Install and run Docker.
  • Make sure you have an X11 server running:
    • On Ubuntu Linux, it should be running by default.
    • On macOS, install and launch XQuartz (make sure to go to XQuartz > Preferences > Security and check "Allow client connections").
    • On Windows, install and launch VcXsrv (make sure to configure it to disable access control).
  • Install VScode and add Ledger's extension.
  • Open a terminal and clone app-ethereum with git clone [email protected]:LedgerHQ/app-ethereum.git.
  • Open the app-ethereum folder with VSCode.
  • Use Ledger extension's sidebar menu or open the tasks menu with ctrl + shift + b (command + shift + b on a Mac) to conveniently execute actions:
    • Build the app for the device model of your choice with Build.
    • Test your binary on Speculos with Run with Speculos.
    • You can also run functional tests, load the app on a physical device, and more.

The terminal tab of VSCode will show you what commands the extension runs behind the scene.

With a terminal

The ledger-app-dev-tools docker image contains all the required tools and libraries to build, test and load an application.

You can download it from the ghcr.io docker repository:

sudo docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

You can then enter this development environment by executing the following command from the root directory of the application git repository:

Linux (Ubuntu)

sudo docker run --rm -ti --user "$(id -u):$(id -g)" --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath .):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

macOS

sudo docker run  --rm -ti --user "$(id -u):$(id -g)" --privileged -v "$(pwd -P):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

Windows (with PowerShell)

docker run --rm -ti --privileged -v "$(Get-Location):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

The application's code will be available from inside the docker container, you can proceed to the following compilation steps to build your app.

Compilation and load

To easily setup a development environment for compilation and loading on a physical device, you can use the VSCode integration whether you are on Linux, macOS or Windows.

If you prefer using a terminal to perform the steps manually, you can use the guide below.

Compilation

Setup a compilation environment by following the shell with docker approach.

Be sure you checkout the submodule:

git submodule update --init

From inside the container, use the following command to build the app:

make DEBUG=1  # compile optionally with PRINTF

EIP-7702 support (authorization signing, "Smart accounts" setting and type 4 transactions) is not part of the default build. Enable it with EIP7702_SUPPORT=1:

make EIP7702_SUPPORT=1

You can choose which device to compile and load for by setting the BOLOS_SDK environment variable to the following values:

  • BOLOS_SDK=$NANOX_SDK
  • BOLOS_SDK=$NANOSP_SDK
  • BOLOS_SDK=$STAX_SDK
  • BOLOS_SDK=$FLEX_SDK
  • BOLOS_SDK=$APEX_P_SDK

Loading on a physical device

This step will vary slightly depending on your platform.

Your physical device must be connected, unlocked and the screen showing the dashboard (not inside an application).

Linux (Ubuntu)

First make sure you have the proper udev rules added on your host. See udev-rules

Then once you have opened a terminal in the app-builder image and built the app for the device you want, run the following command:

# Run this command from the app-builder container terminal.
make load    # load the app on the device selected by BOLOS_SDK

Setting the BOLOS_SDK environment variable will allow you to load on whichever supported device you want.

macOS / Windows (with PowerShell)

It is assumed you have Python installed on your computer.

Run these commands on your host from the app's source folder once you have built the app for the device you want:

# Install Python virtualenv
python3 -m pip install virtualenv
# Create the 'ledger' virtualenv
python3 -m virtualenv ledger

Enter the Python virtual environment

  • macOS: source ledger/bin/activate
  • Windows: .\ledger\Scripts\Activate.ps1
# Install Ledgerblue (tool to load the app)
python3 -m pip install ledgerblue
# Load the app.
python3 -m ledgerblue.runScript --scp --fileName bin/app.apdu --elfFile bin/app.elf

Tests

The Ethereum app comes with different tests:

  • Functional Tests implemented with Ledger's Ragger test framework.
  • Unit Tests, allowing to test basic simple functions

Functional Tests (Ragger based)

📚 For a comprehensive overview of all tested functionalities, see the Test Documentation.

Linux (Ubuntu)

On Linux, you can use Ledger's VS Code extension to run the tests. If you prefer not to, open a terminal and follow the steps below.

Install the tests requirements:

pip install -r tests/functional/requirements.txt

Then you can:

Run the functional tests (here for flex but available for any device once you have built the binaries):

pytest tests/functional/ --tb=short -v --device flex

Please see the corresponding documentation USAGE

Or run your app directly with Speculos

speculos build/flex/bin/app.elf

macOS / Windows

To test your app on macOS or Windows, it is recommended to use Ledger's VS Code extension to quickly setup a working test environment.

You can use the following sequence of tasks and commands (all accessible in the extension sidebar menu):

  • Select build target
  • Build app

Then you can choose to execute the functional tests:

  • Use Run tests.

Or simply run the app on the Speculos emulator:

  • Run with Speculos.

Unit Tests

Those tests are available in the directory tests/unit. Please see the corresponding README to compile and run them.

Contributing

Contributions are what makes the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag enhancement.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/my-feature)
  3. Commit your Changes (git commit -m 'feat: my new feature')
  4. Push to the Branch (git push origin feature/my-feature)
  5. Open a Pull Request

Please try to follow Conventional Commits.

探索相关项目

加载中…