<!-- source: https://www.secondlayer.tools/docs/guides -->

# Guides

Build one thing end to end, one small step at a time.

- [Listen for Contract Events](https://www.secondlayer.tools/docs/guides/listen-for-contract-events.md): A signed POST to your server for each print a contract emits, as it lands.
- [Index a Contract into Postgres](https://www.secondlayer.tools/docs/guides/index-contract-into-postgres.md): Define a subgraph, try it on real blocks, deploy it and read the rows.

## Read next

- [Listen for Contract Events](https://www.secondlayer.tools/docs/guides/listen-for-contract-events.md)
- [Index a Contract into Postgres](https://www.secondlayer.tools/docs/guides/index-contract-into-postgres.md)

## Notes for agents

- Guides are end-to-end builds. For one fact (a route, a filter, a field), read the matching page under Docs or the API reference.
- Webhooks: /docs/guides/listen-for-contract-events. Subgraphs: /docs/guides/index-contract-into-postgres.

## Setup

Ensure setup once, skipping any step already done:
- CLI: `bun add -g @secondlayer/cli`
- Instance: `secondlayer init` writes `INSTANCE_TOKEN`. Loopback `/v1` reads need no key.
- Hosted reads: export `SECONDLAYER_API_KEY` (`sk-sl_*`) or buy credits with `secondlayer credits buy` (`balance`, `refill`), then `secondlayer whoami`
