viz.account

Module Contents

HistoryGenerator
class Account(account_name: str, blockchain_instance: Optional['Client'] = None)

Bases: dict

Inheritance diagram of viz.account.Account
private-bases

This class allows to easily access Account data.

param str account_name

Name of the account

param viz.viz.Client blockchain_instance

Client instance

property balances(self)

Shortcut to get_balances()

property energy(self)

Account energy at the moment of last use (stale)

refresh(self)

Loads account object from blockchain.

get_balances(self)

Obtain account balances.

Returns

dict with balances like {'VIZ': 49400000.0, 'SHARES': 0.0}

current_energy(self)

Returns current account energy (actual data, counts regenerated energy)

virtual_op_count(self)

Returns number of virtual ops performed by this account.

get_withdraw_routes(self, type_: str = 'all')

Get vesting withdraw routes.

Parameters

type – route type, one of all, incoming, outgoing

Returns

list with routes

Example return:

[
    {
        'from_account': 'alice',
        'to_account': 'bob',
        'percent': 10000,
        'auto_vest': False
    }
]
get_account_history(self, index: int, limit: int, start: Optional[int] = None, stop: Optional[int] = None, order: int = -1, filter_by: Optional[Union[str, List[str]]] = None, raw_output: bool = False)

A generator over get_account_history RPC.

It offers serialization, filtering and fine grained iteration control.

Note

This method is mostly for internal use, probably you need history().

Parameters
  • index (int) – start index for get_account_history

  • limit (int) – How many items in account history will be scanned (any ops, not only filtered)

  • start (int) – (Optional) skip items until this index

  • stop (int) – (Optional) stop iteration early at this index

  • order – (1, -1): 1 for chronological, -1 for reverse order

  • filter_by (str,list) – filter out all but these operations

  • raw_output (bool) – (Defaults to False). If True, return history in steemd format (unchanged).

history(self, filter_by: Optional[Union[str, List[str]]] = None, start: int = 0, batch_size: int = 1000, raw_output: bool = False, limit: int = -1)

Stream account history in chronological order.

This generator yields history items which may be in list or dict form depending on raw_output.

Parameters
  • filter_by (str,list) – filter out all but these operations

  • start (int) – (Optional) skip items until this index

  • batch_size (int) – (Optional) request as many items from API in each chunk

  • raw_output (bool) – (Defaults to False). If True, return history in steemd format (unchanged).

  • limit (int) – (Optional) limit number of filtered items to this amount (-1 means unlimited). This is a rough limit, actual results could be a bit longer

Returns

number of ops

Non-raw output example of yielded item:

{
    'from': 'viz',
    'to': 'null',
    'amount': '1.000 VIZ',
    'memo': 'test',
    'trx_id': '592010ade718c91a81cba3b8378c35ed81d23f23',
    'block': 5,
    'trx_in_block': 0,
    'op_in_trx': 0,
    'virtual_op': 0,
    'timestamp': '2020-05-19T08:10:47',
    'account': 'viz',
    'type': 'transfer',
    '_id': 'd1ed77ae861bb1ecc26a82dd275cc80e5ac124a6',
    'index': 0,
}

Raw output example of single item:

[
    0,
    {
        'trx_id': '592010ade718c91a81cba3b8378c35ed81d23f23',
        'block': 5,
        'trx_in_block': 0,
        'op_in_trx': 0,
        'virtual_op': 0,
        'timestamp': '2020-05-19T08:10:47',
        'op': ['transfer', {'from': 'viz', 'to': 'null', 'amount': '1.000 VIZ', 'memo': 'test'}],
    },
]
history_reverse(self, filter_by: Optional[Union[str, List[str]]] = None, batch_size: int = 1000, raw_output: bool = False, limit: int = -1)

Stream account history in reverse chronological order.

This generator yields history items which may be in list or dict form depending on raw_output. Output is similar to history().

Parameters
  • filter_by (str,list) – filter out all but these operations

  • batch_size (int) – (Optional) request as many items from API in each chunk

  • raw_output (bool) – (Defaults to False). If True, return history in steemd format (unchanged).

  • limit (int) – (Optional) limit number of filtered items to this amount (-1 means unlimited). This is a rough limit, actual results could be a bit longer

Returns

number of ops

__contains__()

True if the dictionary has the specified key, else False.

__delattr__()

Implement delattr(self, name).

__delitem__()

Delete self[key].

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__getitem__()

x.__getitem__(y) <==> x[y]

__gt__()

Return self>value.

__iter__()

Implement iter(self).

__le__()

Return self<=value.

__len__()

Return len(self).

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__setitem__()

Set self[key] to value.

__sizeof__()

D.__sizeof__() -> size of D in memory, in bytes

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

clear()

D.clear() -> None. Remove all items from D.

copy()

D.copy() -> a shallow copy of D

get()

Return the value for key if key is in the dictionary, else default.

items()

D.items() -> a set-like object providing a view on D’s items

keys()

D.keys() -> a set-like object providing a view on D’s keys

pop()

D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised

popitem()

D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.

setdefault()

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update()

D.update([E, ]**F) -> None. Update D from dict/iterable E and F. If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

D.values() -> an object providing a view on D’s values