Print Events

You don't decode prints: every one is indexed already parsed from Clarity into JSON, with the raw hex kept beside it.

$curl "https://api.secondlayer.tools/v1/index/events?event_type=print&contract_id=SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-registry&order=desc&limit=1" \
-H "Authorization: Bearer sk-sl_…"
200response.jsonjson
{
"events": [
{
"cursor": "9348740:2",
"block_height": 9348740,
"block_time": "2026-10-28T17:42:12.000Z",
"tx_id": "0xfff08aecc097d418f55b98b10abe2bc6b1785b89b0ed1b80506fc15a375a14f9",
"tx_index": 0,
"event_index": 2,
"event_type": "print",
"contract_id": "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-registry",
"payload": {
"topic": "print",
"value": {
"amount": "40477",
"block-height": "973577",
"max-fee": "850",
"recipient": { "hashbytes": "0x98cfcc0a22d16a9ce131dd774ee0245a3b10dcfb", "version": "0x04" },
"request-id": "4636",
"sender": "SPEG24N6F52VPD8001H20TD317GHDD23GGVEZC56",
"topic": "withdrawal-create"
},
"raw_value": "0x0c0000000706616d6f756e74…"
}
}
],
"next_cursor": "desc:9348740:2",
"tip": { "block_height": 9348932, "finalized_height": 9348069, "lag_seconds": 18 },
"reorgs": []
}

The decoded tuple is value: uints are decimal strings, buffers are hex, principals are strings. raw_value is the hex you started from, kept so you can check the decode.

A contract prints different shapes under different topics. The print-schema call lists a contract's topics and each field's Clarity and TypeScript type.

$curl "https://api.secondlayer.tools/v1/index/contracts/SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-registry/print-schema" \
-H "Authorization: Bearer sk-sl_…"
200response.jsonjson
{
"contract_id": "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-registry",
"topics": [
{
"topic": "withdrawal-create",
"count": 29,
"fields": [
{ "name": "amount", "camel_name": "amount", "clarity_type": "uint", "ts_type": "bigint" },
{ "name": "recipient", "camel_name": "recipient", "clarity_type": "(tuple (hashbytes (buff 32)) (version (buff 1)))", "ts_type": "{ hashbytes: string; version: string }" },
]
},
],
"sampled": true
}

Clarity ABIs don't describe prints, so the schema is inferred from indexed prints. camel_name is what a subgraph handler sees on event.data, where a uint is a bigint; REST values are decimal strings.

Field or caseMeans
sampled: trueOlder topics may be missing
optional_some_rateReported on optional fields
"*" topicPrints with no topic string, or that aren't tuples, with non_tuple set
CacheFive minutes (max-age=300, weak ETag); an empty result is not cached

secondlayer subgraphs create <name> --from-contract <contract_id> reads the same schema: Typed print payloads.

The events feed filters by contract, not by topic. Keep the topic you want from the tuple's own topic key.

const withdrawals = page.events.filter(
(event) => (event.payload.value as { topic?: string } | undefined)?.topic === "withdrawal-create",
);

To be pushed one topic instead of reading it, a webhook trigger takes topic: Print fields.

Reading a contract's prints means reading every topic it emits, so a chatty contract costs more rows than the topic you keep. Page with Cursors and Pages. Every filter and the response schema: Decoded events by event_type, Print payload schemas.

Edit on GitHub

Quick Start

Copy this prompt into your agent.

Set up Secondlayer Index in this project. It reads Stacks chain data, decoded, from block 1.

1. Install `@secondlayer/sdk` with the project's package manager. If a release-age policy blocks the install, stop and ask me instead of changing it.
2. Ask me for a Secondlayer API key (`sk-sl_...`, from https://www.secondlayer.tools/signin) and put it in `.env` as `SECONDLAYER_API_KEY`. Never commit it. If I self-host, use `INSTANCE_TOKEN` and my instance URL instead. Until I give you one, read with a free trial key: `curl -X POST https://api.secondlayer.tools/api/public/trial-key` returns `{ key }`, read-only for Streams and Index, good for 24 hours and 100,000 rows. Keep it out of git too.
3. Add a note to `AGENTS.md`, creating it if needed: before using Secondlayer, follow the secondlayer skill if it's installed, and read https://www.secondlayer.tools/llms.txt. Before writing code, read https://www.secondlayer.tools/docs/index.md. Any docs page opens as Markdown when you add `.md` to its URL.
4. If you support skills, run: `bunx skills add ryanwaits/secondlayer --skill secondlayer -y`