![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@coolwallet/bsc
Advanced tools
Typescript library with support for the integration of BSC for third party application, include the functionalities of generation of addresses and signed transactions.
npm install @coolwallet/bsc
import BSC from '@coolwallet/bsc'
import { crypto } from '@coolwallet/core';
import { createTransport } from '@coolwallet/transport-web-ble';
const bsc = new BSC();
const transport = await createTransport();
const { privateKey: appPrivateKey } = crypto.key.generateKeyPair();
const appId = 'appId that had been registered by wallet';
const addressIndex = 0;
const address = await bsc.getAddress(transport, appPrivateKey, appId, addressIndex);
const transaction = {
nonce: "0x87",
gasPrice: "0x12a05f200",
gasLimit: "0xcf08",
to: "0x8A1628c2397F6cA75579A45E81EE3e17DF19720e",
value: "xe8d4a51000",
data: "",
chainId: 56
}
const signTxData = {
transport,
appPrivateKey,
appId,
transaction,
addressIndex
}
const normalTx = await bsc.signTransaction(signTxData);
const bep20Transaction = {
nonce: "0x87",
gasPrice: "0x12a05f200",
gasLimit: "0x5208",
to: "0x55d398326f99059ff775485246999027b3197955",
value: "0x0",
data: "0xa9059cbb000000000000000000000000BDCc4DBd6",
chainId: 56,
option: {
symbol: "USDT",
unit: "18"
}
}
const bep20SignTxData = {
transport,
appPrivateKey,
appId,
transaction: bep20Transaction,
addressIndex
}
const bep20Tx = await bsc.signBEP20Transaction(bep20SignTxData);
The address generated is compatible to BIP44 with account and change set to 0, which means calling getAddress
with addressIndex = i
will get the address of folllowing BIP44 path:
m/44'/60'/0'/0/{i}
In the design of current hardware, we only support path m/44'/60'/0'/0/{i}
for speed optimization. This might change in the future and we will then open a more general interface to deal with custom path.
async getAddress(
transport: types.Transport,
appPrivateKey: string,
appId: string,
addressIndex: number
): Promise<string>
Arg | Description | Type | Required |
---|---|---|---|
transport | Object to communicate with CoolWallet device | Transport | True |
appPrivateKey | Private key for the connected application | string | True |
appId | ID for the connected application | string | True |
addressIndex | The from address index in BIP44 derivation | number | True |
Sign BSC Transaction. If the transaction has non-empty data
field, the card will display SMART
instead of transfering amount.
async signTransaction(signTxData: types.signTx)
Arg | Description | Type | Required |
---|---|---|---|
transport | Object to communicate with CoolWallet device | Transport | True |
appPrivateKey | Private key for the connected application | string | True |
appId | ID for the connected application | string | True |
transaction | Essential information/property for BSC Transaction | Transaction | True |
addressIndex | The from address index in BIP44 derivation | number | True |
publicKey | Public key of the from address | string | True |
confirmCB | Callback of confirmation data to the connected application | Function | False |
authorizedCB | Callback of authorized transaction data to the connected application | Function | False |
Perform BSC personal_sign
.
async signMessage(signMsgData: types.signMsg): Promise<string>
Arg | Description | Type | Required |
---|---|---|---|
transport | Object to communicate with CoolWallet device | Transport | True |
appPrivateKey | Private key for the connected application | string | True |
appId | ID for the connected application | string | True |
message | Message to sign | string | True |
addressIndex | The from address index in BIP44 derivation | number | True |
confirmCB | Callback of confirmation data to the connected application | Function | False |
authorizedCB | Callback of authorized data to the connected application | Function | False |
Perform BSC sign_typed_data
.
async signTypedData(typedData: types.signTyped): Promise<string>
Arg | Description | Type | Required |
---|---|---|---|
transport | Object to communicate with CoolWallet device | Transport | True |
appPrivateKey | Private key for the connected application | string | True |
appId | ID for the connected application | string | True |
typedData | Typed structured data to be signed | any | True |
addressIndex | The from address index in BIP44 derivation | number | True |
confirmCB | Callback of confirmation data to the connected application | Function | False |
authorizedCB | Callback of authorized data to the connected application | Function | False |
FAQs
Coolwallet BSC sdk
The npm package @coolwallet/bsc receives a total of 36 weekly downloads. As such, @coolwallet/bsc popularity was classified as not popular.
We found that @coolwallet/bsc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.