Start from a trusted factory
Pin the chain ID and factory address from Contracts. Use factory.curveCount() and factory.curves(i), where i is a zero-based factory-local index. That index is not necessarily the token index used by the website API. For a growing catalog, index TokenCreated events from the factory deployment block, using bounded block ranges and saved checkpoints.
Verify both directions
- Confirm eth_chainId is 4663 and the configured factory has deployed code.
- Resolve the candidate curve through factory.curves(i), or a canonical TokenCreated receipt emitted by that factory.
- Read curve.factory() and require the configured factory address.
- Read curve.token(), then token.curve(), and require the reverse curve binding.
- Read token.decimals() and current curve.graduated(). The supplied V10 example expects 18 decimals. Never infer authenticity from symbol(), name() or a returned website label.
Minimal read-only example
import {JsonRpcProvider, FetchRequest} from 'ethers';
import {inspectCurve} from './littlejohn-v10-example.mjs';
const request = new FetchRequest(process.env.RPC_URL);
request.timeout = 15000;
const rpc = new JsonRpcProvider(request, undefined, {batchMaxCount: 1});
try {
const market = await inspectCurve(rpc, 0n); // factory-local index
console.log(market.tokenAddress, market.curveAddress, market.graduated);
} finally { rpc.destroy(); }Given only a token address
token.curve() can supply a candidate, but an arbitrary token can implement that getter. Resolve the corresponding trusted factory event or factory list entry before accepting it. Cache verified bindings rather than scanning every curve on each quote. The example takes the trusted factory index to avoid pretending the factory has a direct token-to-curve lookup getter.
Failure handling
Reject mismatched bindings, missing code and wrong networks. Retry timeouts with bounded backoff. Do not treat a failed call as evidence that the market graduated or that a token is malicious. Historical reads may require an archive-capable provider; the reference quote flow uses a recent shared block.