USC SDK
Getting Started with the USC SDK
The @gluwa/usc-sdk is a TypeScript/JavaScript SDK for verifying cross-chain transactions on the Creditcoin network. It lets you generate inclusion proofs for transactions on supported source chains (e.g. Ethereum Sepolia) and verify them on-chain via Creditcoin's precompile contracts.
Installation
npm install @gluwa/usc-sdk
# or
yarn add @gluwa/usc-sdkThe SDK requires ethers.js v6 as a peer dependency.
Core concepts
A transaction inclusion proof answers the question: "Did this transaction really happen on chain X?" It is made of two parts:
Merkle proof
The transaction is included in a specific block's transaction tree
Continuity proof
That block is part of a sequence of blocks anchored to an attestation point on Creditcoin
The SDK provides three main components you will work with:
ProverAPIProofGenerator— fetches pre-computed proofs from a hosted API (recommended starting point)PrecompileChainInfoProvider— queries attestation state from CreditcoinPrecompileBlockProver— submits proofs to Creditcoin's on-chain verifier
Setting up providers
You need two JSON-RPC providers: one for the source chain (where the transaction happened) and one for Creditcoin (where proofs are verified).
Step 1: Query supported chains
Use PrecompileChainInfoProvider to see which source chains are currently supported and find the chainKey for the chain you want to prove transactions from.
The chainKey is a Creditcoin-internal identifier for a source chain — it is not the same as the chain's EVM chainId. You will need it in every subsequent call.
Step 2: Wait for attestation
Before a proof can be generated, the block containing your transaction must be attested on Creditcoin. Attestation happens periodically and automatically; you just need to wait for it.
waitUntilHeightAttested polls Creditcoin at a configurable interval (default: 5 s) and resolves once the target height is confirmed. It will throw after a configurable timeout (default: 60 s).
Step 3: Generate a proof with the Prover
ProverAPIProofGenerator is the simplest way to get a proof. It calls a hosted API that computes and caches proofs on your behalf — no RPC-heavy local computation required.
The returned proofData object contains everything needed for on-chain verification:
chainKey
number
Source chain identifier
headerNumber
number
Block number the transaction was in
txHash
string
Transaction hash
txBytes
string
ABI-encoded transaction
merkleProof
TransactionMerkleProof
Siblings in the block's transaction Merkle tree
continuityProof
ContinuityProof
Chain of Merkle roots linking the block to an attestation
cached
boolean
Whether the proof was served from cache
Batch proof generation
If you need proofs for multiple transactions at once, use generateBatchProof. All transactions in a batch share a single continuity proof, which makes on-chain batch verification more efficient.
Step 4: Verify the proof on-chain
PrecompileBlockProver submits proofs to Creditcoin's verifier precompile.
Single transaction
Batch of transactions
When using batch proofs, you need to flatten the proof data into parallel arrays:
Complete end-to-end example
Alternative: Raw proof generator
For advanced use cases where you need full control (e.g. running your own indexer, offline proof computation, or custom block providers), the SDK also ships a RawProofGenerator that computes proofs locally by fetching data directly from source chain RPCs.
Both RawProofGenerator and ProverAPIProofGenerator implement the same ProofGenerator interface and produce identical output, so you can swap between them without changing any downstream code.
Last updated