Skip to main content
Version: 11.x

Class: Block

Defined in: src/utils/provider.ts:188

This class is formatting the identifier of a block.

hex string and BigInt are detected as block hashes. identifier return { block_hash: hash }

decimal string and number are detected as block numbers. identifier return { block_number: number }

text string are detected as block tag. identifier return tag

null is detected as 'latest' block tag. identifier return 'latest'

Example​

const result = new provider.Block(null).identifier;
// result = "latest"

Constructors​

Constructor​

new Block(_identifier): Block

Defined in: src/utils/provider.ts:235

Create a Block instance

Parameters​

_identifier​

BlockIdentifier

hex string and BigInt are detected as block hashes. decimal string and number are detected as block numbers. text string are detected as block tag. null is considered as a 'latest' block tag.

Returns​

Block

Properties​

hash​

hash: BlockIdentifier = null

Defined in: src/utils/provider.ts:192

Param​

hash

if not null, contains the block hash


number​

number: BlockIdentifier = null

Defined in: src/utils/provider.ts:197

Param​

number

if not null, contains the block number


tag​

tag: BlockIdentifier = null

Defined in: src/utils/provider.ts:202

Param​

tag

if not null, contains "pre_confirmed" or "latest"

Accessors​

queryIdentifier​

Get Signature​

get queryIdentifier(): any

Defined in: src/utils/provider.ts:248

Example​
const result = new provider.Block(123456n).queryIdentifier;
// result = "blockHash=0x1e240"
Returns​

any

the identifier as a string


identifier​

Get Signature​

get identifier(): any

Defined in: src/utils/provider.ts:269

Example​
const result = new provider.Block(56789).identifier;
// result = { block_number: 56789 }
Returns​

any

the identifier as an object

Set Signature​

set identifier(_identifier): void

Defined in: src/utils/provider.ts:291

change the identifier of an existing Block instance

Example​
const myBlock = new provider.Block("latest");
myBlock.identifier ="0x3456789abc";
const result = myBlock.identifier;
// result = { block_hash: '0x3456789abc' }
Parameters​
_identifier​

BlockIdentifier

Returns​

void

Methods​

valueOf()​

valueOf(): BlockIdentifier

Defined in: src/utils/provider.ts:295

Returns​

BlockIdentifier


toString()​

toString(): BlockIdentifier

Defined in: src/utils/provider.ts:297

Returns​

BlockIdentifier