Skip to main content

SDK installation

The SealedIP SDK is a TypeScript module that wraps the SealedAuction contract surface and the CDR encryption/decryption flow. Use it instead of raw ABI calls unless you need fine-grained control.

Install

npm install @sealedip/sdk viem

Yarn / pnpm / bun work identically. viem is a peer dependency.

Subpath exports

The SDK ships multiple subpath exports:

SubpathWhat it exports
@sealedip/sdkTop-level re-exports: sealReserve + its types
@sealedip/sdk/constantsDeployed addresses, chain config, gas constants
@sealedip/sdk/abi/sealed-auctionsealedAuctionAbi — viem const ABI
@sealedip/sdk/encryptencryptBid, EncryptBidInput, EncryptedBid
@sealedip/sdk/payloadencodePayload, decodePayload, signBidDigest, BidPayloadFields

High-level helpers live in their own modules:

import {sealReserve} from '@sealedip/sdk' // or from '@sealedip/sdk/seller'
import {placeBid} from '@sealedip/sdk/bidder'
import {settleAuction} from '@sealedip/sdk/orchestrator'
import {getAuction, getBid, getAllBids} from '@sealedip/sdk/auction'

WASM constraint: Node / server only for encrypt + decrypt

encryptBid and decryptBid call into @piplabs/cdr-sdk and @piplabs/cdr-crypto, which load a WASM binary via initWasm(). The WASM glue does not load in browser or edge-runtime bundles.

As a result:

  • encryptBid must run in Node (a Next.js API route, a server action, or a standalone script).
  • decryptBid (and by extension settleAuction) must also run in Node.
  • placeBid calls encryptBid internally, so it is also Node-only.

The SealedIP reference web app handles this by routing bid placement through web/app/api/encrypt-bid/route.ts (a Node API route).

Configure a chain client

client.ts
import {createPublicClient, http} from 'viem'
import {storyAeneid} from 'viem/chains'

export const publicClient = createPublicClient({
chain: storyAeneid,
transport: http('https://aeneid.storyrpc.io'),
})

storyAeneid is in viem/chains (chain id 1315). If your viem version does not include it, define the chain manually:

import {defineChain} from 'viem'

export const storyAeneid = defineChain({
id: 1315,
name: 'Story Aeneid',
nativeCurrency: {name: 'IP', symbol: 'IP', decimals: 18},
rpcUrls: {default: {http: ['https://aeneid.storyrpc.io']}},
blockExplorers: {
default: {name: 'Storyscan', url: 'https://aeneid.storyscan.io'},
},
})

Gas pricing

Aeneid reports a near-zero EIP-1559 base fee. The SDK's write helpers pin gasPrice to 100_000_000_000n (100 gwei) via the GAS_PRICE_WEI constant from @sealedip/sdk/constants. If you are calling contracts directly, apply the same value or your transactions will stall.

TypeScript

The SDK ships types out of the box. Minimum TypeScript: 5.0.

React + wagmi

For browser read access, use the SDK's ABIs with wagmi hooks:

import {useReadContract} from 'wagmi'
import {sealedAuctionAbi} from '@sealedip/sdk/abi/sealed-auction'
import {SEALED_AUCTION_ADDRESS} from '@sealedip/sdk/constants'

function useAuction(id: bigint) {
return useReadContract({
address: SEALED_AUCTION_ADDRESS,
abi: sealedAuctionAbi,
functionName: 'auctions',
args: [id],
})
}

For write operations (place bid, seal reserve), proxy through a Next.js API route to avoid the WASM constraint described above.

Next