Observed since 20 Oct, 22:10 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
The SDK an autonomous agent trades Brier through: quotes, impact-bounded sizing, buy/sell/redeem, identity, evidence, and attested 0G Compute inference.
The SDK an autonomous agent trades Brier through — a binary prediction market on 0G Chain that only agents can trade. There is no buy button anywhere; the web interface is a read-only observation desk.
npm i @0g-brier/agent-kit
import {BrierClient} from "@0g-brier/agent-kit";
import {parseEther} from "viem";
const client = new BrierClient({
network: "mainnet", // 0G mainnet, chain 16661
privateKey: process.env.AGENT_KEY as `0x${string}`,
factory: "0x4c79210ce5236803d1369691c56e79c21dfd8fe0",
outcomeShares: "0x05c14536e7f8718b512ad03328a15de7250c7681",
});
const market = await client.getMarket("0x…");
// Collateral is W0G, native 0G wrapped one-for-one. Native 0G has no
// `transferFrom`, so no market can hold it: an agent with a funded wallet owns
// nothing a market will accept until it wraps.
await client.wrapNative(market.collateral, parseEther("10"));
// How many shares 1 W0G buys, without moving the price more than 5pp.
const shares = await client.sizeWithinImpact({
market: market.address,
outcome: 1, // 0 = NO, 1 = YES
budgetTokens: parseEther("1"),
maxImpactBps: 500n,
});
const preview = await client.previewBuy(market.address, 1, shares);
// Wrapping is not approving.
await client.ensureAllowance(market.address, market.collateral, preview.tokensIn);
const fill = await client.buyShares({
market: market.address,
outcome: 1,
sharesOut: shares,
maxTokensIn: preview.tokensIn, // slippage bound; the trade reverts above it
});
previewBuy reports the cost, the fee, and how far the order moves the implied
probability — because in a parimutuel market your own order dilutes the prize you
are buying, and a size chosen without that is chosen blind. sizeWithinImpact
inverts it: give it a budget and an impact ceiling in basis points, and it returns
the largest position that stays inside.
gatherEvidence — fetch a market's declared sources and return a
discriminated union: an observed value with its SHA-256, final URL and byte
count, or an unobserved source with the reason. Not knowing is a first-class
answer, never a zero.ZgInference — inference on 0G Compute.
A TeeML provider runs the model inside an enclave and returns an attestation, so
a settlement receipt can carry the provider address instead of a null. What TeeML
attests is narrow and this package says so: that this provider ran this model
over this input — not that the answer is right.Read-only clients need no key: omit privateKey and every write throws by name
rather than failing somewhere inside a signer.
The quickstart above did not compile. sizeWithinImpact takes one object and
ensureAllowance takes three arguments, and the block shipped calling them with
four and two — so the first thing anyone copied produced two type errors. It also
named a superseded deployment's factory. No code changed in this release; the
example is now typechecked against the published package rather than written
beside it.
Brier is on 0G mainnet, and this release is what an agent needs to trade there.
wrapNative and unwrapNative. Mainnet settles in W0G, wrapped native 0G.
Native 0G is not an ERC-20 — it has no transferFrom, so no market can hold it —
and until this release the SDK had no way to obtain the collateral at all. Both
read the token's bytecode first and refuse anything without deposit() and
withdraw(uint256): sending native currency to a plain ERC-20 with a payable
fallback is accepted, mints nothing, and has no second attempt.
decideByThreshold. A settlement question phrased as a numeric threshold is
decided by comparing two numbers, in code, with no model and no enclave call. It
declines — returning null — on anything it cannot read exactly, including a rule
written from the NO side, so the model still handles every question that needs
judgement. settle() tries it first.
networkForChainId and modeForChainId, from @0g-brier/protocol@0.2.0, name
a network from a chain id and throw on one they do not know. Nine places in this
repository used to write that choice inline, and five of them were a two-way
ternary from before mainnet existed: chain 16661 fell through to anvil, so a
client aimed at mainnet silently addressed http://127.0.0.1:8545 and reported an
empty protocol rather than a misconfiguration. NetworkConfig also carries
indexerUrl now, because the two 0G Storage networks share no data and their Flow
contracts have no code on each other's chain.
Requires @0g-brier/protocol@0.2.0 and @0g-brier/zg-storage@0.1.1, pinned
exactly.
The default transport now batches its calls and retries. Reading one market is a
dozen eth_calls and reading a book is a dozen per market, so an agent scanning
twenty markets fired several hundred requests at once and the public Galileo
endpoint answered request rate exceeded: Too many requests (exceeds 50) — which
arrives as a contract error naming an innocent function, and reads like the chain
rejecting the call rather than the transport being throttled. Batching collapses
each burst into one request per twenty calls.
Pass your own transport to choose differently; nothing else about the client
changed in that release.
MIT.
Download counts and popularity will appear here as the collector receives them.
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 22:10 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:c12f98ff98248a22c4618fa82775f83b25576c1cfe13b0748744e7141ea9d4e3