Class: EvmBlock

moralis-monorepo / @moralisweb3/evm-utils / EvmBlock

Class: EvmBlock

@moralisweb3/evm-utils.EvmBlock

The EvmBlock is a representation of a block.

Implements

  • MoralisDataObject

Table of contents

Methods

Accessors

Methods

create

Static create(data, core?): EvmBlock

Create a new instance of EvmBlock from any valid transaction input

Example

const transaction = EvmTransaction.create(data);

Parameters

NameTypeDescription
dataEvmBlockishthe EvmBlockish type
core?MoralisCore-

Returns

EvmBlock


equals

Static equals(dataA, dataB): boolean

Check the equality between two Evm blocks. It compares their hashes and blocks.

Example

EvmTransaction.equals(dataA, dataB)

Parameters

NameTypeDescription
dataAEvmBlockishThe first block to compare
dataBEvmBlockishThe second block to compare

Returns

boolean


equals

equals(data): boolean

Checks the equality of the current block with another evm block

Example

block.equals(data)

Parameters

NameTypeDescription
dataEvmBlockishthe block to compare with

Returns

boolean

Implementation of

MoralisDataObject.equals


toJSON

toJSON(): Object

Example

block.toJSON()

Returns

Object

a JSON represention of the block.

NameType
numberstring
difficultystring
totalDifficultystring
sizestring
gasLimitstring
gasUsedstring
chainstring | number
minerstring
transactions{ to: undefined | string ; from: string ; nonce: undefined | string ; gas: undefined | string ; gasPrice: string ; gasUsed: string ; cumulativeGasUsed: string ; blockNumber: string ; value: undefined | string ; chain: string | number ; contractAddress: undefined | string ; logs: { address: string ; logIndex?: number ; transactionHash: string ; transactionIndex?: number ; data: string ; topics: string[] ; blockHash: string ; blockNumber: number ; blockTimestamp?: string }[] ; blockTimestamp: string ; data?: string ; hash: string ; type?: number ; index: number ; blockHash: string ; receiptRoot?: string ; receiptStatus?: number }[]
timestampDate
hashstring
parentHashstring
noncestring
sha3Unclesstring
logsBloomstring
transactionsRootstring
stateRootstring
receiptsRootstring
extraDatastring
transactionCountnumber

Implementation of

MoralisDataObject.toJSON


format

format(): Object

Example

block.format()

Returns

Object

a JSON represention of the block.

NameType
numberstring
difficultystring
totalDifficultystring
sizestring
gasLimitstring
gasUsedstring
chainstring | number
minerstring
transactions{ to: undefined | string ; from: string ; nonce: undefined | string ; gas: undefined | string ; gasPrice: string ; gasUsed: string ; cumulativeGasUsed: string ; blockNumber: string ; value: undefined | string ; chain: string | number ; contractAddress: undefined | string ; logs: { address: string ; logIndex?: number ; transactionHash: string ; transactionIndex?: number ; data: string ; topics: string[] ; blockHash: string ; blockNumber: number ; blockTimestamp?: string }[] ; blockTimestamp: string ; data?: string ; hash: string ; type?: number ; index: number ; blockHash: string ; receiptRoot?: string ; receiptStatus?: number }[]
timestampDate
hashstring
parentHashstring
noncestring
sha3Unclesstring
logsBloomstring
transactionsRootstring
stateRootstring
receiptsRootstring
extraDatastring
transactionCountnumber

Implementation of

MoralisDataObject.format

Accessors

result

get result(): EvmBlockData

Example

block.result

Returns

EvmBlockData

all the data without casting it to JSON.


number

get number(): BigNumber

Example

block.number // BigNumber

Returns

BigNumber

the block number.


hash

get hash(): string

Example

block.hash // "0x9b559aef7ea858608c2e554246fe4a24287e7aeeb976848df2b9a2531f4b9171"

Returns

string

the block hash.


timestamp

get timestamp(): Date

Example

block.timestamp // Date

Returns

Date

the block timestamp.


miner

get miner(): EvmAddress

Example

block.miner // EvmAddress

Returns

EvmAddress

the block miner.


difficulty

get difficulty(): BigNumber

Example

block.difficulty // BigNumber

Returns

BigNumber

the block difficulty.


totalDifficulty

get totalDifficulty(): BigNumber

Example

block.totalDifficulty // BigNumber

Returns

BigNumber

the block total difficulty.


size

get size(): BigNumber

Example

block.size // BigNumber

Returns

BigNumber

the block size.


gasLimit

get gasLimit(): BigNumber

Example

block.gasLimit // BigNumber

Returns

BigNumber

the block gas limit.


gasUsed

get gasUsed(): BigNumber

Example

block.gasUsed // BigNumber

Returns

BigNumber

the block gas used.


transactions

get transactions(): EvmTransaction[]

Example

block.transactions // EvmTransaction[]

Returns

EvmTransaction[]

the block transactions.


chain

get chain(): EvmChain

Example

block.chain // EvmChain

Returns

EvmChain

the block chain.


transactionCount

get transactionCount(): number

Example

block.transactionCount // 252

Returns

number

the block transaction count.


transactionsRoot

get transactionsRoot(): string

Example

block.transactionsRoot // "0xe4c7bf3aff7ad07f9e80d57f7189f0252592fee6321c2a9bd9b09b6ce0690d27"

Returns

string

the block transactions root.


stateRoot

get stateRoot(): string

Example

block.stateRoot // "0x49e3bfe7b618e27fde8fa08884803a8458b502c6534af69873a3cc926a7c724b"

Returns

string

the block state root.


receiptsRoot

get receiptsRoot(): string

Example

block.receiptsRoot // "0x7cf43d7e837284f036cf92c56973f5e27bdd253ca46168fa195a6b07fa719f23"

Returns

string

the block receipts root.


logsBloom

get logsBloom(): string

Example

block.logsBloom // "0xdde5fc46c5d8bcbd58207bc9f267bf43298e23791a326ff02661e99790da9996b3e0dd912c0b8202d389d282c56e4d11eb2dec4898a32b6b165f1f4cae6aa0079498eab50293f3b8defbf6af11bb75f0408a563ddfc26a3323d1ff5f9849e95d5f034d88a757ddea032c75c00708c9ff34d2207f997cc7d93fd1fa160a6bfaf62a54e31f9fe67ab95752106ba9d185bfdc9b6dc3e17427f844ee74e5c09b17b83ad6e8fc7360f5c7c3e4e1939e77a6374bee57d1fa6b2322b11ad56ad0398302de9b26d6fbfe414aa416bff141fad9d4af6aea19322e47595e342cd377403f417dfd396ab5f151095a5535f51cbc34a40ce9648927b7d1d72ab9daf253e31daf"

Returns

string

the block logs bloom.


extraData

get extraData(): string

Example

block.extraData // "0x65746865726d696e652d6575726f70652d7765737433"

Returns

string

the block extra data.


parentHash

get parentHash(): string

Example

block.parentHash // "0x011d1fc45839de975cc55d758943f9f1d204f80a90eb631f3bf064b80d53e045"

Returns

string

the block parent hash.


sha3Uncles

get sha3Uncles(): string

Example

block.sha3Uncles // "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"

Returns

string

the block sha3Uncles.


nonce

get nonce(): string

Example

block.nonce // "0xedeb2d8fd2b2bdec"

Returns

string

the block nonce.


Did this page help you?