# Events

## Declaration

```text
    event Transfer(from: address, to: address, value: uint256)
    event Mint(to: address, amount: uint256)
```

### Indexed parameters

Mark log topics with the **`indexed`** keyword before a parameter name:

```text
event Transfer(indexed from: address, to: address, indexed value: uint256)

ping() {
    emit Transfer(sender, recipient, amount)
}
```

**CX3JS emit** passes an **`indexed`** array to the runtime for topic selection. The flat CX3JS ABI event list uses **`{ name, type }`** without per-field `indexed` flags. **CX3WASM**'s generated event ABI (`WITGenerator.extractEvents`) also only emits **`{ name, type }`** - `indexed` never surfaces there either; it is available only on the AST during CX3JS emission of runtime topics. Verify behaviour in `test/sprint6-parity-priority.test.js`.

## Emit

```text
    emit Transfer(sender, to, amount)
```

## After a transfer

```text
    transfer(to: address, amount: uint256) {
        require balances[sender] >= amount, "balance"
        balances[sender] = balances[sender] - amount
        balances[to] = balances[to] + amount
        emit Transfer(sender, to, amount)
    }
```

## Next

**Imports**
