Documentation
8 - Wallet API

8 - Wallet API

  1. Fork github.com/LedgerHQ/wallet-api (opens in a new tab)
  2. Clone the repo

Running the Wallet API project

cd wallet-api
pnpm i
pnpm dev

Adding the crypto in Wallet API

  1. In packages/core/src/families create a folder for your family if it doesn't already exist

  2. In packages/core/src/families/common.ts update the FAMILIES array to add your new coin family name

  3. In packages/core/src/families/{COIN_FAMILY}/validation.ts define and export coin family types related schema using Zod (opens in a new tab). At minimum, a schemaRaw{COIN_FAMILY}Transaction

  4. In packages/core/src/families/{COIN_FAMILY}/types.ts define and export types related to your type. At minimum, a {COIN_FAMILY}Transaction (opens in a new tab) and a Raw{COIN_FAMILY}Transaction (opens in a new tab)

  5. In packages/core/src/families/{COIN_FAMILY}/serializer.ts add the logic to serialize and deserialize a transaction in a raw transaction (type comprised of only json compatible types) to be transferred through JSON-RPC (opens in a new tab)

  6. In packages/core/src/families/index.ts export your new family types

  7. In packages/core/src/families/types.ts update Transaction type to add your new coin related transaction type

  8. In packages/core/src/families/validation.ts update schemaRawTransaction to add your new coin related transaction schema

  9. In packages/core/src/families/serializer.ts add your new coin family transactions serialization and deserialization logics in serializeTransaction and deserializeTransaction

  10. Create a changeset with the command pnpm changelog, you should only need to select @ledgerhq/wallet-api-core then you can select it again for the minor bump as we introduce a new feature and add a summary of the changes (you can edit the file after creation)

  11. Create a PR on the wallet-api (opens in a new tab) repo in order to get a new version to use in LL

Examples:

Updating Ledger Live

  1. Fork github.com/LedgerHQ/ledger-live (opens in a new tab)

  2. Clone the repo

  3. Update the version of @ledgerhq/wallet-api-core, @ledgerhq/wallet-api-server and @ledgerhq/wallet-api-client used in Ledger Live

  4. In LL, you might need to create an adapter for your coin family to transform a WalletAPITransaction (the type of the transaction from the Wallet API point of view) to a Ledger Live Transaction (the type of the transaction from the Ledger Live point of view)

  • libs/ledger-live-common/src/generated/walletApiAdapter.ts import your adapter and add it to the export
ℹ️

The file above is automatically generated at build time by this script (opens in a new tab). It should not be updated manually but you should still check that your adapter is included in this file once added.

The actual adapted file to add is described bellow:

  • libs/ledger-live-common/src/families/{COIN_FAMILY}/walletApiAdapter.ts the actual transaction adapter
    (here is an example adapter for ethereum: libs/ledger-live-common/src/families/ethereum/walletApiAdapter.ts)

Examples:

Ledger
Copyright © Ledger SAS. All rights reserved. Ledger, Ledger Nano S, Ledger Vault, Bolos are registered trademarks of Ledger SAS