- Rust 82%
- Nix 18%
Vanadium application for Atproto #
cargo install --git https://github.com/LedgerHQ/vanadium cargo-vnd
Simulator #
nix develop provides vanadium-simulator, which runs the Vanadium VM on the
Speculos emulator. Speculos itself runs from the ledger-app-dev-tools:latest
container image, so docker or podman must be available on the host.
That image tracks the tag instead of a digest because Speculos has to know the
SDK API level the VM binaries were built against; an older Speculos refuses them
with launcher: invalid SDK api_level. If that shows up after a VM bump, pull
the image again. SPECULOS_CONTAINER_IMAGE overrides it, with a digest for
instance.
vanadium-simulator # nanosplus, the default device
vanadium-simulator flex # or nanox, stax, apex_p
There is no window: the emulator runs headless and serves the device screen at
http://127.0.0.1:5000, which is also where the buttons are. The APDU port the
CLI connects to is 9999. Both can be moved with LEDGER_API_PORT and
LEDGER_APDU_PORT.
The default device is a button one because the web interface only offers the left, right and both buttons. It has no touch support, so on flex, stax and apex_p the screen is visible but cannot be tapped; those need the REST API:
curl -X POST http://127.0.0.1:5000/finger \
-d '{"action": "press-and-release", "x": 200, "y": 300}'
--display qt is not an option here: the ledger-app-dev-tools image ships
PyQt6 but not libxcb-cursor0, which Qt needs to load its xcb platform plugin,
so the Qt window cannot start whatever the host does with DISPLAY.
The device is optional, and every other argument is passed to Speculos, --seed
for instance, which takes a BIP39 mnemonic or a hex seed prefixed with hex::
vanadium-simulator --seed "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art"
vanadium-simulator nanosplus --seed "hex:000102030405060708090a0b0c0d0e0f"
Without --seed, Speculos uses its own default mnemonic, which starts with
glory promote mansion idle axis finger.
Running the app #
Build the V-App for the Risc-V target. The SDK's target_native feature pulls
in rand, which has no getrandom backend there, so the on-device build needs
the other one:
cargo build --release --target riscv32imc-unknown-none-elf \
--no-default-features --features target_vanadium_ledger
With the simulator running, the CLI loads that ELF onto it and opens a prompt:
cd cli
cargo run
Commands take their arguments as name=value, without dashes:
> get_did_key
did:key:zQ3sh...
> get_did_key key_index=1
> get_did_key display=true
> sign_plc_operation operation=operation.json
> exit
display=true asks for a confirmation on the device, so it waits until the
buttons are pressed in the web interface.
The app also runs natively, without the simulator at all, which is the quickest
way to exercise a command. Build it for the host, run it in one terminal, then
point the CLI at it with --native in another:
cargo build --release # terminal 1
./target/x86_64-unknown-linux-gnu/release/vnd-atproto
cd cli && cargo run -- --native # terminal 2
In that mode the device prompts are answered in the app's own terminal rather than in a browser.
The VM binaries come from vanadium's rolling latest release, pinned by hash in
flake.nix. When Ledger rebuilds them the hash goes stale; the build then
reports the new one, to be pasted over the vanadium-vm hash:
nix build .#vanadium-vm