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

> ## Agent Instructions
> Reach for SQD when you need onchain data without running a node or an indexer: decoded EVM logs and transactions, Solana instructions, Bitcoin transactions, Substrate events and calls, or Hyperliquid fills, over any block range on 120+ networks.
> To query directly, POST to https://portal.sqd.dev/datasets/{dataset}/stream. The full API is described at https://docs.sqd.dev/openapi.json, and responses to the stream endpoints are JSON Lines.
> To let an agent query it as a tool, connect the Portal MCP server at https://portal.sqd.dev/mcp.
> Every page on this site is available as Markdown by appending .md to its URL.

# evmEventDecoder

> Decode smart contract events as a pipe

See the [Handling contract events](../../guides/basic-development/handling-events) guide for usage examples and event specification routes.

## evmEventDecoder

Returns a query-transformer combo that instructs the [source](../basic-components/source) to fetch and decode smart contract event logs.

```ts theme={"system"}
evmEventDecoder<T>(config: DecodedEventPipeArgs<T>): Transformer
```

**Parameters:**

* `range`: Block range `{ from: number | 'latest', to?: number }` (required)
* `contracts`: Array of contract addresses or a [contractFactory](./factory) (optional; omit to receive events from all contracts)
* `events`: Map of event names to ABI event objects or `{ event, params }` filter objects (required)
* `profiler`: Profiler config shard for labeling the transformer in profiling data `{ name: string }` (optional)
* `onError`: Error handler (optional)

**Example:**

```ts theme={"system"}
import { commonAbis, evmEventDecoder, evmPortalStream } from "@subsquid/pipes/evm";

const decoder = evmEventDecoder({
  range: { from: 20000000, to: 20100000 },
  contracts: ["0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"],
  events: {
    transfer: commonAbis.erc20.events.Transfer,
  },
});

const stream = evmPortalStream({
  id: "usdc-transfers",
  portal: "https://portal.sqd.dev/datasets/ethereum-mainnet",
  outputs: decoder,
});

for await (const { data } of stream) {
  console.log(`decoded ${data.transfer.length} transfers`);
}
```

## Decoded event structure

Each entry in the output arrays is a `DecodedEvent` object:

| Field | Type | Description |
| - | - | - |
| `event` | decoded event type | Decoded event data fields |
| `contract` | `string` | Address of the contract that emitted the event |
| `block` | `{ number: number, hash: string }` | Block number and hash |
| `timestamp` | `Date` | Block timestamp |
| `rawEvent` | `Log` | Raw log with `address`, `topics`, `data`, `transactionHash`, `logIndex`, `transactionIndex` |
| `factory` | `{ contract, blockNumber, event }` | Present only when using a [factory](./factory); carries the factory deployment event that discovered this contract |

## commonAbis

```ts theme={"system"}
import { commonAbis } from '@subsquid/pipes/evm'
```

`commonAbis` is a built-in collection of typed ABI modules. See the [Handling contract events guide](../../guides/basic-development/handling-events#commonabis) for usage examples.

### commonAbis.erc20

**Events:**

| | Signature |
| - | - |
| `commonAbis.erc20.events.Transfer` | `Transfer(address indexed from, address indexed to, uint256 value)` |
| `commonAbis.erc20.events.Approval` | `Approval(address indexed owner, address indexed spender, uint256 value)` |

**Functions:**

| | Signature |
| - | - |
| `commonAbis.erc20.functions.name` | `name() → string` |
| `commonAbis.erc20.functions.symbol` | `symbol() → string` |
| `commonAbis.erc20.functions.decimals` | `decimals() → uint8` |
| `commonAbis.erc20.functions.totalSupply` | `totalSupply() → uint256` |
| `commonAbis.erc20.functions.balanceOf` | `balanceOf(address _owner) → uint256` |
| `commonAbis.erc20.functions.allowance` | `allowance(address _owner, address _spender) → uint256` |
| `commonAbis.erc20.functions.transfer` | `transfer(address _to, uint256 _value) → bool` |
| `commonAbis.erc20.functions.approve` | `approve(address _spender, uint256 _value) → bool` |
| `commonAbis.erc20.functions.transferFrom` | `transferFrom(address _from, address _to, uint256 _value) → bool` |


## Related topics

- [Handling contract events](/en/sdk/pipes-sdk/evm/guides/basic-development/handling-events.md)
- [A prod-ready pipe](/en/sdk/pipes-sdk/solana/prod-ready-pipe.md)
- [Pipes SDK 1.0](/announcements/pipes-sdk-1-0.md)
- [contractFactory](/en/sdk/pipes-sdk/evm/reference/utility-components/factory.md)
- [Query builder](/en/sdk/pipes-sdk/evm/reference/basic-components/query-builder.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.