Getting Started
Installation
- NPM
- Yarn
- Build From Source
npm install @provablehq/sdk
yarn add @provablehq/sdk
- Clone the SDK repository
- Navigate to
sdk/and execute the following command:
yarn build:all
Configuration
Ensure Compatibility with ES Modules
In your project's package.json, ensure that the following line is added above scripts:
"type": "module",
Top-Level Await
Top level await is a feature that allows you to use the await keyword outside of an async function. This feature is necessary for the Provable SDK to function correctly.
In webpack this is enabled with the following options within webpack.config.js:
experiments: {
asyncWebAssembly: true,
topLevelAwait: true,
},
Framework Specific Configuration
The npm package create-leo-app offers several templates for building zero knowledge JavaScript apps using several popular frameworks including React, Next.js, and Node. Examining the configuration of these templates can provide additional guidance on how to configure your project.
If you are using Node.js as your framework, the Provable SDK requires a minimum of Node.js version 20 and recommends using version 22+ for best performance.
Network Selection
The Provable SDK contains modules for interacting with both the Mainnet and Testnet networks. The Mainnet and Testnet networks are NOT interoperable so it is required to explicitly select the desired network. Any transactions built for the Mainnet network will not be valid on the Testnet network and vice versa.
The following import syntax is used to select the desired network:
Mainnet
import { ... } from '@provablehq/sdk/mainnet.js';
Testnet
import { ... } from '@provablehq/sdk/testnet.js';
If no network is explicitly selected, the SDK defaults to the testnet network.
WebAssembly Initialization
When the SDK is imported, single-threaded WebAssembly is enabled by default. However, it is recommended to enable multithreaded WebAssembly as it is much more performant and eliminates the possibility of a computationally expensive operation blocking the main thread.
Multi-threaded WebAssembly is enabled by calling the initThreadPool() function at the beginning of the application. This starts multiple WebWorker threads and provides access to the WebAssembly instance and memory to each thread.
This function only needs to be called once and should be called before any other SDK functions.
import { initThreadPool } from '@provablehq/sdk/mainnet.js';
// Enables multithreading
await initThreadPool();
// Perform further program logic...