Skip to main content

LogsSubscription

subscribe('logs')

Subscribes to incoming logs, filtered by the given options. If a valid numerical fromBlock options property is set, web3.js will retrieve logs beginning from this point, backfilling the response as necessary.

You can subscribe to logs matching a given filter object, which can take the following parameters:

  • fromBlock: (optional, default: 'latest') Integer block number, or 'latest' for the last mined block or 'pending', 'earliest' for not yet mined transactions.
  • address: (optional) Contract address or a list of addresses from which logs should originate.
  • topics: (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with or options.

Hierarchy

Index

Constructors

constructor

Properties

readonlyargs

args: { address?: string | string[]; fromBlock?: BlockNumberOrTag; topics?: string[] }

Type declaration

  • optionalreadonlyaddress?: string | string[]
  • optionalreadonlyfromBlock?: BlockNumberOrTag
  • optionalreadonlytopics?: string[]

Accessors

id

  • get id(): undefined | string
  • Returns undefined | string

lastBlock

  • Returns undefined | BlockOutput

Methods

_processSubscriptionError

  • _processSubscriptionError(error: Error): void
  • Parameters

    • error: Error

    Returns void

_processSubscriptionResult

  • _processSubscriptionResult(data: unknown): void
  • Parameters

    • data: unknown

    Returns void

emit

  • emit<K>(eventName: K, params: { data: LogsOutput } & CommonSubscriptionEvents[K]): void
  • Type parameters

    Parameters

    • eventName: K
    • params: { data: LogsOutput } & CommonSubscriptionEvents[K]

    Returns void

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

getMaxListeners

  • getMaxListeners(): number
  • Returns number

listenerCount

  • listenerCount<K>(eventName: K): number
  • Type parameters

    Parameters

    • eventName: K

    Returns number

listeners

  • listeners<K>(eventName: K): (...args: any[]) => void[]
  • Type parameters

    Parameters

    • eventName: K

    Returns (...args: any[]) => void[]

off

on

once

processSubscriptionData

removeAllListeners

  • Returns EventEmitter

resubscribe

  • resubscribe(): Promise<void>
  • Returns Promise<void>

sendSubscriptionRequest

  • sendSubscriptionRequest(): Promise<string>
  • Returns Promise<string>

sendUnsubscribeRequest

  • sendUnsubscribeRequest(): Promise<void>
  • Returns Promise<void>

setMaxListenerWarningThreshold

  • setMaxListenerWarningThreshold(maxListenersWarningThreshold: number): void
  • Parameters

    • maxListenersWarningThreshold: number

    Returns void

subscribe

  • subscribe(): Promise<string>
  • Returns Promise<string>

unsubscribe

  • unsubscribe(): Promise<void>
  • Returns Promise<void>