OneKey Docs
  • 👋GUIDE
    • Introduction
    • Web App Integration Developer
    • Hardware Integration Developer
    • External Contribution Guide
    • Common Terms
  • 🔮Connect To Software
    • Compatible with Metamask
      • detectEthereumProvider
    • Support Wallet Kit
      • Web3 Onboard
      • Rainbowkit
      • Aptos Wallet Adapter
      • Web3Modal
    • WebApp Connect OneKey
      • ETH
        • Provider API
        • RPC API
        • Accessing Accounts
        • Sending Transactions
        • Signing Data
      • BTC
        • Guide
        • API Reference
          • requestAccounts
          • getAccounts
          • getNetwork
          • switchNetwork
          • getPublicKey
          • getBalance
          • getInscriptions
          • sendBitcoin
          • sendInscription
          • signMessage
          • pushTx
          • signPsbt
          • signPsbts
          • pushPsbt
          • inscribeTransfer (Deprecated)
        • Event
      • Nostr
        • Guide
        • API Reference
          • getPublicKey
          • signEvent
          • signSchnorr
          • getRelays
          • nip04.encrypt
          • nip04.decrypt
        • Event
      • WebLN
        • Guide
        • API Reference
          • enable
          • getInfo
          • makeInvoice
          • sendPayment
          • signMessage
          • verifyMessage
          • lnurl
          • getBalance
        • Event
      • NEAR
        • Introduction
        • Integrating
          • Install the Provider SDK
          • Detecting the Provider
          • Establishing a Connection
          • Accessing Accounts
          • Detecting Provider Network
          • Watch Accounts & Network Status
          • Sending Transactions
            • Create Transaction
            • Sign and Send Transaction
            • Signing Transaction
          • Signing Messages
          • RPC API Calling
          • Debug Logging
          • Migrate from Near Web Wallet
        • Reference
          • API Reference
          • Trouble Shooting
        • Resources
          • Example & Demo
          • FAQ
      • SOLANA
        • Detecting the Provider
        • Establishing a Connection
        • Sending a Transaction
        • Signing a Message
    • Using WalletConnect
      • ETH
      • APTOS
        • Wallet Connect API
  • 📟Connect to Hardware
    • Hardware SDK
      • Started
      • Install SDK
      • Config Event
      • Common Params
      • Path Params
      • Error Code
      • API Reference
        • Basic API
          • Init SDK
          • Search Devices
          • Get Features
          • Get Passphrase State
          • Cancel Request
          • Response UI Event
        • Device API
          • deviceSupportFeatures
          • checkBridgeStatus
          • checkTransportRelease
          • checkFirmwareRelease
          • checkBLEFirmwareRelease
          • deviceChangePin
          • deviceReset
          • deviceSettings
          • deviceUpdateReboot
          • deviceVerify
          • deviceWipe
          • firmwareUpdate
        • Bitcoin & Bitcoin forks
          • btcGetAddress
          • btcGetPublicKey
          • btcSignMessage
          • btcSignTransaction
          • btcVerifyMessage
        • Ethereum & EVM
          • evmGetPublicKey
          • evmGetAddress
          • evmSignTransaction
          • evmSignTypedData
          • evmSignMessage
          • evmVerifyMessage
        • Algorand
          • algoGetAddress
          • algoSignTransaction
        • Aptos
          • aptosGetAddress
          • aptosGetPublicKey
          • aptosSignMessage
          • aptosSignTransaction
        • Alephium
          • alephiumGetAddress
          • alephiumSignMessage
          • alephiumSignTransaction
        • Cardano
          • cardanoGetAddress
          • cardanoGetPublicKey
          • cardanoSignMessage
          • cardanoSignTransaction
        • Conflux
          • confluxGetAddress
          • confluxSignMessage
          • confluxSignMessageCIP23
          • confluxSignTransaction
        • Cosmos
          • cosmosGetAddress
          • cosmosGetPublicKey
          • cosmosSignTransaction
        • Dynex
          • dnxGetAddress
          • dnxSignTransaction
        • FileCoin
          • filecoinGetAddress
          • filecoinSignTransaction
        • Kaspa
          • kaspaGetAddress
          • kaspaSignTransaction
        • Near
          • nearGetAddress
          • nearSignTransaction
        • Nervos
          • nervosGetAddress
          • nervosSignTransaction
        • Nostr
          • nostrGetPublicKey
          • nostrSignEvent
          • nostrSignSchnorr
          • nostrEncryptMessage
          • nostrDecryptMessage
        • NEM
          • nemGetAddress
          • nemSignTransaction
        • Nexa
          • nexaGetAddress
          • nexaSignTransaction
        • Polkadot
          • polkadotGetAddress
          • polkadotSignTransaction
        • Ripple
          • xrpGetAddress
          • xrpSignTransaction
        • Scdo
          • scdoGetAddress
          • scdoSignMessage
          • scdoSignTransaction
        • Solana
          • solGetAddress
          • solSignTransaction
        • Starcoin
          • startcoinGetAddress
          • starcoinGetPublicKey
          • starcoinSignMessage
          • starcoinSignTransaction
          • starcoinVerifyMessage
        • Stellar
          • stellarGetAddress
          • stellarSignTransaction
        • Sui
          • suiGetAddress
          • suiGetPublicKey
          • suiSignMessage
          • suiSignTransaction
        • Tron
          • tronGetAddress
          • tronSignMessage
          • tronSignTransaction
        • Ton
          • tonGetAddress
          • tonSignMessage
          • tonSignProof
      • Advanced
        • Passphrase
        • Common SDK Guide
        • Low-level transport plugin
        • OneKey Message Protocol
      • Tutorial: Get started with OneKey
    • Air Gap SDK
      • Started
      • Tutorial: Wallet Integration
      • API Reference
        • Basic API
          • CryptoHDkey
          • CryptoCoinInfo
          • CryptoKeypath
        • Ethereum & EVM
          • EthSignRequest
          • EthSignature
  • ⛳Best Practice
    • Registering Your Contract's Method Names
    • Registering Tokens with Users
    • Defining Your App's Icon
    • Migration from MetaMask
  • 🎨Logo Assets
  • 🧙Support
  • 🕹️Trouble Shooting
  • ❤️Contribute
