Js-wallet-sdk is a wallet solution based on TypeScript/JavaScript language that includes various public chains' different cryptographic algorithms and common functionalities. You can use it for creating private keys, addresses, assembling transactions, and performing signatures, among other things. This document will provide a detailed guide on how to use this SDK. Currently, it supports various mainstream blockchains, with each token format having its own independent module implementation. We will continue to add support for more blockchains in the future.
As a Javascript SDK, it supports various browsers and JavaScript environments, and can be easily integrated into Web applications, mobile applications, or desktop applications.
To use the Signing SDK, you first need to install it. You can use npm install to get the latest version.
Our Signing SDK supports two types of packages: public packages and single coin modules.
Public packages are for all currencies:
npm install @okxweb3/crypto-lib
npm install @okxweb3/coin-base
Integration of individual currencies, taking ETH and BTC as examples:
Integration of ETH:
npm install @okxweb3/coin-ethereum
Integration of BTC:
npm install @okxweb3/coin-bitcoin
To build the SDK locally:
git clone https://github.com/okx/js-wallet-sdk.git
sh build.sh
Here is a specific introduction to the functions of each module in the Signing SDK.
Package name | Module | Description |
---|---|---|
@okxweb3/coin-base | coin-base | We provide common functions for these chains or currencies, making access to these chains very simple. |
@okxweb3/crypto-lib | crypto-lib | We provide common functions about bip32, bip39, ecdsa, ed25519, etc. |
@okxweb3/coin-aptos | coin-aptos | Aptos SDK is used to interact with the Aptos blockchain, containing various functions that can be used for web3 wallets. |
@okxweb3/coin-bitcoin | coin-bitcoin | Bitcoin SDK is used to interact with the Bitcoin mainnet or testnet, containing various functions that can be used for web3 wallets. The SDK not only supports Bitcoin, but also supports the following chains: BTC, BSV, DOGE, LTC, TBTC. |
@okxweb3/coin-cosmos | coin-cosmos | Cosmos SDK is used to interact with the Cosmos blockchain, containing various functions that can be used for web3 wallets. |
@okxweb3/coin-eos | coin-eos | EOS SDK is used to interact with the EOS blockchain, containing various functions that can be used for web3 wallets. The SDK not only supports EOS, but also supports WAX. |
@okxweb3/coin-ethereum | coin-ethereum | Ethereum SDK is used to interact with the Ethereum blockchain or Evm blockchain, containing various functions that can be used for web3 wallets. |
@okxweb3/coin-flow | coin-flow | Flow SDK is used to interact with the Flow blockchain, containing various functions that can be used for web3 wallets. |
@okxweb3/coin-near | coin-near | Near SDK is used to interact with the Near Protocol, containing the main functions needed when interacting with the Near ecosystem. |
@okxweb3/coin-polkadot | coin-polkadot | Polkadot SDK is used to interact with the Polkadot blockchain, containing the main functions needed when interacting with the Polkadot ecosystem. |
@okxweb3/coin-solana | coin-solana | Solana SDK is used to interact with the Solana chain, containing the main functions needed when interacting with the Solana ecosystem. |
@okxweb3/coin-stacks | coin-stacks | Stacks SDK is used to interact with the Stacks blockchain, containing various functions that can be used for web3 wallets. |
@okxweb3/coin-starknet | coin-starknet | Starknet SDK is used to interact with the Starknet blockchain, containing various functions that can be used for web3 wallets. |
@okxweb3/coin-sui | coin-sui | SUI SDK is used to interact with the SUI blockchain, containing various functions that can be used for web3 wallets. |
@okxweb3/coin-tron | coin-tron | TRX SDK is used to interact with the TRON blockchain, containing various functions that can be used for web3 wallets. |
@okxweb3/coin-zkspace | coin-zkspace | ZKSpace SDK is used to interact with ZK contracts, containing various functions that can be used for web3 wallets. The SDK not only supports ZKSpace, but also supports zkSync. |
The base package is the common basic module for all currencies, providing common interface method definitions, such as: random private key generation, private key derivation, obtaining derivation paths, etc. At present, the implementation packages of individual currencies have basically implemented common interface methods, but the functions supported by different currencies may vary slightly. For more details, you can refer to the function descriptions of each coin implementation package.
To get the latest version of the package via npm:
npm install @okxweb3/coin-base
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getRandomPrivateKey | Generate a random private key | |
getDerivedPrivateKey | Generate a private key from DerivePriKeyParams | |
getNewAddress | Get a new address through a private key | |
validAddress | Validate an address | |
signTransaction | Sign a transaction | |
getDerivedPath | Get a bip44 path | |
validPrivateKey | Validate a private key | |
signMessage | Sign a message | |
verifyMessage | Verify a signed message | |
ecRecover | Recover a signature to a public key | |
getAddressByPublicKey | Get an address through a public key | |
getHardWareRawTransaction | Get the raw transaction of the hardware | |
getHardWareSignedTransaction | Get the signed transaction of the hardware | |
getHardWareMessageHash | Get the message hash of the hardware | |
calcTxHash | Get a transaction hash through a raw transaction | |
getRawTransaction | Generate raw transaction data | |
validSignedTransaction | Check a signed transaction | |
estimateFee | Estimate gas fees |
For more detailed information about the functions supported by the coin-base package and use cases, you can view the github document for more detailed content: coin-base function functions.
This is a library that includes implementations of commonly used security encryption and signature algorithms such as bip32, bip39, ecdsa, ed25519, etc. For example:
To get the latest version of the package via npm:
npm install @okxweb3/crypto-lib
For more detailed information about the functions supported by the crypto-lib package and use cases, you can view the github document for more detailed content: crypto-lib function functions.
Aptos SDK is mainly used to integrate Aptos blockchain, containing functions such as private key generation, private key derivation, address generation, and transaction transfer.
To get the latest version of the package via npm:
npm install @okxweb3/coin-aptos
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getRandomPrivateKey | Generate a random private key | |
getDerivedPrivateKey | Generate a private key from DerivePriKeyParams | |
getNewAddress | Get a new address through a private key | |
validAddress | Validate an address | |
signTransaction | Sign a transaction | |
getDerivedPath | Get a bip44 path | |
signMessage | Sign a message | |
verifyMessage | Verify a signed message | |
calcTxHash | Get a transaction hash through a raw transaction | |
validSignedTransaction | Check a signed transaction |
Aptos transaction support types are:
"transfer", "tokenTransfer", "tokenMint", "tokenBurn", "tokenRegister", "dapp", "simulate", "offerNft", "claimNft", "offerNft_simulate", "claimNft_simulate"
For more detailed information about the functions supported by the coin-aptos package and use cases, you can view the github document for more detailed content: coin-aptos function functions.
coin-bitcoin is an SDK for integrating Bitcoin blockchain. It supports both the Bitcoin mainnet and testnet, and provides a series of functional methods, making it easier for developers to interact with the Bitcoin blockchain. In addition to BTC, it also supports other cryptocurrencies such as BSV, DOGE, LTC, and TBTC.
To get the latest version of the package via npm:
npm install @okxweb3/coin-bitcoin
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getRandomPrivateKey | Generate a random private key | |
getDerivedPrivateKey | Generate a private key from DerivePriKeyParams | |
getNewAddress | Get a new address through a private key | |
validAddress | Validate an address | |
signTransaction | Sign a transaction | |
getDerivedPath | Get a bip44 path | |
signMessage | Sign a message | |
verifyMessage | Verify a signed message | |
calcTxHash | Get a transaction hash through a raw transaction | |
validSignedTransaction | Check a signed transaction | |
getAddressByPublicKey | Get an address through a public key |
For more detailed information about the functions supported by the coin-bitcoin package and use cases, you can view the github document for more detailed content: coin-bitcoin function functions.
Cosmos SDK is a toolkit for integrating with the Cosmos blockchain, providing a series of functional methods, including generating private keys, deriving private keys, generating addresses, and transferring transactions. It supports currencies including:
To get the latest version of the package via npm:
npm install @okxweb3/coin-cosmos
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getRandomPrivateKey | Generate a random private key | |
getDerivedPrivateKey | Generate a private key from DerivePriKeyParams | |
getNewAddress | Get a new address through a private key | |
validAddress | Validate an address | |
signTransaction | Sign a transaction | |
getDerivedPath | Get a bip44 path | |
signMessage | Sign a message | |
verifyMessage | Verify a signed message | |
calcTxHash | Get a transaction hash through a raw transaction | |
validSignedTransaction | Check a signed transaction | |
getAddressByPublicKey | Get an address through a public key |
For more detailed information about the functions supported by the coin-cosmos package and use cases, you can view the github document for more detailed content: coin-cosmos function functions.
EOS SDK is a toolkit for integrating with the EOS blockchain. It provides a series of functional methods, including generating private keys, deriving private keys, generating addresses, and transaction serialization. In addition to EOS, it also supports the Wax coin.
These functional methods make it easier for developers to interact with the EOS blockchain, including creating and managing wallets, sending and receiving transactions, and querying blockchain information.
To get the latest version of the package via npm:
npm install @okxweb3/coin-eos
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getRandomPrivateKey | Generate a random private key | |
getDerivedPrivateKey | Generate a private key from DerivePriKeyParams | |
getNewAddress | Get a new address through a private key | |
signTransaction | Sign a transaction | |
getDerivedPath | Get a bip44 path | |
calcTxHash | Get a transaction hash through a raw transaction |
For more detailed information about the functions supported by the coin-eos package and use cases, you can view the github document for more detailed content: coin-eos function functions.
Ethereum SDK is a toolkit for integrating with the Ethereum blockchain and other blockchains that support EVM (Ethereum Virtual Machine). It provides a series of functional methods, including generating private keys, deriving private keys, generating addresses, and transferring transactions.
These functional methods make it easier for developers to interact with the Ethereum blockchain, including creating and managing wallets, sending and receiving transactions, and querying blockchain information.
To get the latest version of the package via npm:
npm install @okxweb3/coin-ethereum
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getRandomPrivateKey | Generate a random private key | |
getDerivedPrivateKey | Generate a private key from DerivePriKeyParams | |
getNewAddress | Get a new address through a private key | |
validAddress | Validate an address | |
signTransaction | Sign a transaction | |
getDerivedPath | Get a bip44 path | |
validPrivateKey | Validate a private key | |
signMessage | Sign a message | |
verifyMessage | Verify a signed message | |
ecRecover | Recover a signature to a public key | |
getAddressByPublicKey | Get an address through a public key | |
getHardWareRawTransaction | Get the raw transaction of the hardware | |
getHardWareSignedTransaction | Get the signed transaction of the hardware | |
getHardWareMessageHash | Get the message hash of the hardware | |
calcTxHash | Get a transaction hash through a raw transaction | |
getRawTransaction | Generate raw transaction data | |
validSignedTransaction | Check a signed transaction |
For more detailed information about the functions supported by the coin-ethereum package and use cases, you can view the github document for more detailed content: coin-ethereum function functions.
Flow blockchain is a next-generation, future-oriented blockchain platform, specifically designed for high-performance applications and games.
Flow SDK is a toolkit for integrating with the Flow blockchain. It provides a series of functional methods, enabling developers to interact more conveniently with the Flow blockchain. The specific functionalities offered by the SDK can facilitate the development of applications on the Flow blockchain.
To get the latest version of the package via npm:
npm install @okxweb3/coin-flow
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
validateAddress | Validate an address | |
signTransaction | Sign a transaction |
Flow supports two types of transactions: Account and Transfer.
For more detailed information about the functions supported by the coin-flow package and use cases, you can view the github document for more detailed content: coin-flow function functions.
Near Protocol is a scalable blockchain platform that achieves high throughput and low latency transaction processing by using a novel consensus mechanism and sharding technology. Near SDK allows developers to interact more conveniently with the Near blockchain.
Near SDK is a toolkit for integrating with the Near Protocol, containing the main functions needed when interacting with the Near ecosystem.
To get the latest version of the package via npm:
npm install @okxweb3/coin-near
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getAddress | Get an address through a seed | |
validateAddress | Validate an address | |
signTransaction | Sign a transaction | |
transfer | Transfer a coin | |
fullAccessKey | Get a full access key | |
publicKeyFromSeed | Get a public key from a seed |
For more detailed information about the functions supported by the coin-near package and use cases, you can view the github document for more detailed content: coin-near function functions.
Polkadot is a multi-chain heterogeneous blockchain platform, which allows various blockchain networks to run in parallel with a shared security model, and can also realize seamless transfer of information and value between chains.
Polkadot SDK is a toolkit for integrating with the Polkadot blockchain, containing the main functions needed when interacting with the Polkadot ecosystem.
To get the latest version of the package via npm:
npm install @okxweb3/coin-polkadot
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getAddress | Get an address through a seed | |
validateAddress | Validate an address | |
SignTx | Sign a transaction |
For more detailed information about the functions supported by the coin-polkadot package and use cases, you can view the github document for more detailed content: coin-polkadot function functions.
Solana is a high-performance blockchain platform that achieves high throughput and low latency transaction processing through an innovative consensus algorithm and block generation mechanism.
Solana SDK is a toolkit for integrating the Solana blockchain, containing the main functions needed when interacting with the Solana ecosystem.
To get the latest version of the package via npm:
npm install @okxweb3/coin-solana
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getRandomPrivateKey | Generate a random private key | |
getDerivedPrivateKey | Generate a private key from DerivePriKeyParams | |
getNewAddress | Get a new address through a private key | |
validAddress | Validate an address | |
signTransaction | Sign a transaction | |
getDerivedPath | Get a bip44 path | |
signMessage | Sign a message | |
calcTxHash | Get a transaction hash through a raw transaction | |
validSignedTransaction | Check a signed transaction | |
getHardWareRawTransaction | Get the raw transaction of the hardware | |
getHardWareSignedTransaction | Get the signed transaction of the hardware | |
getHardWareMessageHash | Get the message hash of the hardware |
For more detailed information about the functions supported by the coin-solana package and use cases, you can view the github document for more detailed content: coin-solana function functions.
Stacks is an open-source blockchain platform that allows developers to build smart contracts and decentralized applications on the Stacks blockchain.
Stacks SDK is mainly used to integrate Stacks blockchain, containing various functions that can be used for web3 wallets.
To get the latest version of the package via npm:
npm install @okxweb3/coin-stacks
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getRandomPrivateKey | Generate a random private key | |
getDerivedPrivateKey | Generate a private key from DerivePriKeyParams | |
getNewAddress | Get a new address through a private key | |
validAddress | Validate an address | |
signTransaction | Sign a transaction | |
getDerivedPath | Get a bip44 path | |
signMessage | Sign a message | |
verifyMessage | Verify a signed message | |
calcTxHash | Get a transaction hash through a raw transaction | |
getRawTransaction | Get a raw transaction |
For more detailed information about the functions supported by the coin-stacks package and use cases, you can view the github document for more detailed content: coin-stacks function functions.
StarkNet is a decentralized, scalable blockchain network that uses zero-knowledge proof technology to enhance the efficiency and security of transaction processing.
StarkNet SDK is a toolkit for integrating the StarkNet blockchain, providing a series of functional methods that make it easier for developers to interact with the StarkNet blockchain.
To get the latest version of the package via npm:
npm install @okxweb3/coin-starknet
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getRandomPrivateKey | Generate a random private key | |
getDerivedPrivateKey | Generate a private key from DerivePriKeyParams | |
getNewAddress | Get a new address through a private key | |
validAddress | Validate an address | |
signTransaction | Sign a transaction | |
getDerivedPath | Get a bip44 path | |
signMessage | Sign a message | |
verifyMessage | Verify a signed message |
For more detailed information about the functions supported by the coin-starknet package and use cases, you can view the github document for more detailed content: coin-starknet function functions.
SUI SDK is a toolkit for integrating the SUI blockchain, containing various functions that can be used for web3 wallets.
To get the latest version of the package via npm:
npm install @okxweb3/coin-sui
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getRandomPrivateKey | Generate a random private key | |
getDerivedPrivateKey | Generate a private key from DerivePriKeyParams | |
getNewAddress | Get a new address through a private key | |
validAddress | Validate an address | |
signTransaction | Sign a transaction | |
getDerivedPath | Get a bip44 path | |
signMessage | Sign a message | |
calcTxHash | Get a transaction hash through a raw transaction |
For more detailed information about the functions supported by the coin-sui package and use cases, you can view the github document for more detailed content: coin-sui function functions.
TRON SDK is a toolkit for integrating the TRON blockchain, containing various functions that can be used for web3 wallets.
To get the latest version of the package via npm:
npm install @okxweb3/coin-tron
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getRandomPrivateKey | Generate a random private key | |
getDerivedPrivateKey | Generate a private key from DerivePriKeyParams | |
getNewAddress | Get a new address through a private key | |
validAddress | Validate an address | |
signTransaction | Sign a transaction | |
getDerivedPath | Get a bip44 path | |
validPrivateKey | Validate a private key | |
signMessage | Sign a message | |
verifyMessage | Verify a signed message | |
ecRecover | Recover a signature to a public key | |
getAddressByPublicKey | Get an address through a public key | |
getHardWareRawTransaction | Get the raw transaction of the hardware | |
getHardWareSignedTransaction | Get the signed transaction of the hardware | |
getHardWareMessageHash | Get the message hash of the hardware | |
calcTxHash | Get a transaction hash through a raw transaction | |
getRawTransaction | Generate raw transaction data | |
validSignedTransaction | Check a signed transaction |
For more detailed information about the functions supported by the coin-tron package and use cases, you can view the github document for more detailed content: coin-tron function functions.
ZKSpace SDK is mainly used to integrate ZK contracts, containing various functions that can be used for web3 wallets. In addition to ZKSpace, it also supports zkSync.
To get the latest version of the package via npm:
npm install @okxweb3/coin-zkspace
Supported functions:
Function name | Functionality | Remarks |
---|---|---|
getRandomPrivateKey | Generate a random private key | |
getDerivedPrivateKey | Generate a private key from DerivePriKeyParams | |
getNewAddress | Get a new address through a private key | |
validAddress | Validate an address | |
signTransaction | Sign a transaction | |
getDerivedPath | Get a bip44 path | |
validPrivateKey | Validate a private key | |
signMessage | Sign a message | |
verifyMessage | Verify a signed message | |
ecRecover | Recover a signature to a public key | |
getAddressByPublicKey | Get an address through a public key | |
getHardWareRawTransaction | Get the raw transaction of the hardware | |
getHardWareSignedTransaction | Get the signed transaction of the hardware | |
getHardWareMessageHash | Get the message hash of the hardware | |
calcTxHash | Get a transaction hash through a raw transaction | |
getRawTransaction | Generate raw transaction data |
The transaction signature supports data types including: transfer and changePubkey.
For more detailed information about the functions supported by the coin-zkspace package and use cases, you can view the github document for more detailed content: coin-zkspace function functions.
On github, there is a tests
directory under the package corresponding to each module, which contains test cases for various coin modules. You can learn more about the usage of functions in the SDK through these test cases.
Coin family | Coin | Derivation path |
---|---|---|
BTC | BTC | Regular address: m/44'/0'/0/0'/0 SegWit: m/49'/0'/0/0'/0 m/84'/0'/0/0'/0 m/86'/0'/0/0'/0 |
BTC | BCH | m/44'/145'/0'/0/0 |
BTC | BSV | m/44'/236'/0'/0/0 |
BTC | LTC | m/44'/2'/0'/0/0 |
BTC | Doge | m/44'/3'/0'/0/0 |
BTC | TBTC | m/44'/0'/0/0'/0 |
BTC | Omni USDT | m/44'/0'/0/0'/0 |
ETH | ETH | m/44'/60'/0'/0/0 |
ETH | Arbitrum One | m/44'/60'/0'/0/0 |
ETH | Arbitrum Nova | m/44'/60'/0'/0/0 |
ETH | Avalanche C | m/44'/60'/0'/0/0 |
ETH | Boba | m/44'/60'/0'/0/0 |
ETH | BNB Chain | m/44'/60'/0'/0/0 |
ETH | Base | m/44'/60'/0'/0/0 |
ETH | Core | m/44'/60'/0'/0/0 |
ETH | Cronos(EVM) | m/44'/60'/0'/0/0 |
ETH | Celo | m/44'/60'/0'/0/0 |
ETH | Conflux(EVM) | m/44'/60'/0'/0/0 |
ETH | Endurance | m/44'/60'/0'/0/0 |
ETH | EthereumPoW | m/44'/60'/0'/0/0 |
ETH | EthereumFair | m/44'/60'/0'/0/0 |
ETH | Filecoin EVM | m/44'/60'/0'/0/0 |
ETH | Fantom | m/44'/60'/0'/0/0 |
ETH | Flare | m/44'/60'/0'/0/0 |
ETH | Gnosis | m/44'/60'/0'/0/0 |
ETH | Goerli | m/44'/60'/0'/0/0 |
ETH | HAQQ Network | m/44'/60'/0'/0/0 |
ETH | Klaytn | m/44'/60'/0'/0/0 |
ETH | KCC | m/44'/60'/0'/0/0 |
ETH | Kava EVM | m/44'/60'/0'/0/0 |
ETH | Linea | m/44'/60'/0'/0/0 |
ETH | Metis | m/44'/60'/0'/0/0 |
ETH | Moonebeam | m/44'/60'/0'/0/0 |
ETH | Moonriver | m/44'/60'/0'/0/0 |
ETH | Mantle | m/44'/60'/0'/0/0 |
ETH | Omega Network | m/44'/60'/0'/0/0 |
ETH | OKTC | m/44'/60'/0'/0/0 |
ETH | Optimism | m/44'/60'/0'/0/0 |
ETH | opBNB | m/44'/60'/0'/0/0 |
ETH | Polygon | m/44'/60'/0'/0/0 |
ETH | Polygon zkEVM | m/44'/60'/0'/0/0 |
ETH | PulseChain | m/44'/60'/0'/0/0 |
ETH | Sepolia | m/44'/60'/0'/0/0 |
ETH | zkSync Era | m/44'/60'/0'/0/0 |
ETH | ZetaChian | m/44'/60'/0'/0/0 |
Cosmos | Atom | m/44'/118'/0'/0/0 |
Cosmos | Axelar | m/44'/118'/0'/0/0 |
Cosmos | Cronos | m/44'/394'/0'/0/0 |
Cosmos | Osmos | m/44'/118'/0'/0/0 |
Cosmos | Evmos | m/44'/60'/0'/0/0 |
Cosmos | Iris | m/44'/118'/0'/0/0 |
Cosmos | Juno | m/44'/118'/0'/0/0 |
Cosmos | Kava | m/44'/459'/0'/0/0 |
Cosmos | Kujira | m/44'/118'/0'/0/0 |
Cosmos | Secret | m/44'/529'/0'/0/0 |
Cosmos | Sei | m/44'/118'/0'/0/0 |
Cosmos | Stargaze | m/44'/118'/0'/0/0 |
Cosmos | Terra | m/44'/330'/0'/0/0 |
Aptos | Aptos | m/44'/637'/0'/0/0 |
EOS | EOS | m/44'/194'/0'/0/0 |
Solana | Solana | m/44'/501'/0'/0/0 |
Stacks | Stacks | m/44'/5757'/0'/0/0 |
ETH lay2 | Starknet | m/44'/9004'/0'/0/0 |
SUI | SUI | m/44'/784'/0'/0/0 |
TRX | TROM | m/44'/195'/0'/0/0 |
ETH lay2 | ZKSpace | m/44'/60'/0'/0/0 |
ETH lay2 | zkSync | m/44'/60'/0'/0/0 |