SDK Reference: Solana Log Trigger

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

SolanaClient.logTrigger()

Creates the Solana log trigger instance. Unlike EVM's log trigger, this is the low-level primitive generated binding helpers call internally — you rarely call it directly.

logTrigger(config: SolanaFilterLogTriggerRequestJson): Trigger<SolanaLog, SolanaLog>

SolanaFilterLogTriggerRequestJson

The configuration form 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.

FieldTypeRequiredDescription
namestringYesA name you choose to identify this trigger registration.
addressstringYesBase64-encoded 32-byte program public key to watch. Generated bindings set this from the IDL.
eventNamestringYesThe Anchor event name to match, e.g. "PriceUpdated".
contractIdlJsonstringYesBase64-encoded Anchor IDL, used to decode subkey field paths. Generated bindings embed this.
subkeysSolanaSubkeyConfigJson[]NoOptional filters on the event's top-level scalar fields.
cpiFilterConfigSolanaCPIFilterConfigJsonNoSet when the event is emitted via Anchor's emit_cpi! instead of emit!.

SolanaSubkeyConfigJson

One filter condition on a named event field.

FieldTypeDescription
pathstring[]The field name to filter on (e.g. ["asset"]).
comparersSolanaValueComparatorJson[]Values to compare against. Multiple comparers on one path are OR conditions.

Generated bindings produce one SolanaSubkeyConfigJson per filtered field from an <EventName>Filters object — see the guide. Only top-level scalar fields are auto-filterable: nested objects, arrays, boolean, and 128-bit integers are excluded and require a manually built SolanaSubkeyConfigJson.

SolanaValueComparatorJson

FieldTypeDescription
valuestringBase64-encoded comparison value. Use prepareSubkeyValue() to encode it.
operatorstringOne of the operators below.

operator 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 SolanaSubkeyConfigJson values.

SolanaCPIFilterConfigJson

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

FieldTypeDescription
destAddressstringBase64-encoded program address the CPI event was emitted to.
methodNamestringBase64-encoded CPI method name. Always "anchor:event" for Anchor's emit_cpi! events.

anchorCPILogTriggerConfig(programId: Uint8Array): SolanaCPIFilterConfigJson builds this for you — generated bindings call it automatically when you pass { cpi: true } as the trigger options.

SolanaLogTriggerOptions

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

FieldTypeRequiredDescription
cpibooleanNoSet true if the event is emitted via Anchor's emit_cpi!. Defaults to false (emit!).

SolanaLog

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

FieldTypeDescription
chainIdstringChain identifier.
logIndexbigintIndex of the log within the block.
blockHashUint8Array32-byte block hash.
blockNumberbigintBlock/slot number.
blockTimestampbigintUnix timestamp of the block.
addressUint8Array32-byte program public key that emitted the event.
eventSigUint8Array8-byte Anchor event discriminator.
txHashUint8Array64-byte transaction signature.
dataUint8ArrayRaw (Borsh-encoded, discriminator-prefixed) event data.
sequenceNumbigintSequence number for ordering.
errorstringError message if log processing failed (optional).

SolanaDecodedLog<T>

Wraps a SolanaLog with its decoded event data. Generated logTrigger<EventName>Log methods adapt the raw trigger to this type automatically.

type SolanaDecodedLog<T> = {
  log: SolanaLog
  data: T
}

Generated binding method

For each event in your IDL, cre generate-bindings solana generates a method on the program's class:

logTrigger<EventName>Log(
  filterName: string,
  filters?: <EventName>Filters[],
  opts?: SolanaLogTriggerOptions,
): Trigger<SolanaLog, SolanaDecodedLog<EventName>>

<EventName>Filters has one optional field per filterable top-level scalar field on the event (omitted or null means no filter on that field). Passing more than one filter row throws — 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:

;(runtime: Runtime<Config>, payload: SolanaDecodedLog<EventType>) => YourReturnType

Parameters:

  • runtime: The runtime object, typed with your workflow's config.
  • 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.