hoodkit
    Preparing search index...

    Interface Batcher

    A DataLoader-style multicall batcher. Reads enqueued within the same tick are coalesced into one Multicall3 call automatically — code paths that don't know about each other still share a round-trip. Ideal behind an HTTP handler where many independent reads fire per request.

    const batch = createBatcher(hood)
    // These three run as ONE multicall even though they're separate awaits:
    const [a, b, c] = await Promise.all([
    batch.call({ address: t1, abi: erc20Abi, functionName: 'balanceOf', args: [me] }),
    batch.call({ address: t2, abi: erc20Abi, functionName: 'balanceOf', args: [me] }),
    batch.call({ address: t3, abi: erc20Abi, functionName: 'balanceOf', args: [me] }),
    ])
    interface Batcher {
        pending: number;
        call<T = unknown>(read: ContractRead): Promise<T>;
        callSafe<T = unknown>(read: ContractRead): Promise<BatchResult<T>>;
        flush(): Promise<void>;
    }
    Index
    pending: number

    Number of reads waiting for the next flush.

    • Force-flush the current queue immediately (rarely needed — flush is automatic).

      Returns Promise<void>