Skip to main content
Version: Next

Class: Block

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

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:230

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:187

Param

if not null, contains the block hash


number

number: BlockIdentifier = null

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

Param

if not null, contains the block number


tag

tag: BlockIdentifier = null

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

Param

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

Accessors

queryIdentifier

Get Signature

get queryIdentifier(): any

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

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:264

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:286

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:290

Returns

BlockIdentifier


toString()

toString(): BlockIdentifier

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

Returns

BlockIdentifier