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​
Name | Type | Description |
---|---|---|
_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 'pending' block tag. |
Returns​
Defined in​
Properties​
hash​
• hash: BlockIdentifier
= null
Param
if not null, contains the block hash
Defined in​
number​
• number: BlockIdentifier
= null
Param
if not null, contains the block number
Defined in​
tag​
• tag: BlockIdentifier
= null
Param
if not null, contains "pending" or "latest"
Defined in​
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​
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​
• set
identifier(_identifier
): void
change the identifier of an existing Block instance
Parameters​
Name | Type |
---|---|
_identifier | BlockIdentifier |
Returns​
void
Example
const myBlock = new provider.Block('latest');
myBlock.identifier = '0x3456789abc';
const result = myBlock.identifier;
// result = { block_hash: '0x3456789abc' }
Defined in​
Methods​
setIdentifier​
â–¸ setIdentifier(__identifier
): void
Parameters​
Name | Type |
---|---|
__identifier | BlockIdentifier |
Returns​
void
Defined in​
valueOf​
â–¸ valueOf(): BlockIdentifier
Returns​
Defined in​
toString​
â–¸ toString(): BlockIdentifier