nectar.witness module
- class nectar.witness.GetWitnesses(name_list, batch_limit=100, lazy=False, full=True, blockchain_instance=None)
Bases:
WitnessesObjectObtain a list of witnesses
- Parameters:
name_list (list) – list of witneses to fetch
batch_limit (int) – (optional) maximum number of witnesses to fetch per call, defaults to 100
blockchain_instance (nectar.nectar.nectar) – nectar instance to use when accessing the RPC
from nectar.witness import GetWitnesses w = GetWitnesses(["gtg", "jesta"]) print(w[0].json()) print(w[1].json())
- class nectar.witness.ListWitnesses(from_account='', limit=100, lazy=False, full=False, blockchain_instance=None, **kwargs)
Bases:
WitnessesObjectList witnesses ranked by name
- Parameters:
from_account (str) – Witness name from which the list starts (default = “”)
limit (int) – Limits the number of shown witnesses (default = 100)
blockchain_instance (nectar.nectar.nectar) – nectar instance to use when accessing the RPC
>>> from nectar.witness import ListWitnesses >>> ListWitnesses(from_account="gtg", limit=100) <ListWitnesses gtg>
- class nectar.witness.Witness(owner: str | dict[str, Any], full: bool = False, lazy: bool = False, blockchain_instance: Any | None = None, **kwargs: Any)
Bases:
BlockchainObjectRead data about a witness in the chain
- Parameters:
owner (str) – Name of the witness
lazy (bool) – Use lazy loading
full (bool) – Get full data about witness
blockchain_instance (nectar.nectar.nectar) – nectar instance to use when accessing the RPC
- feed_publish(base, quote=None, account=None)
Publish a witness feed price (exchange rate) to the blockchain.
Accepts the base and quote as Amount objects, strings, or numeric values and submits a Feed_publish operation using the provided account (defaults to the witness owner).
- Parameters:
- base: Amount | str | number
The base side of the exchange_rate (must use the blockchain’s backed token symbol).
- quote: Amount | str | number, optional
The quote side of the exchange_rate. Defaults to “1.000 <TOKEN>” where <TOKEN> is the blockchain token_symbol.
- account: str | Account, optional
Account name or Account object used to sign and publish the feed. If omitted, the witness owner is used.
- Returns:
The result returned by blockchain.finalizeOp (typically the broadcast/transaction result).
- Raises:
ValueError: If no account is provided and the witness has no owner. AssertionError: If the resolved base or quote symbols do not match the blockchain’s expected backed_token_symbol and token_symbol, respectively.
- static get_witness_by_account(account_name: str, blockchain_instance: Any | None = None) dict[str, Any] | None
Fetch witness information by account name using the get_witness_by_account RPC call.
- Parameters:
account_name (str) – Name of the witness account
blockchain_instance – Nectar instance (optional)
- Returns:
Witness data dictionary or None if not found/error
- property is_active: bool
- json() dict[str, Any]
- refresh() None
Refresh the witness data from the blockchain and reinitialize this object.
If the witness identifier is empty or the blockchain is not connected, the method returns early. Fetches witness data via the configured RPC, parses timestamps and numeric fields via _parse_json_data, and reinitializes the Witness instance with the retrieved data (respecting this object’s lazy/full flags and blockchain instance).
- Raises:
WitnessDoesNotExistsException: If no witness information is found for the current identifier.
- type_id = 3
- update(*args: Any, **kwargs: Any) Any
Compatibility shim to avoid clashing with MutableMapping.update
- update_witness(signing_key, url, props, account=None)
Update witness
- Parameters:
signing_key (str) – Signing key
url (str) – URL
props (dict) – Properties
account (str) – (optional) witness account name
Properties::
{ "account_creation_fee": x, "maximum_block_size": x, "sbd_interest_rate": x, }
- class nectar.witness.Witnesses(lazy=False, full=True, blockchain_instance=None, **kwargs)
Bases:
WitnessesObjectObtain a list of active witnesses and the current schedule
- Parameters:
blockchain_instance (nectar.nectar.nectar) – nectar instance to use when accessing the RPC
>>> from nectar.witness import Witnesses >>> Witnesses() <Witnesses >
- refresh()
- class nectar.witness.WitnessesObject(iterable=(), /)
Bases:
list- get_votes_sum()
- printAsTable(sort_key='votes', reverse=True, return_str=False, **kwargs)
- class nectar.witness.WitnessesRankedByVote(from_account='', limit=100, lazy=False, full=False, blockchain_instance=None, **kwargs)
Bases:
WitnessesObjectObtain a list of witnesses ranked by Vote
- Parameters:
from_account (str) – Witness name from which the lists starts (default = “”)
limit (int) – Limits the number of shown witnesses (default = 100)
blockchain_instance (nectar.nectar.nectar) – nectar instance to use when accessing the RPC
>>> from nectar.witness import WitnessesRankedByVote >>> WitnessesRankedByVote(limit=100) <WitnessesRankedByVote >
- class nectar.witness.WitnessesVotedByAccount(account, lazy=False, full=True, blockchain_instance=None, **kwargs)
Bases:
WitnessesObjectObtain a list of witnesses which have been voted by an account
- Parameters:
account (str) – Account name
blockchain_instance (nectar.nectar.nectar) – nectar instance to use when accessing the RPC
>>> from nectar.witness import WitnessesVotedByAccount >>> WitnessesVotedByAccount("gtg") <WitnessesVotedByAccount gtg>