Explore subgraphs is live

You shape it.
We run it.

Pick your events, write handlers, deploy — one TypeScript file. Out comes typed Postgres tables and a public REST API, backfilled from genesis and reorg-safe. We host it, or bring your own database.

secondlayer · Subgraphs
stx-transfersv3Subscriptions
GETapi.secondlayer.tools/v1/subgraphs/stx-transfers/<table>API docs →
Tip lag10s
Block sync#8,547,857
Finalized#8,547,632
API p500ms
transfers2.1M rows6 cols
senderrecipientamountmemo_block_height_tx_id
sl — subgraphs
$ sl subgraphs deploy stx-transfers.ts --visibility public
Subgraph "stx-transfers" created → v1
  Read: …/v1/subgraphs/stx-transfers/transfers
  Share: …/v1/subgraphs/stx-transfers (public)
$

Three parts, one file.
Sources, schema, handlers.

The whole subgraph is one TypeScript file. Writes batch and flush atomically per block — on compatible redeploys it reindexes for you (breaking schema changes get a migration plan, never a silent drop).

Read the Subgraphs docs
stx-transfers.ts
export default defineSubgraph({
  name: "stx-transfers",
  sources: {
    transfer: { type: "stx_transfer" },
  },
  schema: {
    transfers: {
      columns: {
        sender: { type: "principal", indexed: true },
        recipient: { type: "principal", indexed: true },
        amount: { type: "uint" },
      },
    },
  },
  handlers: {
    transfer: (event, ctx) => {
      ctx.insert("transfers", {
        sender: event.sender,
        recipient: event.recipient,
        amount: event.amount,
      });
    },
  },
});

Your schema. Our uptime.
Your data, never silently dropped.

One file, one deploy. Hosted or BYO database, full genesis backfill on paid plans.