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

public_processSubscriptionError

  • _processSubscriptionError(error: Error): void
  • Parameters

    • error: Error

    Returns void

public_processSubscriptionResult

  • _processSubscriptionResult(data: LogsOutput): void
  • Parameters

    Returns void

emit

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

    Parameters

    • eventName: K
    • params: CommonSubscriptionEvents & { data: LogsOutput }[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): Function[]
  • Type parameters

    Parameters

    • eventName: K

    Returns Function[]

off

on

once

removeAllListeners

  • removeAllListeners(): EventEmitter
  • Returns EventEmitter

resubscribe

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

setMaxListenerWarningThreshold

  • setMaxListenerWarningThreshold(maxListenersWarningThreshold: number): void
  • Parameters

    • maxListenersWarningThreshold: number

    Returns void

subscribe

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

unsubscribe

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