# Read a revenue token from a script

Everything a token's page shows can be read from the tokenizer and the token, at one block if you like. This walkthrough reads a token's record, its terms, its income books, its doors, its streams and what one wallet can claim.

## In the app

The token's page, `https://hookr.fun/revenue/<address>`, shows the same: its streams and when each ends, its income, the release period, and a connected wallet's income and drops to claim.

## The reads

| What | Read |
| --- | --- |
| The record: who made it, its launch door, its market's family and when it was made | `tokenizations(token)` on the tokenizer |
| Each stream: its kind, its door, Hookr's leg, when it was added and how it ends | `streamCount(token)`, then `streams(token, start, count)` on the tokenizer |
| The terms fixed at the mint | `totalSupply()`, `streamSeconds()`, `tipBps()`, `bridge()` and `bridgeBps()` on the token |
| Who can add streams | `streamManager()`, zero once the list is closed, and `openStreams()` |
| The supply that earns | `earningSupply()` |
| Each asset's books | `assetAt(i)` for `i` below `assetCount()`: `received`, `paid`, `pendingStream` and `streamEnd` |
| What a release now would move | `releasable(i)` |
| What a wallet can claim | `claimable(wallet, i)` |
| The doors | `doorCount()`, then `doors(start, count)`: kind, contract, gas stipend and Hookr's leg |

`pendingStream` is income recognized but not yet released, and `streamEnd` the time by which all of it will have been released. The state view on [Contracts](/docs/revenue-tokenizer/contracts) answers most of this in one call: `tokenState(token)`, `streamsPage(token, start, count)` and `holderState(token, holder)`.

## In code

With [`client.ts` and `abis.ts`](/docs/revenue-tokenizer/walkthrough-setup):

```ts
import { erc20Abi, formatUnits, zeroAddress, type Address } from "viem";
import { client, TOKENIZER } from "./client";
import { tokenAbi, tokenizerAbi } from "./abis";

const WALLET: Address = "0x…"; // whose income to read

// The newest revenue token the tokenizer made; tokenAt(i) never changes.
const count = await client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "tokenCount" });
const token = await client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "tokenAt", args: [count - 1n] });
const t = { address: token, abi: tokenAbi } as const;

const [record, streamCount, symbol, supply, earning, period, tipBps, manager, assetCount, doorCount] = await Promise.all([
  client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "tokenizations", args: [token] }),
  client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "streamCount", args: [token] }),
  client.readContract({ ...t, functionName: "symbol" }),
  client.readContract({ ...t, functionName: "totalSupply" }),
  client.readContract({ ...t, functionName: "earningSupply" }),
  client.readContract({ ...t, functionName: "streamSeconds" }),
  client.readContract({ ...t, functionName: "tipBps" }),
  client.readContract({ ...t, functionName: "streamManager" }),
  client.readContract({ ...t, functionName: "assetCount" }),
  client.readContract({ ...t, functionName: "doorCount" }),
]);
console.log(`${symbol}: made by ${record.creator}, supply ${formatUnits(supply, 18)}, earning ${formatUnits(earning, 18)}`);
console.log(`release period ${period / 86_400} day(s), tip ${tipBps / 100}%, stream manager ${manager === zeroAddress ? "none" : manager}`);

// The income books, one asset at a time: asset 0 is ETH.
for (let i = 0n; i < assetCount; i++) {
  const asset = await client.readContract({ ...t, functionName: "assetAt", args: [i] });
  const eth = asset.currency === zeroAddress;
  const [name, decimals] = eth
    ? (["ETH", 18] as const)
    : await Promise.all([
        client.readContract({ address: asset.currency, abi: erc20Abi, functionName: "symbol" }),
        client.readContract({ address: asset.currency, abi: erc20Abi, functionName: "decimals" }),
      ]);
  const [releasable, claimable] = await Promise.all([
    client.readContract({ ...t, functionName: "releasable", args: [i] }),
    client.readContract({ ...t, functionName: "claimable", args: [WALLET, i] }),
  ]);
  console.log(
    `${name}: received ${formatUnits(asset.received, decimals)}, paid ${formatUnits(asset.paid, decimals)},`,
    `releasing ${formatUnits(asset.pendingStream, decimals)} until ${new Date(Number(asset.streamEnd) * 1000).toISOString()},`,
    `releasable now ${formatUnits(releasable, decimals)}, the wallet can claim ${formatUnits(claimable, decimals)}`,
  );
}

// The doors, each fixed once added, and the streams, their ends read live. Both lists only grow: read them a page at a time.
const KIND = ["Core door", "launch door", "fee NFT door", "v4 position door", "outside door", "v3 position door", "revenue token door"];
const doors = await client.readContract({ ...t, functionName: "doors", args: [0n, doorCount] });
doors.forEach((door, i) => console.log(`door ${i}: ${KIND[door.kind]}, gas stipend ${door.gas}, Hookr's leg ${door.legBps / 100}%`));
const streams = await client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "streams", args: [token, 0n, streamCount] });
console.log(streams.map((s) => ({ kind: s.kind, door: s.door, legBps: s.legBps, endKind: s.endKind, end: s.end })));
```

The ETH line changes with every sync and claim, and a token can take more streams after the mint, so read the counts again rather than keep them.

For many tokens at once, batch the reads with `client.multicall`: viem's `robinhood` chain carries Multicall3's address.

---

This page: https://hookr.fun/docs/revenue-tokenizer/walkthrough-read. Every docs page as Markdown: https://hookr.fun/docs.md.
