<!-- source: https://secondlayer.tools/docs/sdk-reference/contracts -->

# `sl.contracts`

Find contracts that conform to a trait, or get one from the registry by id.

## Methods

### sl.contracts.list(params)

Find contracts conforming to `trait`. `trait` is required (server 400s without it).

REST twin: `GET /v1/contracts`

```ts
sl.contracts.list(params: ContractsListParams): Promise<ContractsEnvelope>
```

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `trait` | `string` | yes | Required. Trait identifier to match (e.g. "sip-010", or a fully-qualified trait). |
| `conformance` | `ContractConformance` | no | Match source. Defaults to "any" server-side. |
| `include` | `"abi"` | no | Set to "abi" to include the full ABI blob in each row. |
| `limit` | `number` | no | Page size, 1–500 (default 100 server-side). |
| `cursor` | `string` | no | Opaque cursor from a prior response's `next_cursor`. |

### sl.contracts.get(contractId, opts)

Get one contract from the registry by id, or `null`.

The prod-safe ABI source. Pass `{ includeAbi: true }` for the full ABI
blob. Resolves to `null` on 404.

```ts
sl.contracts.get(
  contractId: string,
  opts?: { includeAbi?: boolean },
): Promise<ContractSummary | null>
```

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `contractId` | `string` | yes |  |
| `opts.includeAbi` | `boolean` | no |  |

## Types

- `ContractConformance`: Whether a trait match must be declared in source, inferred from ABI, or either.
- `ContractsEnvelope`: One page of contracts and the cursor for the next page.
  - `contracts`: `ContractSummary[]`
  - `next_cursor`: `string \| null`
- `ContractsListParams`: Trait, conformance, and paging for listing contracts.
  - `trait`: `string`. Required. Trait identifier to match (e.g. "sip-010", or a fully-qualified trait).
  - `conformance`?: `ContractConformance`. Match source. Defaults to "any" server-side.
  - `include`?: `"abi"`. Set to "abi" to include the full ABI blob in each row.
  - `limit`?: `number`. Page size, 1–500 (default 100 server-side).
  - `cursor`?: `string`. Opaque cursor from a prior response's `next_cursor`.
- `ContractSummary`: A deployed contract with its traits, standards, and ABI status.
  - `contract_id`: `string`
  - `deployer`: `string`
  - `block_height`: `number`
  - `declared_traits`: `string[] \| null`
  - `inferred_standards`: `string[] \| null`
  - `abi_status`: `string`
  - `abi`?: `unknown`. Present only when `include: "abi"` was requested.

## Notes for agents

- Methods live on 'sl.contracts' of 'const sl = new SecondLayer()'. Signatures and overloads are generated from the SDK source.

## Setup

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