<!-- source: https://www.secondlayer.tools/docs/transfers -->

# 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](https://www.secondlayer.tools/docs/cursors.md).

## FT Transfers by Address

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

```bash
curl "$SECONDLAYER_API_URL/v1/index/ft-transfers?recipient=SP3F3GBGAR8781BF831JT4W7J5DR12ZB15A575DEC&limit=1" \
  -H "Authorization: Bearer sk-sl_…"
```

```ts
import { Index } from "@secondlayer/sdk";

const index = new Index();

const page = await index.ftTransfers.list({
  recipient: "SP3F3GBGAR8781BF831JT4W7J5DR12ZB15A575DEC",
  limit: 1,
});
```

```json response.json status=200
{
  "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.

```ts
const [received, sent] = await Promise.all([
  index.ftTransfers.list({ recipient: address }),
  index.ftTransfers.list({ sender: address }),
]);
```

| Narrow by | Param |
| --- | --- |
| One token | `contractId` or `assetIdentifier` |
| A block range | `fromHeight`, `toHeight` |
| Newest first | `order: "desc"` |

## NFT Transfers for a Collection

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

```ts
const page = await index.nftTransfers.list({
  contractId: "SP2N959SER36FZ5QT1CX9BR63W3E8X35WQCMBYYWC.leo-cats",
  order: "desc",
  limit: 1,
});
```

```json response.json status=200
{
  "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.

```ts
import { cvToValue, deserializeCV } from "@secondlayer/stacks/clarity";

const tokenId = cvToValue(deserializeCV("0x01000000000000000000000000000007ec")); // 2028n
```

| Narrow by | Param |
| --- | --- |
| One collection | `contractId` |
| One NFT type in a contract | `assetIdentifier`, needed when a contract defines several |
| Who sent it, who received it | `sender`, `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.

## STX Transfers

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

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

## Tradeoff

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](https://www.secondlayer.tools/docs/checkpoints.md). Request `fields` to trim each row: [List FT transfers](https://www.secondlayer.tools/docs/api-reference.md#list-ft-transfers), [List NFT transfers](https://www.secondlayer.tools/docs/api-reference.md#list-nft-transfers).

## Read next

- [Cursors and Pages](https://www.secondlayer.tools/docs/cursors.md)
- [Checkpoints](https://www.secondlayer.tools/docs/checkpoints.md)
- [API](https://www.secondlayer.tools/docs/api-reference.md)

## Notes for agents

- Routes: GET /v1/index/ft-transfers, /v1/index/nft-transfers (SDK: sl.index.ftTransfers / nftTransfers .list / .walk), and /v1/index/events?event_type=stx_transfer. Filters: sender, recipient, contract_id, asset_identifier, from_height, to_height, order, fields. No 'address' and no token-id parameter. SDK contractId is one string.
- cursor and from_height are mutually exclusive (400 VALIDATION_ERROR). A cursor only resumes under the order that issued it. null next_cursor means an empty page.
- NFT value is hex Clarity: uint 2028 is 0x01 then 16 bytes. nft_mint and nft_burn are other event types.
- walk() keeps no checkpoint and ignores reorgs: use consume() to keep rows.

## Setup

Ensure setup once, skipping any step already done:
- CLI: `bun add -g @secondlayer/cli`
- Instance: `secondlayer init` writes `INSTANCE_TOKEN`. Loopback `/v1` reads need no key.
- Hosted reads: export `SECONDLAYER_API_KEY` (`sk-sl_*`) or buy credits with `secondlayer credits buy` (`balance`, `refill`), then `secondlayer whoami`
