Contract Calls

Every call to a contract function, with its arguments already parsed from Clarity, from block 1.

$curl "$SECONDLAYER_API_URL/v1/index/contract-calls?contract_id=SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token&function_name=transfer&from_height=9340000&limit=1" \
-H "Authorization: Bearer sk-sl_…"
200response.jsonjson
{
"contract_calls": [
{
"cursor": "9341326:0",
"block_height": 9341326,
"block_time": "2026-10-28T00:52:36.000Z",
"tx_id": "0x385726bb0fe44cac3c127096a28ddd3c5aba20e45e7bb7d09cbba15b9b579d9e",
"tx_index": 0,
"contract_id": "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token",
"function_name": "transfer",
"sender": "SP2X2S5J0DXXRBR786CVVT15SWZT9T6E5D5YYXXF1",
"status": "success",
"args": ["10514538", "SP2X2S5J0DXXRBR786CVVT15SWZT9T6E5D5YYXXF1", "SP1SYS7ZHE8Z05WGJYF7EHXCYCXSJY0FW75MT7M9Z", null],
"result": { "ok": true },
"result_hex": "0x0703"
}
],
"next_cursor": "9341326:0",
"tip": { "block_height": 9348931, "finalized_height": 9348069, "lag_seconds": 18 },
"reorgs": []
}

args holds the arguments in order, one entry per parameter, as plain JSON. Read the names from the contract's ABI: transfer takes the amount, sender, recipient, then an optional memo.

Narrow byParam
One functionfunctionName
Who called itsender
Several contractscontractId as a list (max 20)
Every contract of a standardtrait, instead of contractId
A block rangefromHeight, toHeight
  • There is no status filter: failed calls come back too, so check each row's status.
  • Only calls a transaction makes directly are listed. Calls between contracts are on Contract State.
  • Reads run oldest first; there is no order parameter on this feed.

A read with no fromHeight or cursor covers only the last 17,280 blocks, and a busy function means many rows, so narrow by height before you page (Cursors and Pages). Every filter and the response schema: Decoded contract-call transactions.

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`