If you're building a WebApp with CoolWallet, this is the one you need to use as transport
in other api.
npm i @coolwallet/transport-web-ble
import ETH from '@coolwallet/eth';
import { crypto } from '@coolwallet/core';
import { createTransport } from '@coolwallet/transport-web-ble';
const transport = await createTransport();
const { privateKey: appPrivateKey } = crypto.key.generateKeyPair();
const appId = 'appId that had been registered by wallet';
const eth = new ETH();
// use transport in other package
const address = await eth.getAddress(transport, appPrivateKey, appId, 0);
A convenient way to create internal transport.
const createTransport: () => Promise<Transport>
Manage browser bluetooth status.
Check whether browser support Web Bluetooth API.
async isSupported(): Promise<boolean>
Popup browser bluetooth selector.
Return the selected BluetoothDevice
.
async listen(): Promise<BluetoothDevice>
Connected to the given BluetoothDevice
and create transport
.
async connect(device: BluetoothDevice): Promise<Transport>
Disconnect from the BluetoothRemoteGATTServer
and remove transport
.
async disconnect(): Promise<void>