Using the SDK
The BITE JavaScript SDK enables application and wallet developers to encrypt EVM transactions. BITE extends SKALE’s provably secure consensus protocol with threshold encryption, allowing developers to build private and confidential applications on SKALE.Installation
The SDK works with any BITE-enabled SKALE chain. Currently, BITE is available on SKALE Base Mainnet and Testnet ONLY.
Quick Start
API Reference
new BITE(endpoint)
Creates a new BITE instance configured to use a specific BITE JSON-RPC endpoint.
Parameters:
endpoint: string– BITE URL provider (JSON-RPC endpoint)
bite.encryptTransaction(tx)
Encrypts a transaction object using the BLS threshold encryption public key(s) from the configured BITE provider. The encrypted transaction will have its to field set to the BITE magic address.
Parameters:
tx: { to: string; data: string; /* optional gas and other fields */ }– Standard hex strings
Promise<Transaction> – Encrypted params safe to submit to eth_sendTransaction
Encryption Process:
- RLP encodes the original
dataandtofields - Encrypts the encoded data using AES with a randomly generated key
- Encrypts the AES key using BLS threshold encryption
- Creates the final payload in RLP format:
[EPOCH_ID, ENCRYPTED_BITE_DATA]
bite.encryptMessage(message)
Encrypts a raw hex-encoded message using the BLS threshold encryption from the configured BITE provider.
Parameters:
message: string– A hex string to encrypt (with or without0xprefix)
Promise<string> – An encrypted hex string in RLP format with epoch and encryption data
Example:
bite.getDecryptedTransactionData(transactionHash)
Retrieves decrypted transaction data from the configured BITE provider using the bite_getDecryptedTransactionData JSON-RPC method.
Parameters:
transactionHash: string– The transaction hash to decrypt
Promise<object> – JSON object with data and to keys containing the original decrypted fields
Example:
This method only works for BITE transactions that have been processed and decrypted by the consensus. If the transaction doesn’t exist or has no decrypted data, an error is thrown.
bite.getCommitteesInfo()
Fetches committee information from the configured BITE provider using the bite_getCommitteesInfo JSON-RPC method.
Returns: Promise<Array> – An array of 1-2 JSON objects, each containing:
commonBLSPublicKey: A 256-character hex string (128-byte BLS public key)epochId: An integer representing the epoch identifier
- 1 element: During normal operation (single active committee)
- 2 elements: During committee rotation periods (scheduled for next 3 minutes)
Best Practices
Gas Limit Management
Monitoring Committee Changes
This is not a requirement for single use encrypted transactions. If you are building with Conditional Transactions, you can optionally monitor committee changes to handle expiration of a conditional transaction which can occur during
