Tron application for Ledger devices.
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:
- Install VSCode and add Ledger's extension.
- Open the
app-tronfolder with VSCode. - 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 Speculos with
Run with Speculos. - 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 VSCode will show you what commands the extension runs behind the scene.
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:latestYou can then enter this development environment by executing the following command from the directory of the application git repository:
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:latestsudo docker run --rm -ti --user "$(id -u):$(id -g)" --privileged -v "$(pwd -P):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latestdocker run --rm -ti --privileged -v "$(Get-Location):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latestThe application's code will be available from inside the docker container, you can proceed to the following compilation steps to build your app.
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.
Setup a compilation environment by following the shell with docker approach.
From inside the container, use the following command to build the app:
make COIN=tronYou can choose which device to compile and load for by setting the BOLOS_SDK environment variable to the following values:
BOLOS_SDK=$NANOSP_SDKBOLOS_SDK=$NANOX_SDKBOLOS_SDK=$STAX_SDKBOLOS_SDK=$FLEX_SDK
By default this variable is set to build/load for Nano S+.
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).
First make sure you have the proper udev rules added on your host:
sudo cp .vscode/20-ledger.ledgerblue.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm triggerThen once you have opened a terminal in the app-builder image and built the app for the device you want, run the following command:
make load # load the app on a Nano S+ by defaultSetting the BOLOS_SDK environment variable will allow you to load on whichever supported device you want.
ℹ️ 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 ledgerEnter 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.elfThe Tron app comes with functional tests implemented with Ledger's Ragger test framework.
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 targetBuild 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.
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/requirements.txtThen you can run the functional tests (here for Nano S+ but available for any device once you have built the binaries):
pytest tests/ --tb=short -v --device nanospOr run your app directly with Speculos:
speculos --model nanosp build/nanos2/bin/app.elfTest cases are based on the following seed:
abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about
First private key from this seed is
b5a4cea271ff424d7c31dc12a3e43e401df7a40d7412a15750f3f0b6b5449a28Address:TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdH
The flow processed in GitHub Actions is the following:
- Compilation of the application for all Ledger hardware in ledger-app-builder
- End-to-end tests with Speculos emulator and Ragger (see tests/)