Using the SDK
The BITE JavaScript SDK lets applications and wallets encrypt EVM transactions. It adds threshold encryption to SKALE so developers can build private and confidential applications on the network.Installation
The SDK works with any BITE-enabled SKALE chain. Right now, BITE is available on SKALE Base Mainnet and Testnet only.
Quick Start
API Reference
new BITE(endpoint)
Creates a BITE instance for a specific BITE JSON-RPC endpoint.
Parameters:
endpoint: string- BITE JSON-RPC endpoint
bite.encryptTransaction(tx)
Encrypts a transaction object with the BLS threshold encryption public key or keys from the configured BITE provider. The encrypted transaction uses the BITE magic address in the to field.
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 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:
When using the SDK in the browser, you may need to polyfill For Vite, add to your For Webpack 5, add to your
Buffer. Install the buffer package and configure your bundler:vite.config.ts:webpack.config.js:bite.getDecryptedTransactionData(transactionHash)
Retrieves decrypted transaction data from the configured BITE provider with 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 works only for BITE transactions that have already been processed and decrypted by the network. If the transaction does not exist, or if decrypted data is unavailable, the call throws an error.
bite.getCommitteesInfo()
Fetches committee information from the configured BITE provider with 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: Normal operation with a single active committee
- 2 elements: Committee rotation window, usually covering the next 3 minutes
Best Practices
Gas Limit Management
Monitoring Committee Changes
This is not required for one-off encrypted transactions. If you are building with conditional transactions, you can optionally monitor committee changes to handle expirations during committee rotation.
