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
Name | Type | Description |
---|---|---|
data | EvmEventish | the EvmEventish type |
Returns
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
Name | Type | Description |
---|---|---|
dataA | EvmEventish | The first event |
dataB | EvmEventish | The second event |
Returns
boolean
true if the events are equal, false otherwise
parse
▸ Static
parse(data
): EvmEventData
Parameters
Name | Type |
---|---|
data | EvmEventInput |
Returns
equals
▸ equals(data
): boolean
Checks the equality of the current event instance with another evm event
Example
event.equals(data)
Parameters
Name | Type | Description |
---|---|---|
data | EvmEventish | the 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
Name | Type |
---|---|
address | string |
blockHash | string |
blockNumber | string |
blockTimestamp | Date |
chain | string |
data | { from : undefined | string ; to : undefined | string ; value : undefined | string } |
data.from | undefined | string |
data.to | undefined | string |
data.value | undefined | string |
transactionHash | string |
Implementation of
MoralisDataObject.format
toJSON
▸ toJSON(): Object
Example
event.toJSON()
Returns
Object
a JSON represention of the event.
Name | Type |
---|---|
address | string |
blockHash | string |
blockNumber | string |
blockTimestamp | Date |
chain | string |
data | { from : undefined | string ; to : undefined | string ; value : undefined | string } |
data.from | undefined | string |
data.to | undefined | string |
data.value | undefined | string |
transactionHash | string |
Implementation of
MoralisDataObject.toJSON
Accessors
address
• get
address(): EvmAddress
Example
event.address // EvmAddress
Returns
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
the event chain
data
• get
data(): Object
Example
event.data
Returns
Object
the event data with from address, to address and value
Name | Type |
---|---|
from? | EvmAddress |
to? | EvmAddress |
value? | EvmNative |
result
• get
result(): EvmEventData
Example
event.result
Returns
all the data without casting it to JSON.
transactionHash
• get
transactionHash(): string
Example
event.transactionHash // "0xc9f62f4f6ab505a96c1a84ec2899c6bfd86245ef1effaa689fc997798be763d5"
Returns
string
the event block trannsaciton hash