Skip to content

ryanwaits/secondlayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,812 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Secondlayer

Status

The agent-native data plane for Stacks. Dedicated indexing, real-time subgraphs, and a viem-style chain SDK behind one API — usable from the CLI, SDK, or MCP. Indexed once, free to read.

  • Hosted — managed platform, free during open beta. Reads are public; a key gates writes.
  • Self-host — the whole stack is MIT-licensed. docker compose up runs indexer + API + processor on your own hardware.

Quickstart (hosted)

bun add -g @secondlayer/cli

sl login
sl project create my-app && sl project use my-app

# Index a contract into a typed, queryable Postgres table
sl subgraphs scaffold SP1234ABCD.my-contract -o subgraphs/my-contract.ts
sl subgraphs deploy subgraphs/my-contract.ts --start-block <recent-block>
sl subgraphs query my-contract <table> --sort _block_height --order desc

# Push new rows to a webhook
sl create subscription my-hook --runtime node \
  --subgraph my-contract --table <table> --url https://<host>/webhook

Full walkthrough → QUICKSTART · commands → CLI reference.

Read it from anywhere

Reads are public — no key needed; the SDK defaults to https://api.secondlayer.tools.

import { SecondLayer } from "@secondlayer/sdk";

const sl = new SecondLayer();
const { data } = await sl.subgraphs.queryTable("my-contract", "<table>", {
  sort: "_block_height",
  order: "desc",
  limit: 25,
});
curl "https://api.secondlayer.tools/api/subgraphs/my-contract/<table>?_limit=25"

MCP — point any MCP client at bunx -p @secondlayer/mcp secondlayer-mcp (SECONDLAYER_API_URL=https://api.secondlayer.tools). Set SL_SERVICE_KEY to enable writes (deploy/manage). See MCP README.

Packages

Package Description
@secondlayer/cli sl binary — auth, projects, subgraph deploy, Clarity code-gen
@secondlayer/sdk TypeScript SDK — typed subgraph queries, webhooks
@secondlayer/mcp MCP server — subgraphs + scaffolding for AI agents
@secondlayer/stacks viem-style Stacks client — public/wallet, BNS, AI-SDK tools
@secondlayer/subgraphs defineSubgraph() — declarative schema, triggers + handlers
@secondlayer/shared Shared db, schemas, crypto helpers
@secondlayer/api REST API — hosted + self-host modes

Self-host

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 -d

OSS quickstart · operations & backups in docker/docs/.

Development

bun install && bun run build && bun run test

Releases flow through Changesets: bun run version to bump, bun run release to publish.

License

MIT

About

Agent-native tooling for Stacks L2

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors