SDK Reference: Solana Log Trigger

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

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.

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.

FieldTypeDescription
NamestringA name you choose to identify this trigger registration.
Address[]byteThe 32-byte program public key to watch. Generated bindings set this from the IDL.
EventNamestringThe Anchor event name to match, e.g. "PriceUpdated".
ContractIdlJson[]byteThe program's Anchor IDL, used to decode subkey field paths. Generated bindings embed this.
Subkeys[]*solana.SubkeyConfigOptional filters on the event's top-level scalar fields.
CpiFilterConfig*solana.CPIFilterConfigOptional. Set when the event is emitted via Anchor's emit_cpi! instead of emit!.

solana.SubkeyConfig

One filter condition on a named event field.

FieldTypeDescription
Path[]stringThe field name to filter on (e.g. []string{"Asset"}).
Comparers[]*solana.ValueComparatorValues 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. 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

FieldTypeDescription
Value[]byteThe encoded comparison value. Use bindings.PrepareSubkeyValue() to encode it.
Operatorsolana.ComparisonOperatorOne 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!.

FieldTypeDescription
DestAddress[]byteThe program address the CPI event was emitted to.
MethodName[]byteThe 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.

FieldTypeDescription
CPIboolSet 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.

FieldTypeDescription
ChainIdstringChain identifier.
LogIndexint64Index of the log within the block.
BlockHash[]byte32-byte block hash.
BlockNumberint64Block/slot number.
BlockTimestampuint64Unix timestamp of the block.
Address[]byte32-byte program public key that emitted the event.
EventSig[]byte8-byte Anchor event discriminator.
TxHash[]byte64-byte transaction signature.
Data[]byteRaw (Borsh-encoded, discriminator-prefixed) event data.
SequenceNumint64Sequence number for ordering.
ErrorstringError 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.

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

Generated binding method

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

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:

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

Get the latest Chainlink content straight to your inbox.