1. Install the package
You can also usenpm install @oaknetwork/contracts-sdkoryarn add @oaknetwork/contracts-sdk.
2. Create a client
createOakContractsClient sets up a viem PublicClient for reads and a WalletClient for writes. Pass a contract address to any entity factory to start interacting with it.
3. Read from a contract
index.ts) and run it:
4. Write to a contract
Write methods return a transaction hash (Hex). Use oak.waitForReceipt() to wait for confirmation.
5. Create a campaign
6. Handle errors
Contract reverts can be decoded into typed errors with recovery hints:For the full error reference, see Error Handling.
7. Using a Privy wallet
If your app uses Privy for authentication and embedded wallets, wire Privy’s EIP-1193 provider into viem with thecustom transport, then pass chain, provider, and signer to createOakContractsClient—Pattern 5 (full configuration) in Client Configuration.
The example below uses the useWallets hook from @privy-io/react-auth to pick a wallet; swap in whatever selection logic your app uses.
Unsupported chainsIf Privy does not include your chain in its default networks, register it in the Privy provider. See Configuring EVM networks in the Privy documentation.
For per-entity and per-call signers, browser wallets, and the full list of patterns, see Client Configuration.
What to read next
- Client Configuration — all setup patterns, per-entity and per-call signers, resolution order, and browser wallets
- GlobalParams — protocol-wide configuration reads and writes
- CampaignInfoFactory — deploying new campaigns
- Error Handling — typed error decoding and recovery hints
- Utilities — hashing, encoding, time helpers, and constants