Skip to main content

Class: EvmBlock

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

Class: EvmBlock

@moralisweb3/common-evm-utils.EvmBlock

The EvmBlock is a representation of a block.

Table of contents

Methods

Accessors

Constructors

Methods

create

Static create(data): EvmBlock

Create a new instance of EvmBlock from any valid transaction input

Example

const transaction = EvmTransaction.create(data);

Parameters

NameTypeDescription
dataEvmBlockishthe EvmBlockish type

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
dataAEvmSimpleBlockish | EvmBlockishThe first block to compare
dataBEvmSimpleBlockish | EvmBlockishThe second block to compare

Returns

boolean


parse

Static parse(data): EvmBlockData

Parameters

NameType
dataEvmBlockInput

Returns

EvmBlockData


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


format

format(): Object

Deprecated

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

Returns

Object

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

toJSON

toJSON(): Object

Example

block.toJSON()

Returns

Object

a JSON represention of the block.

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

Accessors

chain

get chain(): EvmChain

Example

block.chain // EvmChain

Returns

EvmChain

the block chain.


difficulty

get difficulty(): BigNumber

Example

block.difficulty // BigNumber

Returns

BigNumber

the block difficulty.


extraData

get extraData(): string

Example

block.extraData // "0x65746865726d696e652d6575726f70652d7765737433"

Returns

string

the block extra data.


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.


hash

get hash(): string

Example

block.hash // "0x9b559aef7ea858608c2e554246fe4a24287e7aeeb976848df2b9a2531f4b9171"

Returns

string

the block hash.


logsBloom

get logsBloom(): string

Example

block.logsBloom // "0xdde5fc46c5d8bcbd58207bc9f267bf43298e23791a326ff02661e99790da9996b3e0dd912c0b8202d389d282c56e4d11eb2dec4898a32b6b165f1f4cae6aa0079498eab50293f3b8defbf6af11bb75f0408a563ddfc26a3323d1ff5f9849e95d5f034d88a757ddea032c75c00708c9ff34d2207f997cc7d93fd1fa160a6bfaf62a54e31f9fe67ab95752106ba9d185bfdc9b6dc3e17427f844ee74e5c09b17b83ad6e8fc7360f5c7c3e4e1939e77a6374bee57d1fa6b2322b11ad56ad0398302de9b26d6fbfe414aa416bff141fad9d4af6aea19322e47595e342cd377403f417dfd396ab5f151095a5535f51cbc34a40ce9648927b7d1d72ab9daf253e31daf"

Returns

string

the block logs bloom.


miner

get miner(): EvmAddress

Example

block.miner // EvmAddress

Returns

EvmAddress

the block miner.


nonce

get nonce(): string

Example

block.nonce // "0xedeb2d8fd2b2bdec"

Returns

string

the block nonce.


number

get number(): BigNumber

Example

block.number // BigNumber

Returns

BigNumber

the block number.


parentHash

get parentHash(): string

Example

block.parentHash // "0x011d1fc45839de975cc55d758943f9f1d204f80a90eb631f3bf064b80d53e045"

Returns

string

the block parent hash.


receiptsRoot

get receiptsRoot(): string

Example

block.receiptsRoot // "0x7cf43d7e837284f036cf92c56973f5e27bdd253ca46168fa195a6b07fa719f23"

Returns

string

the block receipts root.


result

get result(): EvmBlockData

Example

block.result

Returns

EvmBlockData

all the data without casting it to JSON.


sha3Uncles

get sha3Uncles(): string

Example

block.sha3Uncles // "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"

Returns

string

the block sha3Uncles.


size

get size(): BigNumber

Example

block.size // BigNumber

Returns

BigNumber

the block size.


stateRoot

get stateRoot(): string

Example

block.stateRoot // "0x49e3bfe7b618e27fde8fa08884803a8458b502c6534af69873a3cc926a7c724b"

Returns

string

the block state root.


timestamp

get timestamp(): Date

Example

block.timestamp // Date

Returns

Date

the block timestamp.


totalDifficulty

get totalDifficulty(): BigNumber

Example

block.totalDifficulty // BigNumber

Returns

BigNumber

the block total difficulty.


transactionCount

get transactionCount(): number

Example

block.transactionCount // 252

Returns

number

the block transaction count.


transactions

get transactions(): EvmTransaction[]

Example

block.transactions // EvmTransaction[]

Returns

EvmTransaction[]

the block transactions.


transactionsRoot

get transactionsRoot(): string

Example

block.transactionsRoot // "0xe4c7bf3aff7ad07f9e80d57f7189f0252592fee6321c2a9bd9b09b6ce0690d27"

Returns

string

the block transactions root.

Constructors

constructor

new EvmBlock(data)

Parameters

NameType
dataEvmBlockInput