Skip to main content
Version: Next

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

Properties

hash

hash: BlockIdentifier = null

Param

if not null, contains the block hash

Defined in

src/utils/provider.ts:189


number

number: BlockIdentifier = null

Param

if not null, contains the block number

Defined in

src/utils/provider.ts:194


tag

tag: BlockIdentifier = null

Param

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

Defined in

src/utils/provider.ts:199

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


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

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

Methods

setIdentifier

setIdentifier(__identifier): void

Parameters

NameType
__identifierBlockIdentifier

Returns

void

Defined in

src/utils/provider.ts:201


valueOf

valueOf(): BlockIdentifier

Returns

BlockIdentifier

Defined in

src/utils/provider.ts:292


toString

toString(): BlockIdentifier

Returns

BlockIdentifier

Defined in

src/utils/provider.ts:294