# SDK Reference: Solana Log Trigger
Source: https://docs.chain.link/cre/reference/sdk/triggers/solana-log-trigger-go
Last Updated: 2026-10-19

> For the complete documentation index, see [llms.txt](/llms.txt).

The Solana Log Trigger fires when a specific event is emitted by an onchain Solana program.

> **NOTE: Recommended usage**
>
> While this section documents the low-level trigger configuration, the recommended best practice is to use the
> **type-safe helper functions** created by the `cre generate-bindings solana` command.
>
> For a complete guide on how to use these helpers, see the [Solana Log Trigger
> Guide](/cre/guides/workflow/using-triggers/solana-log-trigger-go).

### `solana.LogTrigger`

Creates the Solana log trigger instance. Unlike `evm.LogTrigger`, this is the low-level primitive generated binding
helpers call internally — you rarely construct it directly.

```go
import solana "github.com/smartcontractkit/cre-sdk-go/capabilities/blockchain/solana"

func LogTrigger(chainSelector uint64, config *solana.FilterLogTriggerRequest) cre.Trigger[*solana.Log, *solana.Log]
```

### `solana.FilterLogTriggerRequest`

The configuration struct for the Solana log trigger. Unlike the EVM log trigger, which filters on a list of contract
addresses and up to four topics, a Solana log trigger watches a **single program address** and matches events by
name and subkey values.

| Field             | Type                      | Description                                                                                 |
| ----------------- | ------------------------- | ------------------------------------------------------------------------------------------- |
| `Name`            | `string`                  | A name you choose to identify this trigger registration.                                    |
| `Address`         | `[]byte`                  | The 32-byte program public key to watch. Generated bindings set this from the IDL.          |
| `EventName`       | `string`                  | The Anchor event name to match, e.g. `"PriceUpdated"`.                                      |
| `ContractIdlJson` | `[]byte`                  | The program's Anchor IDL, used to decode subkey field paths. Generated bindings embed this. |
| `Subkeys`         | `[]*solana.SubkeyConfig`  | Optional filters on the event's top-level scalar fields.                                    |
| `CpiFilterConfig` | `*solana.CPIFilterConfig` | Optional. Set when the event is emitted via Anchor's `emit_cpi!` instead of `emit!`.        |

### `solana.SubkeyConfig`

One filter condition on a named event field.

| Field       | Type                        | Description                                                                  |
| ----------- | --------------------------- | ---------------------------------------------------------------------------- |
| `Path`      | `[]string`                  | The field name to filter on (e.g. `[]string{"Asset"}`).                      |
| `Comparers` | `[]*solana.ValueComparator` | Values to compare against. Multiple comparers on one path are OR conditions. |

Generated bindings produce one `SubkeyConfig` per filtered field from an `<EventName>Filters` struct — see the
[guide](/cre/guides/workflow/using-triggers/solana-log-trigger-go). Only top-level scalar
fields are auto-filterable: nested structs, vecs, arrays, `bool`, `u128`, and `i128` are excluded and require a
manually built `SubkeyConfig`.

### `solana.ValueComparator`

| Field      | Type                        | Description                                                                     |
| ---------- | --------------------------- | ------------------------------------------------------------------------------- |
| `Value`    | `[]byte`                    | The encoded comparison value. Use `bindings.PrepareSubkeyValue()` to encode it. |
| `Operator` | `solana.ComparisonOperator` | One of the operators below.                                                     |

**`ComparisonOperator` values:** `COMPARISON_OPERATOR_EQ`, `COMPARISON_OPERATOR_NEQ`, `COMPARISON_OPERATOR_GT`,
`COMPARISON_OPERATOR_LT`, `COMPARISON_OPERATOR_GTE`, `COMPARISON_OPERATOR_LTE`. Generated binding filters always use
`COMPARISON_OPERATOR_EQ`; the other operators are available for manually built `SubkeyConfig` values.

### `solana.CPIFilterConfig`

Identifies a cross-program-invoked event for programs that emit events via Anchor's `emit_cpi!` instead of `emit!`.

| Field         | Type     | Description                                                                   |
| ------------- | -------- | ----------------------------------------------------------------------------- |
| `DestAddress` | `[]byte` | The program address the CPI event was emitted to.                             |
| `MethodName`  | `[]byte` | The CPI method name. Always `"anchor:event"` for Anchor's `emit_cpi!` events. |

`bindings.AnchorCPILogTriggerConfig(programID []byte) *solana.CPIFilterConfig` builds this for you — generated
bindings call it automatically when you pass `&bindings.LogTriggerOptions{CPI: true}`.

### `bindings.LogTriggerOptions`

Passed as the last argument to a generated `LogTrigger<EventName>Log` method.

| Field | Type   | Description                                                                                 |
| ----- | ------ | ------------------------------------------------------------------------------------------- |
| `CPI` | `bool` | Set `true` if the event is emitted via Anchor's `emit_cpi!`. Defaults to `false` (`emit!`). |

### `solana.Log`

The payload passed to the callback function for a matching Solana log.

| Field            | Type     | Description                                             |
| ---------------- | -------- | ------------------------------------------------------- |
| `ChainId`        | `string` | Chain identifier.                                       |
| `LogIndex`       | `int64`  | Index of the log within the block.                      |
| `BlockHash`      | `[]byte` | 32-byte block hash.                                     |
| `BlockNumber`    | `int64`  | Block/slot number.                                      |
| `BlockTimestamp` | `uint64` | Unix timestamp of the block.                            |
| `Address`        | `[]byte` | 32-byte program public key that emitted the event.      |
| `EventSig`       | `[]byte` | 8-byte Anchor event discriminator.                      |
| `TxHash`         | `[]byte` | 64-byte transaction signature.                          |
| `Data`           | `[]byte` | Raw (Borsh-encoded, discriminator-prefixed) event data. |
| `SequenceNum`    | `int64`  | Sequence number for ordering.                           |
| `Error`          | `string` | Error message if log processing failed (optional).      |

### `bindings.DecodedLog[T]`

Wraps a `*solana.Log` with its decoded event data. Generated `LogTrigger<EventName>Log` methods adapt the raw trigger
to this type automatically.

```go
type DecodedLog[T any] struct {
    *solana.Log
    Data T
}
```

### Generated binding method

For each event in your IDL, `cre generate-bindings solana` generates:

```go
func (c *Pkg) LogTrigger<EventName>Log(
    chainSelector uint64,
    filterName string,
    filters []<EventName>Filters,
    opts *bindings.LogTriggerOptions,
) (cre.Trigger[*solana.Log, *bindings.DecodedLog[<EventName>]], error)
```

`<EventName>Filters` has one pointer field per filterable top-level scalar field on the event (`nil` means no filter
on that field). Passing more than one filter row returns an error — only a single row (an AND of its set fields) is
currently supported.

### Callback function

Your callback function for Solana log triggers must conform to this signature:

```go
func onSolanaTrigger(config *Config, runtime cre.Runtime, payload *bindings.DecodedLog[EventType]) (*YourReturnType, error)
```

**Parameters:**

- `config`: Your workflow's static configuration struct.
- `runtime`: The runtime object.
- `payload`: The decoded event data (`payload.Data`) alongside the raw log metadata (`payload.Log`).

## Learn more

- **[Solana Log Trigger Guide](/cre/guides/workflow/using-triggers/solana-log-trigger-go)**: Step-by-step guide to configuring and using the Solana Log trigger
- **[The Trigger Capability](/cre/capabilities/triggers)**: Conceptual overview of all CRE trigger types