Configuration
Dependencies
npm i viemClient helpers
import { createPublicClient, createWalletClient, http } from "viem";
import type { Chain } from "viem";
import { privateKeyToAccount } from "viem/accounts";
export function getPublicClient(chain: Chain) {
return createPublicClient({
chain,
transport: http(),
});
}
export function getWalletClient(chain: Chain, privateKey: `0x${string}`) {
const account = privateKeyToAccount(privateKey);
return createWalletClient({
chain,
transport: http(),
account,
});
}
/** ERC20 `approve(spender, amount)` ABI. Use for collateral and outcome token approvals (split, merge, redeem, swaps). */
export const ERC20_APPROVE_ABI = [
{
inputs: [
{ name: "spender", type: "address" },
{ name: "amount", type: "uint256" },
],
name: "approve",
outputs: [{ type: "bool" }],
stateMutability: "nonpayable",
type: "function",
},
] as const;
/** Market contract ABI: resolve, wrappedOutcome(index), parentMarket, parentOutcome, numOutcomes. Use for resolve and for reading outcome token addresses. numOutcomes() returns the count without INVALID_RESULT; use numOutcomes() + 1 if you need to include it. */
export const MARKET_ABI = [
{
inputs: [],
name: "resolve",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [{ name: "index", type: "uint256" }],
name: "wrappedOutcome",
outputs: [
{ name: "wrapped1155", type: "address" },
{ name: "data", type: "bytes" },
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "parentMarket",
outputs: [{ type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "parentOutcome",
outputs: [{ type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "numOutcomes",
outputs: [{ type: "uint256" }],
stateMutability: "view",
type: "function",
},
] as const;Deployed contracts by chain
Chain ID
Chain
Using in the integration docs
Last updated