Skip to main content
Version: 1.9.0

Function: getMessagesInRange()

getMessagesInRange(source: Chain, opts: { address?: string; endBefore?: string; endBlock?: number | bigint | "finalized" | "latest"; page?: number | bigint; startBlock?: number | bigint; startTime?: number | bigint; topics?: (string | string[] | null)[]; watch?: boolean | AbortSignal; }): AsyncIterableIterator<CCIPRequest<CCIPVersion>>

Defined in: requests.ts:516

Discover and decode CCIP messages within a block/slot/checkpoint range.

This is the range-scanning equivalent of getMessagesInTx. It composes Chain.getLogs and ChainStatic.decodeMessage to yield CCIP requests in discovery order without requiring transaction hashes upfront.

Results are yielded in native log order: (blockNumber, logIndex) ascending for EVM, slot order for Solana. Non-CCIP logs in the range are silently skipped.

Parameters

ParameterTypeDescription
sourceChainSource chain to scan logs from
opts{ address?: string; endBefore?: string; endBlock?: number | bigint | "finalized" | "latest"; page?: number | bigint; startBlock?: number | bigint; startTime?: number | bigint; topics?: (string | string[] | null)[]; watch?: boolean | AbortSignal; }LogFilter options. Key fields: - startBlock / endBlock — block/slot range (endBlock supports 'finalized' and 'latest') - address — onRamp/router address (optional on EVM, required on Solana) - topics — defaults to both CCIP message event names - page — batch size for log pagination
opts.address?stringContract address to filter logs by.
opts.endBefore?stringCursor hint for the exclusive upper end of iteration on chains that support it.
opts.endBlock?number | bigint | "finalized" | "latest"Ending block number (inclusive).
opts.page?number | bigintPage size for pagination.
opts.startBlock?number | bigintStarting block number (inclusive). Required unless startTime is provided; explicit 0 is allowed.
opts.startTime?number | bigintStarting Unix timestamp (inclusive).
opts.topics?(string | string[] | null)[]Topics to filter logs by.
opts.watch?boolean | AbortSignalwatch mode: polls for new logs after fetching since start (required), until endBlock finality tag (e.g. endBlock=finalized polls only finalized logs); can be an AbortSignal to cancel loop

Returns

AsyncIterableIterator<CCIPRequest<CCIPVersion>>

Async iterator of CCIPRequest objects in native log order

Throws

CCIPChainFamilyUnsupportedError if a pre-v1.6 message is found on a non-EVM chain

Throws

CCIPLogsAddressRequiredError on Solana if address is not provided

Examples

EVM — scan a block range for all CCIP messages

TypeScript
const chain = await EVMChain.fromUrl('https://rpc.sepolia.org')
for await (const request of getMessagesInRange(chain, {
startBlock: 1000000,
endBlock: 1001000,
address: '0xOnRampAddress...', // optional on EVM, but recommended for public RPCs
})) {
console.log(`seqNr=${request.message.sequenceNumber} dest=${request.lane.destChainSelector}`)
}

Solana — scan a slot range (address required)

TypeScript
const chain = await SolanaChain.fromUrl('https://api.devnet.solana.com')
for await (const request of getMessagesInRange(chain, {
startBlock: 450000000,
endBlock: 450100000,
address: 'Ccip842gzYHh...', // router program address (required on Solana)
})) {
console.log(`seqNr=${request.message.sequenceNumber}`)
}

See

  • getMessagesInTx - Per-transaction message discovery
  • getMessagesInBatch - Batch discovery by sequence number range