Powered by GitBook
On this page
  • Step 0: Try Online debugging tool
  • Step 1: Selector and Initialize the SDK
  • Step 2: Event Configuration
  • Step 3: API Invocation
  • Example: Getting a BTC Address
  • Step 4: How to Start the Business
  • Development SDK

Was this helpful?

Edit on GitHub
  1. Connect to Hardware
  2. Hardware SDK

Started

PreviousHardware SDKNextInstall SDK

Last updated 1 year ago

Was this helpful?

This guide provides clear and concise steps to seamlessly integrate and fully utilize our hardware SDK.

Step 0: Try Online debugging tool

Step 1: Install bridge

The web terminal can communicate with hardware only after a hardware bridge is installed.

Setp 2: Debug

You can use a USB connection to the device for debugging APIs.

Step 1: Selector and Initialize the SDK

  1. Select the appropriate version of the SDK for your platform. .

  2. Download and install the latest version of the SDK for timely technical support.

Step 2: Event Configuration

After the hardware is successfully connected:

  1. Configure the necessary global events (Events).

  2. Handle events, for example:

    • FIRMWARE_EVENT is pushed when there is a firmware update.

    • Entering the hardware unlock PIN code in the software is implemented through the corresponding EVENT.

    • Requests requiring hardware confirmation will also inform the client through EVENT, like opening or closing confirmation windows.

By default, the device's PIN code input is handled by the software. if you need the hardware to handle related EVENTs, additional steps are required.

Step 3: API Invocation

Before using the API, ensure:

Response and Error Handling

  • The response type is Promise.

  • A successful method returns the Success type; a failure returns the Unsuccessful type.

  • Use response.success to determine if the method executed successfully.

Response Data Structure

export interface Unsuccessful {
  success: false;
  payload: { 
    error: string; // Specific error message
    code?: string | number; // Error code
  };
}

export interface Success<T> {
  success: true;
  payload: T;
}

export type Response<T> = Promise<Success<T> | Unsuccessful>;

Example: Getting a BTC Address

HardwareSDK.btcGetAddress('OneKey21042004483', '0B961C0007C7923D5B1D3341', {
  path: 'm/44\'/0\'/0\'/0/0',
  coin: 'btc',
  showOnOneKey: false
}).then(response => {
  if (response.success) {
    console.log(response.payload.address); // Handling success
  } else {
    console.error(response.payload.error); // Handling failure
  }
});

Successful Result

{
  payload: {
    address: "12rZ8ma1fUaXpDw7Nw5adHSvkfKtqKjJ16",
    path: "m/44'/0'/0'/0/0" 
  },
  success: true
}

Error Information

{
  payload: {
    code: -1,
    error: "Not a valid path"
  },
  success: false
}

Step 4: How to Start the Business

Thus, the normal process for adding a new device is:

    1. In the returned results, there will be information such as connectId, deviceType, and name that you need to save. For USB devices, there will also be a DeviceId.

  1. Later, for other business operations, you only need to call the relevant APIs and pass in the ConnectId and DeviceId.

Development SDK

git clone https://github.com/OneKeyHQ/hardware-js-sdk.git
cd hardware-js-sdk
yarn && yarn bootstrap

# build
yarn build

# start hd-web-sdk
cd packages/hd-web-sdk && yarn dev

To ensure that you can fully understand and correctly handle these events, we recommend that you thoroughly refer to our .

You understand the API call instructions and common parameters. See .

Invoke the API, including the common parameters ().

Select the appropriate API based on the hardware firmware version. See .

In case of failure, check the error information in payload and the error code in response.payload.code. For a list of error codes, see .

First, you need to understand and be clear about ConnectId and DeviceId, as almost every method in subsequent business will require them. Therefore, you need to call the method to save the relevant information.

Use to find nearby devices.

If it is a Bluetooth device, you will need to additionally use the to obtain DeviceId relevant information and persistently save it.

📟
Install Hardware Bridge
Online Debugging Tool
See SDK Platform Selection Guide
Event documentation
Common Params
API Documentation
Error Code List
Common Params
getFeatures API
searchDevice
getFeatures
API Call Instructions