@bitahon/protocol
This library provides an implementation of the Bitahon Protocol Buffers (protobuf) messages.
Installation
General
To obtain the latest version, simply require the project using npm
:
npm install @bitahon/protocol
Usage
import {
APP_ID,
common,
session,
transport,
bitcoin,
} from '@bitahon/protocol';
const bip32Path: common.IBip32Path = {
value: [2147483692, 2147483648, 2147483648, 0, 0], // 44'/0'/0'/0/0
curve: 1, // secp256k1
};
const params: Uint8Array = common.encodeGetPublicKey({
network: bitcoin.NETWORK_ID.BITCOIN_MAINNET,
path: bip32Path,
});
const request: Uint8Array = session.encodeApiRequest({
id: 1,
app: APP_ID.BITCOIN,
method: 1, // GET_PUBLIC_KEY
params,
});
const payload: Uint8Array = transport.encodeApiTransport({
data: request,
// sign,
});
API
APP_ID
Application | uint32 |
---|---|
WALLET | 1 |
BITCOIN | 2 |
ETHEREUM | 3 |
TRON | 4 |
transport
Interfaces
Functions
session
Interfaces
Functions
wallet
METHOD_ID
Method | uint32 |
---|---|
NEW_SESSION | 1 |
Interfaces
Functions
common
Interfaces
Functions
- encodeBip32Path
- decodeBip32Path
- encodeGetPublicKey
- decodeGetPublicKey
- encodeGetPublicKeyResult
- decodeGetPublicKeyResult
- encodeECDSASignResult
- decodeECDSASignResult
- encodeTokenMetadata
- decodeTokenMetadata
bitcoin
NETWORK_ID
Network | uint32 |
---|---|
BITCOIN_MAINNET | 1 |
BITCOIN_TESTNET | 2 |
LITECOIN_MAINNET | 3 |
LITECOIN_TESTNET | 4 |
DOGECOIN_MAINNET | 5 |
METHOD_ID
Method | uint32 |
---|---|
GET_PUBLIC_KEY | 1 |
SIGN_MESSAGE | 2 |
SIGN_TRANSACTION | 3 |
Interfaces
Functions
- encodeSignMessage
- decodeSignMessage
- encodeSignTransaction
- decodeSignTransaction
- encodeSignTransactionResult
- decodeSignTransactionResult
ethereum
NETWORK_ID
Network | uint32 |
---|---|
ETHEREUM_MAINNET | 1 |
ETHEREUM_GOERLI | 2 |
POLYGON_MAINNET | 3 |
OPTIMISM_MAINNET | 4 |
ARBITRUM_MAINNET | 5 |
BSC_MAINNET | 6 |
AVALANCHE_MAINNET | 7 |
WBT_MAINNET | 8 |
BASE_MAINNET | 9 |
ETHEREUM_SEPOLIA | 10 |
METHOD_ID
Method | uint32 |
---|---|
GET_PUBLIC_KEY | 1 |
SIGN_PERSONAL_MESSAGE | 2 |
SIGN_EIP712_MESSAGE | 3 |
SIGN_EIP712_HASHED_MESSAGE | 4 |
SIGN_TRANSACTION | 5 |
Interfaces
Functions
- encodeSignPersonalMessage
- decodeSignPersonalMessage
- encodeSignEIP712Message
- decodeSignEIP712Message
- encodeSignEIP712HashedMessage
- decodeSignEIP712HashedMessage
- encodeSignTransaction
- decodeSignTransaction
tron
NETWORK_ID
Network | uint32 |
---|---|
TRON_MAINNET | 1 |
TRON_TESTNET | 2 |
METHOD_ID
Method | uint32 |
---|---|
GET_PUBLIC_KEY | 1 |
SIGN_PERSONAL_MESSAGE | 2 |
SIGN_TRANSACTION | 3 |