> ## 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.

# Data decoding

> Use generated typegen modules to decode EVM and Substrate data.

Decoding events:

```typescript theme={"system"}
import {run} from '@subsquid/batch-processor'
import * as depositsAbi from './abi/deposits'

run(dataSource, new TypeormDatabase(), async (ctx) => {
  for (let c of ctx.blocks) {
    for (let log of c.logs) {
      if (log.address === CONTRACT_ADDRESS &&
          log.topics[0] == depositsAbi.events.Deposit.topic) {

        // type-safe decoding of the Deposit event data
        const amt = depositsAbi.events.Deposit.decode(log).wad
      }
    }
  }
})
```

Similar to `events`, transaction access is provided by the `functions` object for each contract method defined in the ABI.

Generated event objects also expose `is(log)`, `topicSelection(indexedArgs)`, and the `topic` constant. `topicSelection()` returns a `topic0` through `topic3` filter object that can be used as the `where` option of `addLog()`:

```typescript theme={"system"}
source.addLog({
  where: depositsAbi.events.Deposit.topicSelection({owner: [OWNER]}),
})
```

Generated function objects expose `sighash`, `is(transaction)`, `encode(args)`, `decode(input)`, and `decodeResult(output)`. Overloaded ABI names receive a signature-based suffix so every generated export remains unique.
