nectar.block module
- class nectar.block.Block(block: int | float | dict, only_ops: bool = False, only_virtual_ops: bool = False, full: bool = True, lazy: bool = False, blockchain_instance: Any = None, **kwargs)
Bases:
BlockchainObjectRead a single block from the chain
- Parameters:
block (int) – block number
blockchain_instance (Hive) – Hive instance
lazy (bool) – Use lazy loading
only_ops (bool) – Includes only operations, when set to True (default: False)
only_virtual_ops (bool) – Includes only virtual operations (default: False)
Instances of this class are dictionaries that come with additional methods (see below) that allow dealing with a block and its corresponding functions.
When only_virtual_ops is set to True, only_ops is always set to True.
In addition to the block data, the block number is stored as self[“id”] or self.identifier.
>>> from nectar.block import Block >>> block = Block(1) >>> print(block) <Block 1>
Note
This class comes with its own caching function to reduce the load on the API server. Instances of this class can be refreshed with
Account.refresh().- property block_num: int | None
Returns the block number
- json() dict
- property json_operations: list[Any]
Returns all block operations as list, all dates are strings.
- property json_transactions: list[dict[str, Any]]
Returns all transactions as list, all dates are strings.
- property operations: list[Any]
Returns all block operations as list
- ops_statistics(add_to_ops_stat: dict[str, int] | None = None) dict[str, int]
Returns a statistic with the occurrence of the different operation types
- refresh() None
Even though blocks never change, you freshly obtain its contents from an API with this method
- time() datetime
Return a datetime instance for the timestamp of this block
- property transactions: list[dict[str, Any]]
Returns all transactions as list
- class nectar.block.BlockHeader(block: int | float | dict, full: bool = True, lazy: bool = False, blockchain_instance: Any = None, **kwargs)
Bases:
BlockchainObjectRead a single block header from the chain
- Parameters:
block (int) – block number
blockchain_instance (Hive) – Hive instance
lazy (bool) – Use lazy loading
In addition to the block data, the block number is stored as self[“id”] or self.identifier.
>>> from nectar.block import BlockHeader >>> block = BlockHeader(1) >>> print(block) <BlockHeader 1>
- property block_num: int
Returns the block number
- json() dict
- refresh() None
Even though blocks never change, you freshly obtain its contents from an API with this method
- time() datetime
Return a datetime instance for the timestamp of this block
- class nectar.block.Blocks(starting_block_num: int, count: int = 1000, lazy: bool = False, full: bool = True, only_ops: bool = False, only_virtual_ops: bool = False, blockchain_instance: Any = None, **kwargs)
Bases:
listObtain a list of blocks
- Parameters:
name_list (list) – list of accounts to fetch
count (int) – (optional) maximum number of accounts to fetch per call, defaults to 100
blockchain_instance (Hive) – Hive() instance to use when accessing RPC