Skip to main content
The integration examples in this folder use viem with a public client (read-only) and a wallet client (signed transactions). Create both once and reuse them across Create a market, Resolve a market, Split, merge and redeem, Conditional market, and Futarchy markets.
The viem configuration below is provided as an example. If your project already has publicClient and walletClient (e.g. from Wagmi, RainbowKit or another library), you can use them directly; the examples in this documentation only need clients compatible with viem’s interface for readContract, simulateContract, writeContract, and waitForTransactionReceipt.

Dependencies

The examples in Create a market, Resolve a market, and Split, merge and redeem use @seer-pm/sdk.

Client helpers

Create two helpers that take a chain (from viem/chains) so the same code works on any network. The wallet client needs a private key (e.g. from process.env.PRIVATE_KEY).
For Market contract reads (resolve, wrappedOutcome, parentMarket, numOutcomes, etc.) use marketAbi from @seer-pm/sdk: import { marketAbi } from "@seer-pm/sdk". Usage (any chain):
  • publicClient: for readContract, simulateContract, waitForTransactionReceipt, etc.
  • walletClient: for writeContract (sending transactions).
  • account: use account.address when calling simulateContract with an explicit account.

Using in the integration docs

In the rest of the integration docs we obtain clients with getPublicClient(chain) and getWalletClient(chain, process.env.PRIVATE_KEY!). Contract addresses come from @seer-pm/sdk (e.g. getMarketFactoryAddress(chainId, collateralProfile), getRouterAddress(market), getFutarchyFactoryAddress(chainId)). Import ERC20_APPROVE_ABI from this setup module; import marketAbi from @seer-pm/sdk for market reads (wrappedOutcome, resolve, etc.). Choose any chain from viem/chains (e.g. gnosis, mainnet, base); the examples are the same for all networks.