### Complete Device Discovery and Connection Example Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/beginner/discover_and_connect.mdx This comprehensive example demonstrates how to start discovering devices, connect to the first one found, retrieve its information, and begin monitoring its state. It also includes essential cleanup logic for unsubscribing from observables and disconnecting from the device. ```typescript import { DeviceStatus } from "@ledgerhq/device-management-kit"; // Global variables to store subscriptions and session info let discoverySubscription; let stateSubscription; let currentSessionId; function startDiscoveryAndConnect() { // Clear any previous discovery if (discoverySubscription) { discoverySubscription.unsubscribe(); } console.log("Starting device discovery..."); // Start discovering - this will scan for any connected devices discoverySubscription = dmk.startDiscovering({}).subscribe({ next: async (device) => { console.log( `Found device: ${device.id}, model: ${device.deviceModel.model}`, ); // Connect to the first device we find try { // Pass the full device object, not just the ID currentSessionId = await dmk.connect({ device }); console.log(`Connected! Session ID: ${currentSessionId}`); // Stop discovering once we connect discoverySubscription.unsubscribe(); // Get device information const connectedDevice = dmk.getConnectedDevice({ sessionId: currentSessionId, }); console.log(`Device name: ${connectedDevice.name}`); console.log(`Device model: ${connectedDevice.modelId}`); // Start monitoring device state stateSubscription = monitorDeviceState(currentSessionId); } catch (error) { console.error("Connection failed:", error); } }, error: (error) => { console.error("Discovery error:", error); }, }); } function monitorDeviceState(sessionId) { return dmk.getDeviceSessionState({ sessionId }).subscribe({ next: (state) => { console.log(`Device status: ${state.deviceStatus}`); // Check for specific status conditions if (state.deviceStatus === DeviceStatus.LOCKED) { console.log("Device is locked - please enter your PIN"); } // Show battery level if available if (state.batteryStatus) { console.log(`Battery level: ${state.batteryStatus.level}%`); } // Show app information if available if (state.currentApp) { console.log(`Current app: ${state.currentApp.name}`); console.log(`App version: ${state.currentApp.version}`); } // Basic device model info console.log(`Device model: ${state.deviceModelId}`); }, error: (error) => { console.error("State monitoring error:", error); }, }); } // Always clean up resources when done async function cleanup() { // Unsubscribe from all observables if (discoverySubscription) { discoverySubscription.unsubscribe(); } if (stateSubscription) { stateSubscription.unsubscribe(); } // Disconnect from device if connected if (currentSessionId) { try { await dmk.disconnect({ sessionId: currentSessionId }); console.log("Device disconnected successfully"); currentSessionId = null; } catch (error) { console.error("Disconnection error:", error); } } } // Example usage: // startDiscoveryAndConnect(); // ...later when done... // cleanup(); ``` -------------------------------- ### Example package.json for Bluetooth Integration Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/mobile-application/react-native-bluetooth-ios.mdx This is an example of how your 'package.json' file should be configured after installing the necessary dependencies for Bluetooth communication. ```javascript { "name": "myiOSBTApp", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@ledgerhq/hw-app-eth": "^6.16.2", "@ledgerhq/react-native-hw-transport-ble": "^6.15.0", "buffer": "^6.0.3", "react": "17.0.2", "react-native": "0.66.3", "react-native-ble-plx": "^2.0.3", "react-native-qrcode-svg": "^6.1.1", "react-native-svg": "^12.1.1", "rxjs": "^7.4.0" }, "devDependencies": { "@babel/core": "^7.16.0", "@babel/runtime": "^7.16.3", "@react-native-community/eslint-config": "^3.0.1", "babel-jest": "^27.3.1", "eslint": "^8.3.0", "jest": "^27.3.1", "metro-react-native-babel-preset": "^0.66.2", "react-test-renderer": "17.0.2" }, "jest": { "preset": "react-native" } } ``` -------------------------------- ### Install and Run Android App Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/mobile-application/react-native-android-hid.mdx Install the application on your connected Android device and launch it. Follow the on-screen prompts on your device to confirm the installation. ```bash npm run android ``` -------------------------------- ### Start Development Server Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/devtools/README.md Starts the development server for the DevTools application. ```bash pnpm dev ``` -------------------------------- ### Install Device Management Kit Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/device-management-kit/README.md Install the core package using npm. ```sh npm install @ledgerhq/device-management-kit ``` -------------------------------- ### Install Bitcoin Signer Kit Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/references/signers/btc.mdx Installs the `device-signer-kit-bitcoin` package. Ensure `@ledgerhq/device-management-kit` is installed first. ```sh npm install @ledgerhq/device-signer-kit-bitcoin ``` -------------------------------- ### Start Sample App Development Server Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/README.md Builds required dependencies and starts a development server for the sample application. Execute this command at the root of the repository. ```bash pnpm dev ``` -------------------------------- ### Start Development Server Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/beginner/personal-message.mdx Use this command to start the development server for your application. This command is defined in the package.json scripts. ```bash npm run start ``` -------------------------------- ### Complete package.json Example Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/web-application/web-hid-usb.mdx An example of a complete package.json file including dependencies, scripts, and aliases for a Web HID/USB application. ```json { "name": "update-doc-web-hid-usb", "version": "1.0.0", "description": "", "source": "src/index.html", "dependencies": { "@ledgerhq/hw-app-btc": "^10.1.0", "@ledgerhq/hw-transport-webhid": "^6.28.0", "@ledgerhq/hw-transport-webusb": "^6.28.4", "@ledgerhq/logs": "^6.12.0", "core-js": "^3.33.3" }, "scripts": { "build": "parcel build", "start": "parcel" }, "devDependencies": { "buffer": "^6.0.3", "parcel": "^2.10.3", "process": "^0.11.10", "stream-browserify": "^3.0.0" }, "alias": { "@ledgerhq/devices": "@ledgerhq/devices/lib-es" } } ``` -------------------------------- ### Complete package.json Example Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/beginner/personal-message.mdx A complete example of a package.json file for a personal message signing application. Ensure all dependencies and configurations are correctly set. ```json { "name": "example-sign-personal-message", "version": "1.0.0", "description": "", "source": "src/index.html", "scripts": { "build": "parcel build", "start": "parcel" }, "author": "", "license": "ISC", "dependencies": { "@ledgerhq/hw-app-eth": "^6.35.6", "@ledgerhq/hw-transport-webhid": "^6.28.4", "@ledgerhq/logs": "^6.12.0", "core-js": "^3.36.0", "eth-crypto": "^2.6.0" }, "devDependencies": { "buffer": "^6.0.3", "parcel": "^2.12.0", "process": "^0.11.10", "stream-browserify": "^3.0.0" }, "alias": { "@ledgerhq/devices": "@ledgerhq/devices/lib-es", "@ledgerhq/domain-service": "@ledgerhq/domain-service/lib-es", "@ledgerhq/evm-tools": "@ledgerhq/evm-tools/lib-es", "@ledgerhq/cryptoassets": "@ledgerhq/cryptoassets/lib-es", "@ledgerhq/live-network": "@ledgerhq/live-network/lib-es" } } ``` -------------------------------- ### Install Cosmos Signer Kit Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/references/signers/cosmos.mdx Install the device-signer-kit-cosmos package using npm. Ensure the Device Management Kit is installed first. ```sh npm install @ledgerhq/device-signer-kit-cosmos ``` -------------------------------- ### Complete package.json Example Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/web-application/web-bluetooth.mdx A complete example of a package.json file including dependencies for a web application interacting with Ledger devices via Web Bluetooth. ```json { "name": "test-bluetooth", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint" }, "dependencies": { "@ledgerhq/hw-app-eth": "^6.35.1", "@ledgerhq/hw-transport-web-ble": "^6.28.1", "eip55": "^2.1.1", "next": "14.0.4", "react": "^18", "react-dom": "^18" } } ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/README.md Install all project dependencies using pnpm. This command should be run after configuring the project with Proto. ```bash pnpm i ``` -------------------------------- ### Install DMK Packages Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/beginner/init_dmk.mdx Install the Device Management Kit and the WebHID transport package using npm. ```bash npm install @ledgerhq/device-management-kit @ledgerhq/device-transport-kit-web-hid ``` -------------------------------- ### Install Dependencies and Build Libraries Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/clear-signing-tester/README.md Installs project dependencies and builds necessary libraries using pnpm. ```bash pnpm install pnpm build:libs ``` -------------------------------- ### Start Development Server Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/web-application/web-bluetooth.mdx Command to start the development server for your Next.js application. Ensure your Ledger device is connected and the Ethereum app is running. ```bash npm run dev ``` -------------------------------- ### Install @ledgerhq/dmk-ledger-wallet Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/ledger-wallet/README.md Install the package using npm. ```sh npm install @ledgerhq/dmk-ledger-wallet ``` -------------------------------- ### Execute Install App Device Action Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/references/device-management-kit/secure-channel.mdx This snippet shows how to install an application on the device using InstallAppDeviceAction. It handles pending states, including user interaction requirements and installation progress, as well as completion and error states. ```typescript import { DeviceActionStatus, UserInteractionRequired, InstallAppDAState, InstallAppDeviceAction, } from "@ledgerhq/device-management-kit"; const deviceAction = new InstallAppDeviceAction({ input: { unlockTimeout: 60000, appName: "Solana" }, }); const { observable, cancel } = await dmk.executeDeviceAction({ deviceAction, }); observable.subscribe({ next: (state: InstallAppDAState) => { switch (state.status) { case DeviceActionStatus.Pending: const { intermediateValue: { requiredUserInteraction, progress }, } = state; switch (requiredUserInteraction) { case UserInteractionRequired.None: console.log( `Installing app progress ${progress}, no user action required`, ); break; case UserInteractionRequired.AllowSecureConnection: console.log( "User should allow the secure connection on the device", ); break; case UserInteractionRequired.UnlockDevice: console.log("User should unlock the device"); break; default: throw new Error("Unknown user interaction required"); } break; case DeviceActionStatus.Completed: const { output } = state; console.log("Device action completed", output); break; case DeviceActionStatus.Error: const { error } = state; console.log("Error occurred during the execution", error); break; } }, }); ``` -------------------------------- ### Install Dependencies Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/devtools/README.md Installs project dependencies using pnpm. ```bash pnpm install ``` -------------------------------- ### Install Zcash Signer Kit Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/signer/signer-zcash/README.md Install the Zcash Signer Kit package using pnpm. ```bash pnpm add @ledgerhq/device-signer-kit-zcash ``` -------------------------------- ### Install Context Module Package Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/signer/context-module/README.md Install the context-module package using npm. ```sh npm install @ledgerhq/context-module ``` -------------------------------- ### Install Aleo Signer Kit Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/signer/signer-aleo/README.md Install the Aleo signer kit package using pnpm. ```bash pnpm add @ledgerhq/device-signer-kit-aleo ``` -------------------------------- ### Install WebUSB Transport Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/web-application/web-hid-usb.mdx Install the package for interacting with Ledger Nano devices using the Web USB API. ```bash npm install --save @ledgerhq/hw-transport-webusb ``` -------------------------------- ### Install Solana and WebUSB Packages Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/beginner/transfer-sol.mdx Install the required npm packages for Solana application development with Ledger devices using WebUSB. ```bash npm install --save-dev parcel npm install --save @ledgerhq/hw-app-solana npm install --save @ledgerhq/hw-transport-webusb npm install --save @ledgerhq/logs npm install --save @solana/web3.js npm install --save bs58 ``` -------------------------------- ### Install Core Dependencies Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/web-application/web-hid-usb.mdx Install essential packages for Ledger device interaction and logging, along with Parcel for building the application. ```bash npm install --save core-js npm install --save @ledgerhq/logs npm install --save-dev parcel npm install --save @ledgerhq/hw-app-btc ``` -------------------------------- ### Install WebHID Transport Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/web-application/web-hid-usb.mdx Install the package for interacting with Ledger Nano devices using the Web HID API. ```bash npm install --save @ledgerhq/hw-transport-webhid ``` -------------------------------- ### Install Dependencies with Post-Install Scripts Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/agent-files/skills/release/SKILL.md Install project dependencies, ensuring that post-install scripts and native dependencies are correctly processed. This command bypasses lockfile verification. ```bash pnpm install --no-frozen-lockfile ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/beginner/personal-message.mdx Installs the necessary npm packages for the project, including core-js, Ledger logs, Parcel, the Ethereum app, eth-crypto, and buffer/process/stream polyfills. ```bash npm install --save core-js npm install --save @ledgerhq/logs npm install --save-dev parcel npm install --save @ledgerhq/hw-app-eth npm install --save eth-crypto npm install --save-dev buffer npm install --save-dev process npm install --save-dev stream-browserify ``` -------------------------------- ### Get Solana Context Before v2.0.0 Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/integration/migrations/signers/context-module/1_17_1_to_2_0_0.mdx Example of retrieving Solana-specific context using the `getSolanaContext()` method, which was removed in v2.0.0. ```typescript const solanaContext = await contextModule.getSolanaContext(transaction); ``` -------------------------------- ### Build Sample Application Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/README.md Build the sample application module. This command is run from the monorepo root. ```bash pnpm sample build ``` -------------------------------- ### Get Contexts After v2.0.0 Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/integration/migrations/signers/context-module/1_17_1_to_2_0_0.mdx Example of retrieving contexts using the standard `getContexts()` method, which now handles Solana context after the removal of `getSolanaContext()`. ```typescript const contexts = await contextModule.getContexts(transaction); ``` -------------------------------- ### DMK v0.5: Built-in Transports Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/integration/migrations/dmk/05_to_06.mdx In version 0.5.0, transports were integrated directly within the DeviceManagementKit. This example shows the basic builder setup. ```typescript import { DeviceManagementKitBuilder, ConsoleLogger, } from "@ledgerhq/device-management-kit"; const dmk = new DeviceManagementKitBuilder() .addLogger(new ConsoleLogger()) .build(); ``` -------------------------------- ### Create Project Directory and Files Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/beginner/transfer-sol.mdx Initializes the project by creating a new directory and essential files for the web application. Ensure you have Node.js installed. ```bash mkdir e2e-sol-tutorial cd e2e-sol-tutorial ``` ```bash npm init ``` ```bash touch index.html touch index.js touch style.css mkdir assets ``` -------------------------------- ### Set up Rozenite DevTools for React Native Apps Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/device-management-kit/README.md Integrates DMK developer tools directly into React Native DevTools using Rozenite. This setup is recommended if Rozenite is already configured in your app for a more integrated experience. Ensure the required packages are installed. ```typescript import { DevToolsLogger, DevToolsDmkInspector, } from "@ledgerhq/device-management-kit-devtools-core"; import { RozeniteConnector, useRozeniteConnector, } from "@ledgerhq/device-management-kit-devtools-rozenite"; // Create the connector (shared between logger and inspector) const connector = RozeniteConnector.getInstance(); // Create the logger (before DMK is built) const devToolsLogger = new DevToolsLogger(connector); // Build the DMK with the logger const dmk = new DeviceManagementKitBuilder() //... .addLogger(devToolsLogger) .build(); // Optional: Enable inspector for device sessions and DMK interaction // This must be done AFTER the DMK is built const inspector = new DevToolsDmkInspector(connector, dmk); // Clean up when done (e.g., on app unmount) // inspector.destroy(); // At the root of your React app, call this hook to initialise the connection useRozeniteConnector(); ``` -------------------------------- ### Install Pods for iOS Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/mobile-application/react-native-bluetooth-ios.mdx After installing npm packages, navigate to the 'ios' directory and run 'pod install' and 'pod update' to install the native dependencies. ```bash cd ios/ pod install pod update ``` -------------------------------- ### Create Project Directory Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/beginner/personal-message.mdx Sets up the necessary directory structure for the project. ```bash mkdir example-sign-personal-message cd example-sign-personal-message ``` -------------------------------- ### Install Homebrew Package Manager Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/mobile-application/environment-setup.mdx Install Homebrew, a package manager for macOS, to easily install other command-line tools and software. This command downloads and runs the official installation script. ```bash ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" ``` -------------------------------- ### Install Concordium Signer Kit Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/references/signers/concordium.mdx Install the device-signer-kit-concordium package using npm. Ensure the device-management-kit is installed first as a prerequisite. ```sh npm install @ledgerhq/device-signer-kit-concordium ``` -------------------------------- ### Create and Navigate to Project Directory Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/beginner/cosmos-app.mdx Use these bash commands to create a new project folder and navigate into it. ```bash mkdir use-cosmos-webapp cd use-cosmos-webapp ``` -------------------------------- ### Install Polkadot Signer Kit Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/references/signers/polkadot.mdx Install the Polkadot Signer Kit package. Ensure the Device Management Kit is installed first as a dependency. ```sh npm install @ledgerhq/device-signer-kit-polkadot ``` -------------------------------- ### Example Signer Generation Session Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/how-to-create-signer.md This example demonstrates an interactive session with the signer generator, including user inputs for cryptocurrency name and context module dependency, and the output confirming successful package generation. ```bash $ pnpm ldmk-tool generate-signer 🚀 Generating new signer package 🚀 Welcome to the Ledger Device SDK Signer Generator This will create a new signer package skeleton for your cryptocurrency. ✔ What is the name of your cryptocurrency? XXX ? Do you want to include the context-module dependency? (y/N) n ✅ Generating signer package for XXX Context module: No 📦 Creating directory structure... 📦 Copying and adapting files... ✅ Created packages/signer/signer-xxx/package.json ✅ Created packages/signer/signer-xxx/tsconfig.json ✅ Created packages/signer/signer-xxx/src/index.ts ✅ Created packages/signer/signer-xxx/src/api/SignerXXX.ts ✅ Created packages/signer/signer-xxx/src/api/SignerXXXBuilder.ts ... (more files) 🎉 Signer package generated successfully! Next steps: 1. Navigate to the generated package: cd packages/signer/signer-xxx 2. Install dependencies: pnpm install 3. Build the package: pnpm build 4. Start developing your XXX signer implementation! ``` -------------------------------- ### Build Documentation Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/README.md Build the project's documentation. This command is run from the monorepo root. ```bash pnpm doc build ``` -------------------------------- ### Install Xcode Command Line Tools Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/mobile/android/fastlane/README.md Ensure you have the latest version of the Xcode command line tools installed before proceeding with Fastlane installation. ```sh xcode-select --install ``` -------------------------------- ### Install Node HID Transport Package Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/transport/node-hid/README.md Install the core package using npm. Ensure the Device Management Kit is also installed in your project. ```sh npm install @ledgerhq/device-transport-kit-node-hid ``` -------------------------------- ### Run Development Server Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/sample/README.md Use these commands to start the Next.js development server. Open http://localhost:3000 in your browser to view the application. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Create Project Directory and Files Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/beginner/transfer-eth.mdx Initializes the project structure by creating a directory and essential files for the web application. This includes the main HTML, JavaScript, and CSS files, as well as an assets folder. ```bash mkdir e2e-eth-tutorial cd e2e-eth-tutorial ``` ```bash touch index.html touch index.js touch style.css mkdir assets ``` -------------------------------- ### Install Java JRE and JDK Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/mobile-application/environment-setup.mdx Install Java JRE and JDK 8 using Homebrew. A complete Java installation is necessary to avoid potential build failures in React Native projects. ```bash brew install --cask adoptopenjdk/openjdk/adoptopenjdk8 ``` -------------------------------- ### Run the CLI Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/ldmk-cli/README.md Execute the Ledger Device Management Kit CLI from the repository root using pnpm. ```bash pnpm cli dev ``` -------------------------------- ### Initialize npm Project Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/beginner/personal-message.mdx Initializes a new npm project, creating a package.json file. ```bash npm init ``` -------------------------------- ### Install Signer Polkadot Package Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/signer/signer-polkadot/README.md Install the Signer Polkadot package using pnpm. ```bash pnpm add @ledgerhq/device-signer-kit-polkadot ``` -------------------------------- ### Install React Native BLE Transport Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/transport/rn-ble/README.md Install the core package using npm. ```sh npm install @ledgerhq/device-transport-kit-react-native-ble ``` -------------------------------- ### Initialize and Use Device Controller Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/speculos-device-controller/README.md Instantiate the client with a base URL and then create factories for button and tap interactions. Use default screen sizes like 'flex'. ```typescript import { deviceControllerClientFactory } from "speculos-device-controller"; const deviceClient = deviceControllerClientFactory("http://localhost:4000"); // Buttons const deviceButtons = deviceClient.buttonFactory(); await deviceButtons.press("both"); await deviceButtons.left(); await deviceButtons.right(); await deviceButtons.both(); await deviceButtons.pressSequence(["left", "right", "both"], 150); // Tap: percentages (0..100) await deviceClient.tapFactory("flex").tapQuick({ x: 20, y: 45 }); // 20% / 45% of the "flex" screen // You can easily instantiate tap devices dynamically const currentDeviceTap = deviceClient.tapFactory(currentDevice); await currentDeviceTap.tapLong({ x: 20, y: 45 }); ``` -------------------------------- ### Install Aleo Signer Kit Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/references/signers/aleo.mdx Install the device-signer-kit-aleo package. This module depends on @ledgerhq/device-management-kit. ```sh npm install @ledgerhq/device-signer-kit-aleo ``` -------------------------------- ### Building the Package Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/how-to-create-signer.md Build the package for production or development. Use 'dev' for watch mode during development. ```bash pnpm build ``` ```bash pnpm dev ``` -------------------------------- ### Navigate to App Directory Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/web-application/web-bluetooth.mdx Change into the newly created project directory to begin modifying the application files. ```bash cd examples-web-bluetooth ``` -------------------------------- ### Initialize React Native Project Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/mobile-application/react-native-bluetooth-android.mdx Create a new React Native project and navigate into its directory. This sets up the basic structure for your mobile application. ```bash react-native init myAndroidBTApp cd myAndroidBTApp ``` -------------------------------- ### Install Speculos Transport Package Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/transport/speculos/README.md Install the core package for the Speculos transport using npm. ```sh npm install @ledgerhq/device-transport-kit-speculos ``` -------------------------------- ### Install Solana Signer Package Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/signer/signer-solana/README.md Install the device-signer-kit-solana package. This module depends on the @ledgerhq/device-management-kit package. ```sh npm install @ledgerhq/device-signer-kit-solana ``` -------------------------------- ### Build and Run Compiled Server Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/device-mock-server/README.md Build the server and then run the compiled JavaScript output. ```bash pnpm build pnpm start # node lib/cjs/main.js ``` -------------------------------- ### Get Wallet Address Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/references/signers/btc.mdx Allows users to get the wallet address linked to a Ledger device. ```APIDOC ## getWalletAddress ### Description Allows users to get the wallet address linked to a Ledger device. ### Method `signerBitcoin.getWalletAddress` ### Parameters #### Path Parameters - **derivationPath** (string) - Required - The derivation path for the wallet address. - **addressIndex** (number) - Required - The index of the address to retrieve. - **options** (object) - Optional - Additional options for retrieving the wallet address. ``` -------------------------------- ### React Native Project Initialization Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/integration/mobile-application/react-native-android-hid.mdx Create a new React Native project and navigate into its directory. This sets up the basic structure for your application. ```bash react-native init myAndroidHidApp cd myAndroidHidApp ``` -------------------------------- ### Install Signer Hyperliquid Package Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/signer/signer-hyperliquid/README.md Install the necessary package for Hyperliquid signer functionality using pnpm. ```bash pnpm add @ledgerhq/device-signer-kit-hyperliquid ``` -------------------------------- ### Main Entry Point Index File Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/how-to-create-signer.md Sets up the main entry point for the package, including inversify requirements and exporting from the API. ```typescript // inversify requirement import "reflect-metadata"; export * from "@api/index"; ``` -------------------------------- ### Initialize Device Management Kit with Console Logger and WebHID Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/packages/device-management-kit/README.md Initialize the Device Management Kit with a console logger and WebHID transport. The returned object is the main entry point for SDK interactions. This setup should be done once per application runtime. ```ts import { ConsoleLogger, DeviceManagementKitBuilder, } from "@ledgerhq/device-management-kit"; import { webHidTransportFactory } from "@ledgerhq/device-transport-kit-web-hid"; export const sdk = new DeviceManagementKitBuilder() .addLogger(new ConsoleLogger()) .addTransport(webHidTransportFactory) .build(); ``` -------------------------------- ### Create Source Files Source: https://github.com/ledgerhq/device-sdk-ts/blob/develop/apps/docs/pages/docs/ledgerjs/beginner/personal-message.mdx Creates the source directory and essential HTML and JavaScript files. ```bash mkdir src touch src/index.html touch src/main.js ```