JavaScript/TypeScript
The JS-Bindings uses emscripten to create a webassembly which can easily be packed even using webpack or in a nodejs env. In Node.js the package additionally ships a native addon (N-API) with platform-optimized assembly, which is loaded automatically and makes proof verification an order of magnitude faster than the WASM build (see Native Addon in Node.js).
Installation
npm install @corpus-core/colibri-stateless
Import / Usage (ESM and CommonJS)
Colibri is published as a dual package and can be used in both ESM and CommonJS environments.
ESM (browsers, modern bundlers, Node ESM)
import Colibri, { Strategy, set_wasm_url } from "@corpus-core/colibri-stateless";
// Optional: only needed if you want to pin the WASM location explicitly
// set_wasm_url("https://example.com/c4w.wasm");
const client = new Colibri();
CommonJS (e.g. Jest, older Node toolchains)
const { default: Colibri, Strategy, set_wasm_url } = require("@corpus-core/colibri-stateless");
// Optional: in Node you can explicitly point to the wasm file path
// set_wasm_url(require("node:path").join(__dirname, "c4w.wasm"));
const client = new Colibri();
Native Addon in Node.js
The BLS pairing check is by far the most expensive part of proof verification. The generic WASM build cannot use CPU-specific instructions, so in Node.js the package bundles a self-contained native N-API addon (colibri_native.node) that statically links the C core including blst with platform-optimized assembly — making BLS pairing (and thus proof verification) ~25-30x faster than WASM.
How it works
The runtime selection is fully transparent — no code changes and no optional dependencies are required:
- Browser / bundlers always use the WASM build. The native code paths are behind the
nodecondition in the package exports, so webpack/vite/etc. never see them. - Node.js resolves the
nodeconditional export, which looks for a prebuilt addon matching the current platform underprebuilds/<platform>-<arch>/inside the package. - If no prebuild exists for the platform (or loading fails), the client silently falls back to the WASM build — same API, same results, just slower.
You can check which runtime is active:
import { getRuntime } from "@corpus-core/colibri-stateless";
const runtime = await getRuntime();
console.log(runtime.kind); // 'native' or 'wasm'
Bundled prebuild targets
| Target | Platform |
|---|---|
linux-x64 |
Linux (glibc), x86-64 |
linux-arm64 |
Linux (glibc), ARM64 |
darwin-arm64 |
macOS, Apple Silicon |
darwin-x64 |
macOS, Intel |
win32-x64 |
Windows, x86-64 |
The addon only uses N-API version 8 symbols resolved from the Node.js host process, so a single prebuild works across Node versions (Node >= 12.22, tested with current LTS releases).
Environment variables
| Variable | Effect |
|---|---|
C4_NATIVE_ADDON=<path> |
Load the addon from an explicit path (overrides the prebuild lookup) |
C4_FORCE_NATIVE=1 |
Fail hard instead of falling back to WASM (useful in CI/benchmarks) |
C4_DISABLE_NATIVE=1 |
Skip the native addon entirely and always use WASM |
C4_DEBUG_NATIVE=1 |
Log the reason when falling back to WASM |
Building the addon from source
For platforms without a bundled prebuild, the addon can be built with plain CMake (no node-gyp required; the node-api-headers are fetched automatically):
cmake -S . -B build/node-addon -DCMAKE_BUILD_TYPE=Release -DNODE_ADDON=1
cmake --build build/node-addon --target colibri_native
# -> build/node-addon/node-addon/colibri_native.node
export C4_NATIVE_ADDON=$PWD/build/node-addon/node-addon/colibri_native.node
Limitations
- The addon (like the underlying C library) keeps global state and must not be used concurrently from multiple
worker_threads. - Custom storage callbacks (
register_storage) are invoked synchronously and should not throw; a throwing callback is treated as a cache miss.
Using Colibri as RPC Provider
The Colibri Class implements the EIP-1193 Interface, so any library supporting EIP-1193 Providers can easily use Colibri as RPCProvider.
Right now Subscription and Filters have not been implemented, so in case you need those features, jus use a different Provider for those tasks and the verify the found logs using Colibri. But those features will be implemented in one of the next releases.
import { BrowserProvider } from "ethers";
import Colibri from "@corpus-core/colibri-stateless";
async function main() {
// Initialize the client with the default configuration and RPCs
const client = new Colibri({prover:['https://mainnet.colibri-proof.tech']});
// Use Colibri client as the EIP-1193 provider for ethers (v6)
const provider = new BrowserProvider(client);
// Fetch the latest block using the ethers provider
const block = await provider.getBlock('latest');
console.log("Block fetched via ethers:", block);
}
main().catch(console.error);
import * as ethers from "ethers";
import Colibri from "@corpus-core/colibri-stateless";
async function main() {
// Initialize the client with the default configuration and RPCs
const client = new Colibri({prover:['https://mainnet.colibri-proof.tech']});
// Use Colibri client as the EIP-1193 provider for ethers (v6)
const provider = new ethers.providers.Web3Provider(client);
// Fetch the latest block using the ethers provider
const block = await provider.getBlock('latest');
console.log("Block fetched via ethers:", block);
}
main().catch(console.error);
import Web3 from 'web3';
import Colibri from "@corpus-core/colibri-stateless";
async function main() {
// Initialize the client with the default configuration and RPCs
const client = new Colibri({prover:['https://mainnet.colibri-proof.tech']});
// Use Colibri client as the EIP-1193 provider for web3.js
const web3 = new Web3(client);
// Fetch the latest block using the web3.js provider
const block = await web3.eth.getBlock('latest');
console.log("Block fetched via web3.js:", block);
}
main().catch(console.error);
import { createPublicClient, custom } from 'viem';
import { mainnet } from 'viem/chains';
import Colibri from "@corpus-core/colibri-stateless";
async function main() {
// Initialize the Colibri client
const colibriClient = new Colibri({prover:['https://mainnet.colibri-proof.tech']});
// Create a viem Public Client using Colibri as a custom EIP-1193 transport
const viemClient = createPublicClient({
chain: mainnet, // Specify the chain
transport: custom(colibriClient) // Wrap Colibri client
});
// Fetch the latest block using the viem client
const block = await viemClient.getBlock({ blockTag: 'latest' });
console.log("Block fetched via viem:", block);
}
main().catch(console.error);
Secure Transaction Verification
Colibri provides built-in protection against NPM supply-chain attacks and transaction manipulation through its transaction verification feature. When enabled, all eth_sendTransaction calls are automatically verified before being broadcast to the network.
How it works
- Sign via Fallback Provider: Transaction is signed using your configured fallback provider (e.g., MetaMask)
- Decode & Verify: The signed transaction is decoded and compared with the original parameters
- Secure Broadcast: Only if verification passes, the transaction is sent to the network
Example
import { BrowserProvider } from "ethers";
import Colibri from "@corpus-core/colibri-stateless";
// 🛡️ Secure transactions with built-in verification
const client = new Colibri({
fallback_provider: window.ethereum, // MetaMask as Signer
verifyTransactions: true // Prevents transaction manipulation
});
const provider = new BrowserProvider(client);
// Send transaction - automatically verified before broadcast
const tx = await provider.getSigner().sendTransaction({
to: "0x742d35cc6633C0532925a3b8D8C9C4e2F9",
value: "0x16345785d8a0000", // 0.1 ETH
gasLimit: "0x5208"
});
console.log("✅ Verified transaction:", tx.hash);
This feature protects against:
- Malicious NPM packages modifying transaction parameters
- Browser extensions tampering with transactions
- Supply-chain attacks targeting transaction data
Building proofs in you app.
If you don't want to use a remote Service building the proofs, you can also use Colibri directly to build the proof or to verify. A Proof is juzst a UInt8Array or just bytes. You write it in a file or package it in your application and verify whenever it is needed:
import Colibri from "@corpus-core/colibri-stateless";
async function main() {
const method = "eth_getTransactionByHash";
const args = ['0x2af8e0202a3d4887781b4da03e6238f49f3a176835bc8c98525768d43af4aa24'];
// Initialize the client with the default configuration and RPCs
const client = new Colibri({prover:['https://mainnet.colibri-proof.tech']});
// Create a proof for the given method and arguments as UInt8Array
const proof = await client.createProof(method, args);
// Verify the proof against requested method and arguments
const result = await client.verifyProof(method, args, proof);
// the result will be the expected json
console.log(result);
}
main().then(console.log).catch(console.error);
Configuration
The constructor of the colibri client accepts a configuration-object, which may configure the client. The following parameters are accepted:
-
chainId- the chain to be used (default is 1, whoich is mainnet).new Colibri({ chainId: 'gnosis'}) -
beacon_apis- urls for the beacon apis
An array of endpoints for accessing the beacon chain using the official Eth Beacon Node API. The Array may contain more than one url, and if one API is not responding the next URL will work as fallback. This beacon API is currently used eitehr when building proofs directly or even if you are using a remote prover, the LightClientUpdates (every 27h) will be fetched directly from the beacon API.new Colibri({ beacon_apis: [ 'https://lodestar-mainnet.chainsafe.io' ]}) -
rpcs- RPCs for the executionlayer
a array of rpc-endpoints for accessing the execution layer. If you are using the remote prover, you may not need it at all. But creating your proofs locally will require to access data from the execution layer. Having more than one rpc-url allows to use fallbacks in case one is not available.new Colibri({ beacon_apis: [ "https://nameless-sly-reel.quiknode.pro/<APIKEY>/", "https://eth-mainnet.g.alchemy.com/v2/<APIKEY>", "https://rpc.ankr.com/eth/<APIKEY>" ]}) -
l1Rpcs- optional execution RPCs for the L1 of the configured chain Requests whosechain_idis the L1 returned byc4_get_l1_chain_id_for_l2are sent to this list when that L1 differs fromchainId. The function maps an EEZ L2 such as RollupX to the L1 it settles on (Ethereum mainnet,1) and every other chain to itself. Omit the list, or pass an empty array, to use the built-in default execution RPCs for that L1. Requests for the configured chain keep usingrpcs, including whenchainIdis already1. Any other chain id is an error.new Colibri({ chainId: 8453, rpcs: ["https://mainnet.base.org"], l1Rpcs: ["https://eth-mainnet.g.alchemy.com/v2/<APIKEY>"] }) -
prover- urls for remote prover an array of endpoints for remote prover. This allows to generate the proof in the backend, where caches can speed up the process.new Colibri({ prover: ["https://mainnet.colibri-proof.tech" ]}) -
prover_mode- proof generation mode (default:"remote"if prover URLs configured, otherwise"local") Controls how proofs are built and verified. Five modes are available:"local"-- Proofs are built entirely on the client. Requires access to a Beacon API and execution layer RPC. Fully trustless, but slower and needs more infrastructure."remote"-- Proofs are fetched from a remote Colibri prover server. Fastest option but relies on the prover server for proof generation. The verifier still cryptographically checks every proof."hybrid"-- The consensus-layer proof (BlockHeaderProof) comes from the Colibri server, while execution-layer data (account proofs, storage, etc.) is fetched directly from the RPC provider. Best balance of performance and scalability -- the Colibri server only serves lightweight, cacheable header proofs while the heavy RPC load goes to your existing provider."proxy"-- Like remote, but the client sends its own RPC and Beacon API URLs to the prover server. The server uses these endpoints instead of its own. Useful when the client has access to private or premium RPC providers."light_client"-- Like hybrid, with additional background polling of block headers to keep the cache warm. CallstartLightClient()/stopLightClient()to control polling. Default interval: 12000ms. By default only the compacteth_getBlockHeaderis fetched; passfullBlock: trueto fetch the full block (useful when manyeth_getTransactionByHash/eth_getTransactionReceiptcalls follow).
// Explicit hybrid mode: header proofs from Colibri, execution data from RPC provider new Colibri({ prover: ["https://mainnet.colibri-proof.tech"], rpcs: ["https://eth-mainnet.g.alchemy.com/v2/<APIKEY>"], prover_mode: "hybrid" }) // Light client mode with background header polling const client = new Colibri({ prover: ["https://mainnet.colibri-proof.tech"], rpcs: ["https://eth-mainnet.g.alchemy.com/v2/<APIKEY>"], prover_mode: "light_client" }); client.startLightClient(); // polls eth_getBlockHeader every 12s client.startLightClient(12000, true); // or fetch the full block -
zk_proof- use remote ZK sync proof for bootstrap (default:false) Iftrue, the verifier will bootstrap the initial sync committee using the ZK proof (ZKSyncData) provided by the remote prover, instead of initializing viacheckpointz/ trusted checkpoints.new Colibri({ prover: ["https://mainnet.colibri-proof.tech"], zk_proof: true }) -
checkpoint_witness_keys- optional checkpoint signer addresses when usingzk_proof(default:null) A list of Ethereum addresses (20 bytes each). The current format is a single hex string where multiple addresses are concatenated (no separator).Example (one signer):
new Colibri({ prover: ["https://mainnet.colibri-proof.tech"], zk_proof: true, checkpoint_witness_keys: "0x07f50c1d17cb84a656692ddfd577c09756cb305b" })Example (two signers concatenated):
new Colibri({ zk_proof: true, checkpoint_witness_keys: "0x<addr1_40hex><addr2_40hex>" }) -
checkpointz- urls for checkpoint servers (Checkpointz or Beacon API)
An array of server endpoints for fetching finalized checkpoint data and weak subjectivity validation. Supports both dedicated Checkpointz servers and standard Beacon API nodes, as the verifier uses the Beacon-API-compatible endpoint/eth/v1/beacon/states/head/finality_checkpoints. These servers provide finalized beacon block roots that the verifier uses for secure initialization and periodic validation. The verifier automatically queries these servers when no trusted checkpoint is provided or when validating long sync gaps. Multiple URLs enable automatic fallback for resilience. Defaults to public Checkpointz servers for mainnet, but you can also use your own Beacon node for maximum trust.// Using public Checkpointz servers (default for mainnet) new Colibri({ checkpointz: [ 'https://sync-mainnet.beaconcha.in', 'https://beaconstate.info', 'https://sync.invis.tools', 'https://beaconstate.ethstaker.cc' ]}) // Or using your own Beacon node for maximum trust new Colibri({ checkpointz: [ 'http://localhost:5052' ]}) -
trusted_checkpoint- optional beacon block hash used as trusted anchor
This single blockhash will be used as anchor for fetching the keys for the sync committee. So instead of starting with the genesis you can define a starting block, where you know the blockhash. If no trusted checkpoint is set, the verifier will automatically fetch the latest finalized checkpoint from a Checkpointz server, making initialization secure and convenient. Providing an explicit trusted checkpoint is recommended for maximum security control but is no longer required.new Colibri({ trusted_checkpoint: "0x4232db57354ddacec40adda0a502f7732ede19ba0687482a1e15ad20e5e7d1e7" }) -
cache- cache impl for rpc-requests
you can provide your own implementation to cache JSON-RPC requests. those function will be used before a request is send, also allowing mock handlers to cache responses for tests.new Colibri({ cache: { cacheable(req: DataRequest) { return req.payload && req.payload.method!='eth_blockNumber' }, get(req: DataRequest) { try { return fs.readFileSync(`${cache_dir}/${req.url}`); } catch (e) { return null } }, set(req: DataRequest, data: Uint8Array) { fs.writeFileSync(`${cache_dir}/${req.url}`, data); } }}) -
debug- if true you will see debug output on the consolenew Colibri({ debug: true}) -
include_code- if true the code of the contracts will be included when creating proofs. this is only relevant when creating your own proofs for eth_call. (default: false)new Colibri({ include_code: true}) -
use_accesslist- iftrue(default), localeth_call/eth_estimateGas/colibri_simulateTransactionproofs useeth_createAccessListto discover touched accounts and storage. Set tofalseonly to opt into the legacydebug_traceCall(prestateTracer) path (C4_PROVER_FLAG_USE_DEBUG_TRACE); that API is not available on every RPC provider, while contract code is usually cached anyway. Irrelevant when proofs are fetched from a remote prover that already chose its own path.new Colibri({ use_accesslist: true }) // default new Colibri({ use_accesslist: false }) // legacy debug_traceCall -
logs_completeness- if true,eth_getLogsproduces (prover) and requires (verifier) a completeness proof over the requested block range[fromBlock, toBlock]. It proves that no matching log was omitted, not just that the returned logs are valid. This sets the prover flag (1 << 12) and the verifier flag (1 << 9) and requires a prover that supports it. The range end (toBlock) may be a pinned block hash/number or"latest";"safe"/"finalized"are not supported yet. (default: false, tracks issue #128)new Colibri({ logs_completeness: true }) -
privacy_mode- PAP (Pragmatic Adaptive Privacy) mode. Reduces intent leakage towards RPC/prover by using cached data when available and verifying afterwards. Allowed values:"none"(default),"basic". With"basic", the verifier sets the PAP flag so that method-type and verification can use cached storage for optimistic execution (e.g. foreth_call); method type may depend on params. This feature is still experimental!new Colibri({ privacy_mode: "basic" }) -
skip_wsp_check- iftrue, the verifier skips the Weak Subjectivity Period (WSP) check for prover-supplied or self-fetched sync committee data, settingVERIFY_FLAG_SKIP_WSP_CHECK(bit1 << 7). The WSP check anchors the highest finalized header against the configuredcheckpointzendpoint whenever a sync crosses the WSP (typically ~2 to 4 months on Ethereum mainnet); for ZK sync data the verifier preferscheckpoint_witness_keys+ matching signatures when available, otherwise falls back tocheckpointz. SECURITY: only enable when another trust anchor (witness signatures, hard-coded checkpoint, signed package) is in place; disabling raises the risk of long-range attacks. Default:false. See the threat model -- long range attacks for background.new Colibri({ skip_wsp_check: true }) -
max_latest_age_seconds- upper bound (in seconds) on the age of a proof whose request uses the"latest"block tag. Without this guard a proof for an oldlatestblock remains cryptographically valid forever and could be replayed as "current" months later. The binding readsDate.now()and forwardsnow - max_latest_age_secondsto the verifier, which rejects stale proofs with"proof for latest too old". Covered RPC methods:eth_call,eth_estimateGas,colibri_simulateTransaction,eth_getBalance,eth_getCode,eth_getStorageAt,eth_getTransactionCount,eth_getProof,eth_getBlockByNumber,eth_getBlockHeader,eth_blobBaseFee,eth_maxPriorityFeePerGas, andeth_blockNumber(implicit-latest).eth_getLogsis not covered yet (tracked in issue #128). Set to0to disable the check (useful for legacy proof formats that do not embed a block context). Default:60(≈ 5 Ethereum slots). The check also applies in PAP mode, where the call proof arrives viacolibri_proofCall(same proof structure as a directeth_call); this requires a prover that embeds the block context (≥ 1.1.15). Account methods rely on a slimtimestampleaf in the state proof that is only emitted by prover ≥ 1.1.27; against older provers the verifier fails closed with"cannot verify freshness of latest block without block context"-- setmax_latest_age_seconds: 0to opt out. Caveat: the gate fires only on"latest"(not"safe"/"finalized"), and if the host wallclock is belowmax_latest_age_seconds(embedded boards before NTP sync, sandboxed environments) the lower bound clamps to0and the check is silently disabled; ensure your runtime has a synced clock or setmax_latest_age_seconds: 0explicitly to acknowledge this state.new Colibri({ max_latest_age_seconds: 30 }) -
oblivious_nodes- TEE RPC endpoints for privateeth_getProof(default: empty). Routeseth_getProofonly to these URLs; setsVERIFY_FLAG_OBLIVIOUSand PAP automatically. For fulleth_callprivacy, combine withprivacy_mode: "basic"andprover_mode: "hybrid":// https://rpc.safe-node.com/ requires an API key for testing new Colibri({ privacy_mode: "basic", prover_mode: "hybrid", oblivious_nodes: ["https://rpc.safe-node.com/"], })Why hybrid: only the block proof is fetched from the prover; account/storage data is loaded from RPC or oblivious node and verified locally (remote mode would download the full call proof from the server). Why PAP: avoids
eth_createAccessListon the prover (intent leakage); storage slots are resolved optimistically in the local EVM so onlyeth_getProofRPCs are exposed externally.How oblivious RPC nodes work (TEE, Oblivious RAM): Oblivious Labs.
-
fetch- custom fetch function for all HTTP requests
Provide a customfetchimplementation to route all network traffic through Tor, a SOCKS proxy, or any other transport layer. The function must match the signature ofglobalThis.fetch. When not set, the standardfetchis used.// Browser: route through Tor via Arti WASM (bootstrap runs in background) import { createBrowserFetch } from '@corpus-core/colibri-tor/browser'; const torFetch = createBrowserFetch(); new Colibri({ fetch: torFetch })// Node.js: route through a locally running Tor SOCKS5 proxy import { createSocksFetch } from '@corpus-core/colibri-tor/node'; const torFetch = await createSocksFetch({ socksPort: 9050 }); new Colibri({ fetch: torFetch }) -
verify- a function to decide which request should be verified and which should be fetched from the default RPC-Provider. It allows you to speed up performance for requests which are not critical.new Colibri({ verify: (method, args) => method != 'eth_blockNumber' }) -
proofStrategy- a strategy function used to determine how to handle proofs. Currently there are 3 default-implementations.Strategy.VerifiedOnly- throws an exception if verifaction fails or a non verifieable function is called.Strategy.VerifyIfPossible- Verifies only verifiable rpc methods and uses the fallbackhandler or rpcs if the method is not verifiable, but throws an exception if verifaction fails.Strategy.WarningWithFallback- Always use the defaultprovider or rpcs to fetch the response and in parallel verifiy the response if possible. If the Verification fails, the warningHandler is called ( which still could throw an exception ). If it fails the response from the rpc-provider is used.
new Colibri({ proofStrategy: Strategy.VerifyIfPossible }) -
warningHandler- a function to be called in case the warning-strategy is used and a verification-error happens. If not set, the default will simply use console.warn to log the error.new Colibri({ warningHandler: (req, error) => console.warn(`Verification Error: ${error}`) }) -
fallback_provider- a EIP 1193 Provider used as fallback for all requests which are not verifieable, like eth_sendTransaction. Also used for signing transactions whenverifyTransactionsis enabled.new Colibri({ fallback_provider: window.ethereum }) -
verifyTransactions- if true, all eth_sendTransaction calls will be verified before broadcast to prevent transaction manipulation attacks. Requiresfallback_providerto be set. (default: false)new Colibri({ fallback_provider: window.ethereum, verifyTransactions: true }) -
chain_configs- optional array of runtime chain registrations forwarded to the C core'sc4_configure_chainentry point.Lets you add L1 / L2 chains that are not baked into the Colibri core at compile time — e.g. a custom Ethereum-fork L1 reusing the same stack as mainnet, or a private OP / Arbitrum / EEZ rollup. Each entry needs a
chain_typeselector (one of the canonical strings"ethereum","op","eez","arbitrum", or the numericC4_CHAIN_TYPE_*constant) plus the fields required by the corresponding handler.Registration happens lazily on the first request (
rpc(),createProof(),verifyProof(),getMethodSupport()) and is deduplicated across everyC4Clientinstance that lives in the same process — the C core rejects a re-registration of the samechain_id, so client-side deduplication avoids a spurious "chain_id is already registered" error when you construct multiple clients with the same config.The per-handler payload schema is documented centrally under Registering chain configs at runtime; the TypeScript shape is
ChainRegistrationinsrc/types.ts.Ethereum-fork L1 (custom chain):
new Colibri({ chainId: 42, rpcs: ["https://rpc.my-chain.net"], beacon_apis: ["https://beacon.my-chain.net"], chain_configs: [{ chain_type: "ethereum", chain_id: 42, genesis_validators_root: "0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95", fork_epochs: [0, 0, 0, 0, 0, 0, 1536], fork_versions: [ "0x00000000", "0x01000000", "0x02000000", "0x03000000", "0x04000000", "0x05000000", "0x06000000", "0x07000000" ] }] })Private OP rollup:
new Colibri({ chainId: 42069, rpcs: ["https://rpc.my-op-rollup.net"], chain_configs: [{ chain_type: "op", chain_id: 42069, sequencer_address: "0x1234567890abcdef1234567890abcdef12345678" }] })Custom EEZ rollup:
new Colibri({ chainId: 7777, rpcs: ["https://rpc.my-eez.net"], chain_configs: [{ chain_type: "eez", chain_id: 7777, rollup_id: 1, proxy: "0x1234567890abcdef1234567890abcdef12345678" }] })Additional Arbitrum rollup:
new Colibri({ chainId: 888001, rpcs: ["https://rpc.my-arb.net"], chain_configs: [{ chain_type: "arbitrum", chain_id: 888001, sequencer_inbox: "0x1234567890abcdef1234567890abcdef12345678" }] })Multiple registrations (e.g. for an L2 plus its custom L1) are supported by passing several entries in the array. Built-in chain ids (mainnet, sepolia, Base, Arbitrum One, …) always take precedence and cannot be shadowed through
chain_configs.
Building
In order to build the Javascript bindings from source, you need to have emscripten installed and the EMSDK environment variable pointing to its installation directory.
The Colibri JS-Binding has been tested with Version 4.0.3. Using latest or other versions may result in unexpected issues. For example Version 4.0.7 is not working. So make sure you select the right version when installing!
CMake Presets (Recommended)
This project includes a CMakePresets.json file for easier configuration.
- Set Environment Variable: Ensure the
EMSDKenvironment variable points to your Emscripten SDK directory.export EMSDK=/path/to/your/emsdk - Configure using Preset: Use the
wasmpreset.- In VS Code/Cursor: Select the
[wasm]configure preset via the status bar or command palette (CMake: Select Configure Preset). - On the Command Line:
# Configure (from the project root) cmake --preset wasm -S . # The binary directory (e.g., build/wasm) is defined in the preset
- In VS Code/Cursor: Select the
- Build:
- In VS Code/Cursor: Use the build button or the command palette (
CMake: Build). Make sure the[wasm]build preset is selected. - On the Command Line:
# Build (using the build directory from the preset) cmake --build build/wasm -j
- In VS Code/Cursor: Use the build button or the command palette (
This preset automatically sets -DWASM=true, -DCURL=false, and the correct toolchain file based on your EMSDK variable. You can create custom presets in CMakeUserPresets.json if you need different CMake flags (e.g., -DETH_ACCOUNT=1).
emcmake
If you prefer not to use presets or your environment doesn't support them well:
- Set Environment Variable: Ensure
EMSDKis set and the Emscripten environment is active (e.g., viasource ./emsdk_env.sh). - Configure and Build:
Replacegit clone https://github.com/corpus-core/colibri-stateless.git && cd colibri-stateless mkdir build/wasm-manual && cd build/wasm-manual # Use a dedicated build dir # Ensure EMSDK is set correctly before running emcmake emcmake cmake -DWASM=true -DCURL=false <other_flags> ../.. make -j<other_flags>with any additional CMake options you need (like-DETH_ACCOUNT=1).
After a successful build (using either method), the JS/WASM module will be in the configured build directory's emscripten subfolder (e.g., build/wasm/emscripten).