Skip to main content

Class: EvmEvent

moralis-monorepo / @moralisweb3/common-evm-utils / EvmEvent

Class: EvmEvent

@moralisweb3/common-evm-utils.EvmEvent

The EvmEvent is a representation of an event.

Use this class any time you work with an event.

Implements

  • MoralisDataObject

Table of contents

Methods

Accessors

Methods

create

Static create(data): EvmEvent

Create a new instance of EvmEvent from any valid event input

Example

const event = EvmEventish.create(data);

Parameters

NameTypeDescription
dataEvmEventishthe EvmEventish type

Returns

EvmEvent


equals

Static equals(dataA, dataB): boolean

Check the equality between two Evm events. It checks if the chain, block number, address and data are equal.

Example

EvmEvent.equals(dataA, dataB)

Parameters

NameTypeDescription
dataAEvmEventishThe first event
dataBEvmEventishThe second event

Returns

boolean

true if the events are equal, false otherwise


parse

Static parse(data): EvmEventData

Parameters

NameType
dataEvmEventInput

Returns

EvmEventData


equals

equals(data): boolean

Checks the equality of the current event instance with another evm event

Example

event.equals(data)

Parameters

NameTypeDescription
dataEvmEventishthe event to compare with

Returns

boolean

true if the events are equal, false otherwise

Implementation of

MoralisDataObject.equals


format

format(): Object

Deprecated

This method will be removed soon. To format the value, use one of the properties.

Returns

Object

NameType
addressstring
blockHashstring
blockNumberstring
blockTimestampDate
chainstring
data{ from: undefined | string ; to: undefined | string ; value: undefined | string }
data.fromundefined | string
data.toundefined | string
data.valueundefined | string
transactionHashstring

Implementation of

MoralisDataObject.format


toJSON

toJSON(): Object

Example

event.toJSON()

Returns

Object

a JSON represention of the event.

NameType
addressstring
blockHashstring
blockNumberstring
blockTimestampDate
chainstring
data{ from: undefined | string ; to: undefined | string ; value: undefined | string }
data.fromundefined | string
data.toundefined | string
data.valueundefined | string
transactionHashstring

Implementation of

MoralisDataObject.toJSON

Accessors

address

get address(): EvmAddress

Example

event.address // EvmAddress

Returns

EvmAddress

the event address


blockHash

get blockHash(): string

Example

event.blockHash // "0xc9f62f4f6ab505a96c1a84ec2899c6bfd86245ef1effaa689fc997798be763d5"

Returns

string

the event block hash


blockNumber

get blockNumber(): BigNumber

Example

event.blockNumber // BigNumber

Returns

BigNumber

the event block number


blockTimestamp

get blockTimestamp(): Date

Example

event.blockTimestamp // Date

Returns

Date

the event block timestamp


chain

get chain(): EvmChain

Example

event.chain // EvmChain

Returns

EvmChain

the event chain


data

get data(): Object

Example

event.data

Returns

Object

the event data with from address, to address and value

NameType
from?EvmAddress
to?EvmAddress
value?EvmNative

result

get result(): EvmEventData

Example

event.result

Returns

EvmEventData

all the data without casting it to JSON.


transactionHash

get transactionHash(): string

Example

event.transactionHash // "0xc9f62f4f6ab505a96c1a84ec2899c6bfd86245ef1effaa689fc997798be763d5"

Returns

string

the event block trannsaciton hash