This is the Mintlayer Ledger application for the Ledger Nano X, Nano S+, Stax, Flex and Nano Gen 5 devices.
ℹ️ Nano Gen 5 is usually referred to by its codename, Apex P.
You can quickly set up a development environment on any platform (macOS, Linux or Windows) to build and test your application with Ledger's VS Code extension.
By using Ledger's own developer tools Docker image, the extension allows you to build your apps with the latest SDK, test them on Speculos and load them on any supported device.
- Install and run Docker.
- Make sure you have an X11 server running :
- Install VS Code and add Ledger's extension.
- Open a terminal and clone
mintlayer-ledger-appwithgit clone [email protected]:mintlayer/mintlayer-ledger-app.git. - Open the
mintlayer-ledger-appfolder with VS Code. - Use Ledger extension's sidebar menu or open the tasks menu with
ctrl + shift + b(command + shift + bon a Mac) to conveniently execute actions :- Build the app for the device model of your choice with
Build. - Test your binary on the Speculos emulator with
Run with emulator. - You can also run functional tests, load the app on a physical device, and more.
- Build the app for the device model of your choice with
ℹ️ The terminal tab of VS Code will show you what commands the extension runs behind the scene.
If you do not wish to use the VS Code extension, you can follow the following steps to set up a development environment on Linux, Windows or macOS.
-
The ledger-app-dev-tools Docker image contains all the required tools and libraries to build, test and load an application on a device. You can download it from the ghcr.io docker repository:
docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest
-
Make sure you have an X11 server running :
-
You can then enter into this development environment by executing the following command from the directory of the application (
gitrepository):- Linux (Ubuntu):
docker run --user "$(id -u)":"$(id -g)" --rm -ti --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath .):/app" --publish 5000:5000 --publish 9999:9999 -e DISPLAY=$DISPLAY -v '/tmp/.X11-unix:/tmp/.X11-unix' ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest
- macOS:
docker run --user "$(id -u)":"$(id -g)" --rm -ti --privileged -v "$(pwd -P):/app" --publish 5000:5000 --publish 9999:9999 -e DISPLAY='host.docker.internal:0' -v '/tmp/.X11-unix:/tmp/.X11-unix' ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest
- Windows (with PowerShell):
docker run --rm -ti --privileged -v "$(Get-Location):/app" -e DISPLAY='host.docker.internal:0' --publish 5000:5000 --publish 9999:9999 ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest
- Linux (Ubuntu):
The application's code will be available from inside the docker container, you can proceed to the following compilation steps to build your app.
You can build the Mintlayer app with the following command executed in the root directory of the app.
cargo ledger build nanoxThis command will build the app for the Nano X, but you can use any supported device (nanox, nanosplus, stax, flex, apex_p).
This Mintlayer app comes with functional tests implemented with Ledger's Ragger test framework.
-
Install the tests requirements
pip install -r tests/requirements.txt
-
Run the functional tests :
pytest tests/ --tb=short -v --device {nanosp | nanox | stax | flex | apex_p}
ℹ️ Speculos uses nanosp for Nano S+ (whereas ledger_app.toml lists it as nanos+).
You can also run the app directly on the Speculos emulator from the Docker container
speculos --apdu-port 9999 --api-port 5000 --display headless --model nanosp target/nanosplus/release/mintlayer-applocalhost:5000.
speculos --apdu-port 9999 --api-port 5000 --model stax target/stax/release/mintlayer-appYou can then send APDU using ledgercomm (pip install ledgercomm):
ledgercomm-send file test.apdu
ℹ️ You can also specify the seed phrase via -s, e.g.: -s "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about".
On Linux, loading the application on a device can be done inside the docker container via:
cargo ledger build nanox --load(the --privileged -v "/dev/bus/usb:/dev/bus/usb" part of the Docker run command line allows this).
It can also be done outside the docker container on all platforms via ledgerblue:
-
Install
ledgerblue:pip install ledgerblue
-
Build the app inside the docker container as usual.
-
Load the app on device, e.g. for Flex:
python -m ledgerblue.runScript --targetId <id> --fileName target/flex/release/mintlayer-app.apdu --apdu --scp
ℹ️ Your device must be connected, unlocked and the screen showing the dashboard (not inside an application).
ledgerblue needs the device's targetId.
If you call ledgerblue manually, note that its --targetId defaults to 0x31100002 (Nano S) — wrong for every other device,
and it is not auto-detected from the connected device.
The cleanest option is to let ledgerblue read the id straight from the ELF with --elfFile, which overrides --targetId:
python -m ledgerblue.runScript --elfFile target/flex/release/mintlayer-app --fileName target/flex/release/mintlayer-app.apdu --apdu --scpIf you instead need the raw target ID value (e.g. for a CI script), the tools/get_target_id.py
helper extracts it from the ledger.target_id ELF section:
python tools/get_target_id.py target/flex/release/mintlayer-app # -> 0x33300004The following workflows are executed in GitHub Actions :
- Ledger guidelines enforcer which verifies that an app is compliant with Ledger guidelines. The successful completion of this reusable workflow is a mandatory step for an app to be available on the Ledger application store. More information on the guidelines can be found in the repository ledger-app-workflow.
- Compilation of the application for all supported devices in the ledger-app-builder docker image.
- End-to-end tests with the Speculos emulator and ragger (see tests/).
- Various lint checks performed by Ledger's reusable workflows:
- Source code lint checks with
cargo fmt. - Python functional test code lint checks with
pylintandmypy.
- Source code lint checks with
- Additional custom checks, run via
run_extra_checks.sh. - Unit tests, run via
run_unit_tests.sh.
For the additional documentation, see the docs folder.
- docs/memory_usage.md - guidelines related to the app's memory usage.
- docs/technical_specification.md - app's technical specification.