> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sqd.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> Index ink! smart contract events and state on Substrate with the Squid SDK.

# ink! contracts support

<Warning>
  V2 gateway requests require an API key. Set `SQD_API_KEY` in `.env` before running gateway-based examples, or pass `apiKey: process.env.SQD_API_KEY` in `GatewaySettings`.
</Warning>

This section describes additional options available for indexing [ink!-based WASM contracts](https://use.ink), supported by chains with a `Contracts` pallet. At the moment of writing, AlephZero, Shibuya (Astar testnet), Shiden (Kusama parachain) and Astar (Polkadot parachain) are the most popular chains for deploying ink! contracts.

[Generate an ink! indexing squid automatically](../../examples-tutorials/auto-generate-indexer), follow the [WASM squid tutorial](../../examples-tutorials/ink) for a step-by-step instruction or check out the [squid-wasm-template](https://github.com/subsquid-labs/squid-wasm-template) reference project.

## Processor configuration

Request events by the contract address as described on the [`SubstrateBatchProcessor` reference page](../../reference/substrate-processor/data-requests#addcontractscontractemitted), e.g.

```ts theme={"system"}
import * as ss58 from '@subsquid/ss58'
import {toHex} from '@subsquid/util-internal-hex'

const ADDRESS = toHex(ss58.decode('XnrLUQucQvzp5kaaWLG9Q3LbZw5DPwpGn69B5YcywSWVr5w').bytes)

const processor = new SubstrateBatchProcessor()
  .setGateway('https://v2.archive.subsquid.io/network/shibuya-substrate')
  .setRpcEndpoint('https://shibuya.public.blastapi.io')
  .addContractsContractEmitted({
    contractAddress: [ADDRESS],
    extrinsic: true
  })
  .setFields({
    event: {
      phase: true
    }
  })
```

Generate and use the facade classes for decoding ink! smart contract data with the [`squid-ink-typegen`](../../reference/substrate-typegen#ink-contracts) tool. You can also make direct contract state queries using the `Contract` class it generates.


## Related topics

- [ink! contract indexing](/en/sdk/squid-sdk/substrate/examples-tutorials/ink.md)
- [Substrate typegen](/en/sdk/squid-sdk/substrate/reference/substrate-typegen.md)
- [Ink](/en/data/evm/ink-mainnet.md)
- [Ink Sepolia](/en/data/evm/ink-sepolia.md)
- [Automatically generate an indexer](/en/sdk/squid-sdk/substrate/examples-tutorials/auto-generate-indexer.md)
