Dedicated Stacks indexing and real-time subgraphs. Turn onchain events into typed, queryable views of the chain — pick the events your app needs, shape them into tables, query over HTTP or GraphQL.
- Dedicated hosting — each project gets a managed Postgres + API +
subgraph processor. No shared schema, no
api_key_idfiltering, no noisy-neighbor surprises. - Open source — self-host the whole stack with
docker compose up, or use the hosted platform athttps://api.secondlayer.tools. - One surface, three front-ends — CLI, SDK, and MCP server all hit the same API and share the same auth model.
bun add -g @secondlayer/cli
sl login # magic-link email
sl project create my-app
sl project use my-app
sl instance create --plan launch # provisions a dedicated tenant
sl subgraphs deploy ./my-subgraph.tsFull command reference: packages/cli/README.md.
| Package | Description |
|---|---|
@secondlayer/cli |
sl binary — auth, project/instance lifecycle, subgraph deploy, Clarity code-gen |
@secondlayer/sdk |
TypeScript SDK — typed subgraph queries, workflow triggers, webhooks |
@secondlayer/mcp |
MCP server — exposes subgraphs, workflows, scaffolding to AI agents |
@secondlayer/stacks |
viem-style Stacks client — public/wallet, BNS, triggers, AI-SDK tools |
@secondlayer/subgraphs |
defineSubgraph() — declarative schema + event handlers |
@secondlayer/workflows |
defineWorkflow() — durable onchain automation |
@secondlayer/shared |
Shared db, schemas, auth primitives |
@secondlayer/api |
REST API — platform + dedicated + OSS modes |
sl login
sl project use my-app
sl subgraphs deploy ./my-subgraph.ts
sl subgraphs query my-subgraph transfers --sort _block_height --order descimport { SecondLayer } from "@secondlayer/sdk"
const sl = new SecondLayer({
baseUrl: "https://<slug>.secondlayer.tools",
apiKey: process.env.SL_SERVICE_KEY,
})
const { data } = await sl.subgraphs.queryTable("transfers", "events", {
filters: { sender: "SP1234..." },
sort: "_block_height",
order: "desc",
limit: 25,
})curl -H "Authorization: Bearer $SL_SERVICE_KEY" \
"https://<slug>.secondlayer.tools/api/subgraphs/transfers/events?_sort=_block_height&_order=desc&_limit=25"Point Claude Desktop, Cursor, or any MCP client at npx @secondlayer/mcp
with SL_SERVICE_KEY set. See packages/mcp/README.md.
git clone https://github.com/ryanwaits/secondlayer
cd secondlayer
cp docker/.env.example docker/.env # fill in secrets
docker compose -f docker/docker-compose.yml up -dSee docker/oss/README.md for the OSS-mode quickstart and docker/docs/ for operations, backups, and dedicated hosting internals.
bun install
bun run build
bun run typecheck
bun run testReleases flow through Changesets —
bun run version to bump, bun run release to publish.
MIT