Skip to main content
TypeScript transpiles to JavaScript, so the SDK works in both TypeScript and JavaScript across Node.js, Bun, and browser environments. If you run into an issue, reach out in Discord or open an issue on GitHub.
The BITE TypeScript SDK (@skalenetwork/bite) lets applications and wallets encrypt EVM transactions using threshold encryption. It works with any SKALE chain that has Programmable Privacy enabled.

Installation

The SDK works with any SKALE chain with Programmable Privacy. Currently, it is available on SKALE Base Mainnet and Testnet only.

Quick Start

API Reference

new BITE(endpoint)

Creates a BITE instance configured with a JSON-RPC endpoint. Parameters:
  • endpoint: string — JSON-RPC endpoint
Example:

bite.encryptTransaction(tx)

Encrypts a transaction using BLS threshold encryption. The encrypted transaction will have its to field set to the magic address. Parameters:
  • tx: { to: string; data: string; gasLimit?: number } — Standard hex strings
Returns: Promise<Transaction> — Encrypted transaction safe to submit to eth_sendTransaction Encryption Process:
  1. RLP encodes original data and to fields
  2. Encrypts encoded data using AES with randomly generated key
  3. Encrypts AES key using BLS threshold encryption
  4. Creates final payload: [EPOCH_ID, ENCRYPTED_BITE_DATA]
Committee Behavior:
  • Single Committee: AES key encrypted with current BLS public key
  • Dual Committee: During rotation, AES key encrypted twice (current + next committee keys)
Set gasLimit manually. estimateGas does not return a reliable value for encrypted transactions. If gasLimit is omitted, defaults to 300000.

BITE.encryptTransactionWithCommitteeInfo(tx, committees)

Static method that encrypts using provided committee info, avoiding internal RPC call. Parameters:
  • tx: object — Transaction with data and to fields
  • committees: Array — Committee info objects (from getCommitteesInfo)
Returns:
  • Promise<Transaction> — Encrypted transaction
Use Case: Offline/cached encryption when committee info is already known.

bite.encryptMessage(message)

Encrypts a raw hex-encoded message using BLS threshold encryption. Parameters:
  • message: string — Hex string to encrypt (with or without 0x prefix)
Returns: Promise<string> — Encrypted hex string in RLP format with epoch and encryption data Example:

bite.getDecryptedTransactionData(transactionHash)

Retrieves decrypted transaction data after consensus finality using bite_getDecryptedTransactionData JSON-RPC method. Parameters:
  • transactionHash: string — The transaction hash
Returns: Promise<object> — JSON with data and to keys containing original decrypted fields Example:
This method works only for encrypted 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 using bite_getCommitteesInfo JSON-RPC method. Returns: Promise<Array> — Array of 1-2 committee objects:
  • commonBLSPublicKey: 256-char hex (128-byte BLS public key)
  • epochId: Integer epoch identifier
Array Contents:
  • 1 element: Normal operation (single active committee)
  • 2 elements: Committee rotation period (scheduled for next 3 minutes)
Example:

Transaction Structure

Encrypted Transaction Format

Encryption Payload Structure

The encrypted data field contains RLP-encoded array:
  • EPOCH_ID — Current committee epoch
  • ENCRYPTED_BITE_DATA — AES-encrypted payload with BLS-encrypted AES key

Best Practices

Gas Limit Management

Always set an explicit gas limit for encrypted transactions. Do not rely on estimateGas().

Browser Polyfills

When using the SDK in the browser, you may need to polyfill Buffer:
Vite — add to vite.config.ts:
Webpack 5 — add to webpack.config.js:

Committee Rotation Monitoring

Common Use Cases

Private Token Transfers

Confidential Contract Interactions

Cached Committee Encryption

Resources