Skip to main content
Version: 6.11.0

Class: Block

provider.Block

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 'pending' block tag. identifier return 'pending'

Example

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

Constructors​

constructor​

• new Block(_identifier): Block

Create a Block instance

Parameters​

NameTypeDescription
_identifierBlockIdentifierhex 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 'pending' block tag.

Returns​

Block

Defined in​

src/utils/provider.ts:196

Properties​

hash​

• hash: BlockIdentifier = null

Param

if not null, contains the block hash

Defined in​

src/utils/provider.ts:153


number​

• number: BlockIdentifier = null

Param

if not null, contains the block number

Defined in​

src/utils/provider.ts:158


tag​

• tag: BlockIdentifier = null

Param

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

Defined in​

src/utils/provider.ts:163

Accessors​

queryIdentifier​

• get queryIdentifier(): any

Returns​

any

the identifier as a string

Example

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

Defined in​

src/utils/provider.ts:209


identifier​

• get identifier(): any

Returns​

any

the identifier as an object

Example

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

Defined in​

src/utils/provider.ts:230

• set identifier(_identifier): void

change the identifier of an existing Block instance

Parameters​

NameType
_identifierBlockIdentifier

Returns​

void

Example

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

Defined in​

src/utils/provider.ts:252

Methods​

setIdentifier​

â–¸ setIdentifier(__identifier): void

Parameters​

NameType
__identifierBlockIdentifier

Returns​

void

Defined in​

src/utils/provider.ts:165


valueOf​

â–¸ valueOf(): BlockIdentifier

Returns​

BlockIdentifier

Defined in​

src/utils/provider.ts:256


toString​

â–¸ toString(): BlockIdentifier

Returns​

BlockIdentifier

Defined in​

src/utils/provider.ts:258