Transfers

Every FT, NFT and STX transfer on Stacks, decoded, by address or asset, from block 1.

Each read is one filtered call. Paging works the same on every list: Cursors and Pages.

A transfer has a sender and a recipient, so you read each side with its own call. Here is the received side.

$curl "$SECONDLAYER_API_URL/v1/index/ft-transfers?recipient=SP3F3GBGAR8781BF831JT4W7J5DR12ZB15A575DEC&limit=1" \
-H "Authorization: Bearer sk-sl_…"
200response.jsonjson
{
"events": [
{
"cursor": "9331956:4",
"block_height": 9331956,
"block_time": "2026-10-27T04:25:47.000Z",
"tx_id": "0xf230dcb1f4550142d72e6b07e5f2769c8e533c857d26b1c7dac9a62d6c252804",
"tx_index": 2,
"event_index": 4,
"event_type": "ft_transfer",
"contract_id": "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token",
"asset_identifier": "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token::sbtc-token",
"sender": "SM1793C4R5PZ4NS4VQ4WMP7SKKYVH8JZEWSZ9HCCR.xyk-pool-sbtc-stx-v-1-1",
"recipient": "SP3F3GBGAR8781BF831JT4W7J5DR12ZB15A575DEC",
"amount": "152"
}
],
"next_cursor": "9331956:4",
"tip": { "block_height": 9348864, "finalized_height": 9348069, "lag_seconds": 23 },
"reorgs": []
}

There is no single address filter, so make one call per side and merge by block_height. A transfer to yourself is in both: drop repeats by cursor. amount is a string in the token's smallest unit.

const [received, sent] = await Promise.all([
index.ftTransfers.list({ recipient: address }),
index.ftTransfers.list({ sender: address }),
]);
Narrow byParam
One tokencontractId or assetIdentifier
A block rangefromHeight, toHeight
Newest firstorder: "desc"

Filter by the collection's contract. Each row names the token, its sender and its recipient.

const page = await index.nftTransfers.list({
contractId: "SP2N959SER36FZ5QT1CX9BR63W3E8X35WQCMBYYWC.leo-cats",
order: "desc",
limit: 1,
});
200response.jsonjson
{
"events": [
{
"cursor": "9346444:0",
"block_height": 9346444,
"block_time": "2026-10-28T12:06:24.000Z",
"tx_id": "0xdbe15200c985136b4a673d52e6eb72f0f0fdf1904548820a471c9a8b1287db4f",
"tx_index": 0,
"event_index": 0,
"event_type": "nft_transfer",
"contract_id": "SP2N959SER36FZ5QT1CX9BR63W3E8X35WQCMBYYWC.leo-cats",
"asset_identifier": "SP2N959SER36FZ5QT1CX9BR63W3E8X35WQCMBYYWC.leo-cats::leo-cats",
"sender": "SP3Z7511VWR5WG9J3MAKER3NRZYKWT83K2XTP36EV",
"recipient": "SPV9K21TBFAK4KNRJXF5DFP8N7W46G4V9RCJDC22.leo-nft-market-faktory",
"value": "0x01000000000000000000000000000007ec"
}
],
"next_cursor": "desc:9346444:0",
"tip": { "block_height": 9348996, "finalized_height": 9348069, "lag_seconds": 24 },
"reorgs": []
}

value is the token id as a serialized Clarity value in hex. Decode it with @secondlayer/stacks; this row is token 2028.

import { cvToValue, deserializeCV } from "@secondlayer/stacks/clarity";
const tokenId = cvToValue(deserializeCV("0x01000000000000000000000000000007ec")); // 2028n
Narrow byParam
One collectioncontractId
One NFT type in a contractassetIdentifier, needed when a contract defines several
Who sent it, who received itsender, recipient
  • There is no token id filter: decode value after the read to follow one token.
  • Mints and burns are separate event types, not transfers.

Native STX moves are their own event type, read the same way.

const page = await index.events.list({
eventType: "stx_transfer",
fromHeight: 9340000,
});

A read with no fromHeight or cursor covers only the last 17,280 blocks. Pass fromHeight: 0 for all of history, or keep your own copy with a checkpointed consumer. Request fields to trim each row: List FT transfers, List NFT transfers.

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`