Class: EvmSimpleBlock
moralis-monorepo / @moralisweb3/common-evm-utils / EvmSimpleBlock
Class: EvmSimpleBlock
@moralisweb3/common-evm-utils.EvmSimpleBlock
The EvmSimpleBlock is a representation of a block.
Implements
MoralisDataObject
Table of contents
Methods
Accessors
Constructors
Methods
create
▸ Static create(data): EvmSimpleBlock
Create a new instance of EvmSimpleBlock from any valid transaction input
Example
const transaction = EvmSimpleBlock.create(data);
Parameters
| Name | Type | Description |
|---|---|---|
data | EvmSimpleBlockish | the EvmSimpleBlockish type |
Returns
equals
▸ Static equals(dataA, dataB): boolean
Check the equality between two Evm blocks. It compares their hashes and blocks.
Example
EvmSimpleBlock.equals(dataA, dataB)
Parameters
| Name | Type | Description |
|---|---|---|
dataA | EvmSimpleBlockish | EvmBlockish | The first block to compare |
dataB | EvmSimpleBlockish | EvmBlockish | The second block to compare |
Returns
boolean
parse
▸ Static parse(data): EvmSimpleBlockData
Parameters
| Name | Type |
|---|---|
data | EvmSimpleBlockInput |
Returns
equals
▸ equals(data): boolean
Checks the equality of the current block with another evm block
Example
block.equals(data)
Parameters
| Name | Type | Description |
|---|---|---|
data | EvmSimpleBlockish | the block to compare with |
Returns
boolean
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 |
|---|---|
chain | string |
hash | string |
number | string |
timestamp | Date |
Implementation of
MoralisDataObject.format
toJSON
▸ toJSON(): Object
Example
block.toJSON()
Returns
Object
a JSON represention of the block.
| Name | Type |
|---|---|
chain | string |
hash | string |
number | string |
timestamp | Date |
Implementation of
MoralisDataObject.toJSON
Accessors
chain
• get chain(): EvmChain
Example
block.chain // EvmChain
Returns
the block chain.
hash
• get hash(): string
Example
block.hash // "0x9b559aef7ea858608c2e554246fe4a24287e7aeeb976848df2b9a2531f4b9171"
Returns
string
the block hash.
number
• get number(): BigNumber
Example
block.number // BigNumber
Returns
BigNumber
the block number.
result
• get result(): EvmSimpleBlockData
Example
block.result
Returns
all the data without casting it to JSON.
timestamp
• get timestamp(): Date
Example
block.timestamp // Date
Returns
Date
the block timestamp.
Constructors
constructor
• new EvmSimpleBlock(data)
Parameters
| Name | Type |
|---|---|
data | EvmSimpleBlockInput |