APIs
Wallet API
Server
Wallet API Server
React Hook

useWalletAPIServer

source code (opens in a new tab)

For convenience in a react environment, the hook useWalletAPIServer, is available.

It is used to setup a WalletAPIServer

packages/server/src/WalletAPIServer.ts
 
export function useWalletAPIServer({
  transport,
  config,
  logger,
  accounts,
  currencies,
  permission,
  customHandlers,
}){...}
 
Parameter (destructured from single object)required?note
transportsets the transport
configsets the walletContext.config value
logger(optional) sets the logger
accountssets the accounts
currenciessets the currencies
permissionssets the permissions
customHandlers(optional) sets customHandlers

Once instantiated, it

  • Sets custom handlers, in all cases (even if no custom handlers are sent from LLC), it will be called to set the requestHandlers
  • Sets config, permissions, currencies and accounts.

Then, it returns:

return {
  server,
  onMessage,
};

server is our walletAPIServer instance.
onMessage, which will allow APP -> SERVER communication.

ℹ️

Note that WalletAPIServer is instantiated as a ref useRef (opens in a new tab) we actually return server: server.current

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