You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`chainId`|`number`| Yes| Numeric chain ID (use `CHAIN_IDS.*` constants) |
26
+
|`rpcUrl`|`string`| Yes | RPC endpoint URL for the chain|
27
+
|`privateKey`|`` `0x${string}` ``| Yes | 0x-prefixed private key for the signer|
28
+
|`options`|`Partial<OakContractsClientOptions>`| No | Client-level overrides|
29
29
30
30
## Pattern 2 — Read-only (`chainId` + `rpcUrl`, no `privateKey`)
31
31
32
32
No private key required. All read methods work normally; write and simulate methods throw immediately — no RPC call is made. The error is thrown by `requireSigner()`; the message starts with `No signer configured.` and explains how to pass a client key, full-config signer, or per-entity signer (for example `oak.globalParams(address, { signer })`).
|`chainId`|`number`| Yes| Numeric chain ID (use `CHAIN_IDS.*` constants) |
50
+
|`rpcUrl`|`string`| Yes | RPC endpoint URL for the chain|
51
+
|`options`|`Partial<OakContractsClientOptions>`| No | Client-level overrides|
52
52
53
53
## Pattern 3 — Per-entity signer override
54
54
55
55
Pass a signer when creating an entity. Every write and simulate call on that entity uses the provided signer — you do not pass it again on each call. Use this when the signer is resolved **after** the client is created (browser wallets, Privy, etc.).
const oak =createOakContractsClient({ chain, provider, signer });
147
+
```
148
+
149
+
### Privy wallet with full configuration
150
+
151
+
[Privy](https://www.privy.io/) embedded wallets expose an EIP-1193 provider. Pass that provider to viem's `custom` transport for both `createPublicClient` and `createWalletClient`, then pass `chain`, `provider`, and `signer` into `createOakContractsClient`—the same pattern as [Browser wallet with full configuration](#browser-wallet-with-full-configuration) above.
152
+
153
+
The snippet uses the `useWallets` hook from `@privy-io/react-auth` to pick a wallet; replace that with whatever wallet selection logic your app uses.
154
+
155
+
```typescript
156
+
import {
157
+
createOakContractsClient,
158
+
createPublicClient,
159
+
createWalletClient,
160
+
custom,
161
+
getChainFromId,
162
+
CHAIN_IDS,
163
+
} from'@oaknetwork/contracts-sdk';
164
+
import { useWallets } from'@privy-io/react-auth';
165
+
166
+
const { wallets } =useWallets();
167
+
const wallet =wallets[0]; // or select by address / connector
const oak =createOakContractsClient({ chain, provider, signer });
147
186
```
148
187
188
+
:::info Unsupported chains
189
+
If Privy does not include your chain in its default networks, register it in the Privy provider. See [Configuring EVM networks](https://docs.privy.io/basics/react/advanced/configuring-evm-networks) in the Privy documentation.
190
+
:::
191
+
149
192
## Signer resolution priority
150
193
151
194
When a write or simulate method runs, the signer is resolved in this order:
152
195
153
-
1.**Per-call**`options.signer` — highest priority
154
-
2.**Per-entity**`signer` passed to the entity factory (e.g. `oak.globalParams(addr, { signer })`)
155
-
3.**Client-level**`walletClient` from `createOakContractsClient` (simple or full config with a wallet)
156
-
4.**Throws** an `Error` from `requireSigner()` (message begins with `No signer configured.`) if none of the above is set
196
+
1.**Per-call**`options.signer` — highest priority
197
+
2.**Per-entity**`signer` passed to the entity factory (e.g. `oak.globalParams(addr, { signer })`)
198
+
3.**Client-level**`walletClient` from `createOakContractsClient` (simple or full config with a wallet)
199
+
4.**Throws** an `Error` from `requireSigner()` (message begins with `No signer configured.`) if none of the above is set
0 commit comments