:mod:`viz.viz` ============== .. py:module:: viz.viz Module Contents --------------- .. data:: log .. py:class:: Client Bases: :class:`graphenecommon.chain.AbstractGrapheneChain` .. autoapi-inheritance-diagram:: viz.viz.Client :parts: 1 :private-bases: Blockchain network client. :param str node: Node to connect to :param str rpcuser: RPC user *(optional)* :param str rpcpassword: RPC password *(optional)* :param bool nobroadcast: Do **not** broadcast a transaction! *(optional)* :param bool debug: Enable Debugging *(optional)* :param array,dict,string keys: Predefine the wif keys to shortcut the wallet database *(optional)* :param bool offline: Boolean to prevent connecting to network (defaults to ``False``) *(optional)* :param int expiration: Delay in seconds until transactions are supposed to expire *(optional)* :param bool blocking: Wait for broadcasted transactions to be included in a block and return full transaction. Blocking is checked inside :py:meth:`~graphenecommon.transactionbuilder.TransactionBuilder.broadcast` *(Default: False)*, *(optional)* :param bool bundle: Do not broadcast transactions right away, but allow to bundle operations *(optional)* Three wallet operation modes are possible: * **Wallet Database**: Here, the libs load the keys from the locally stored wallet SQLite database (see ``storage.py``). To use this mode, simply call ``Client()`` without the ``keys`` parameter * **Providing Keys**: Here, you can provide the keys for your accounts manually. All you need to do is add the wif keys for the accounts you want to use as a simple array using the ``keys`` parameter to ``Client()``. * **Force keys**: This more is for advanced users and requires that you know what you are doing. Here, the ``keys`` parameter is a dictionary that overwrite the ``active``, ``master``, or ``memo`` keys for any account. This mode is only used for *foreign* signatures! The purpose of this class it to simplify interaction with blockchain by providing high-level methods instead of forcing user to use RPC methods directly. The idea is to have a class that allows to do this: .. code-block:: python from viz import Client viz = Client() print(viz.info()) .. method:: define_classes(self) .. method:: new_proposal(self, title: str, memo: str = '', parent: Optional[TransactionBuilder] = None, expiration_time: int = 2 * 24 * 60 * 60, review_period_time: Optional[int] = None, account: str = None, **kwargs: Any) Create a new proposal. Proposal is a way to propose some transaction to another account. Primary usecase is a multisig account which requires several members approval to perform an operation. :param str title: title of proposed transaction :param str memo: may be a description of the proposal :param TransactionBuilder parent: TransactionBuilder instance to add proposal to :param int expiration_time: maximum time allowed for transaction :param int review_period_time: time to make a decision of the transaction participants :param str account: author of proposed transaction Example usage: .. code-block:: python from viz import Client viz = Client() proposal = viz.new_proposal('title', 'test proposal', account='alice') viz.transfer("null", 1, "VIZ", memo="test transfer proposal", account=default_account, append_to=proposal) proposal.broadcast() .. method:: proposal_update(self, author: str, title: str, approver: Union[str, list] = None, keys: Union[str, list] = None, permission: str = 'regular', approve: bool = True, account: str = None) Update proposal (approve or disapprove) :param str author: author of proposed transaction :param str title: title of proposed transaction :param str, list approver: account(s) for approvals, default is account field :param str keys: public key(s) used for multisig accounts (key approval) :param str permission: the required permission type for signing :param str approve: True = approve, False = disapprove :param str account: the account that authorizes the operation .. method:: transfer(self, to: str, amount: float, asset: str, memo: str = '', account: Optional[str] = None, **kwargs: Any) Transfer an asset to another account. :param str to: Recipient :param float amount: Amount to transfer :param str asset: Asset to transfer :param str memo: (optional) Memo, may begin with `#` for encrypted messaging :param str account: (optional) the source account for the transfer if not ``default_account`` .. method:: award(self, receiver: str, energy: float, memo: str = '', beneficiaries: Optional[List[Dict[str, Union[str, int]]]] = None, account: str = None, **kwargs: Any) Award someone. :param str receiver: account name of award receiver :param float energy: energy as 0-100% :param str memo: optional comment :param list beneficiaries: list of dicts, example ``[{'account': 'vvk', 'weight': 50}]`` :param str account: initiator account name .. method:: custom(self, id_: str, json: Union[Dict, List], required_active_auths: Optional[List[str]] = None, required_regular_auths: Optional[List[str]] = None) Create a custom operation. :param str id_: identifier for the custom (max length 32 bytes) :param dict,list json: the json data to put into the custom operation :param list required_active_auths: (optional) require signatures from these active auths to make this operation valid :param list required_regular_auths: (optional) require signatures from these regular auths .. method:: withdraw_vesting(self, amount: float, account: str = None) Withdraw SHARES from the vesting account. :param float amount: number of SHARES to withdraw over a period :param str account: (optional) the source account for the transfer if not ``default_account`` .. method:: transfer_to_vesting(self, amount: float, to: str = None, account: str = None) Vest free VIZ into vesting. :param float amount: number of VIZ to vest :param str to: (optional) the source account for the transfer if not ``default_account`` :param str account: (optional) the source account for the transfer if not ``default_account`` .. method:: set_withdraw_vesting_route(self, to: str, percentage: float = 100, account: str = None, auto_vest: bool = False) Set up a vesting withdraw route. When vesting shares are withdrawn, they will be routed to these accounts based on the specified weights. To obtain existing withdraw routes, use :py:meth:`get_withdraw_vesting_routes` .. code-block:: python a = Account('vvk', blockchain_instance=viz) pprint(a.get_withdraw_routes()) :param str to: Recipient of the vesting withdrawal :param float percentage: The percent of the withdraw to go to the 'to' account. :param str account: (optional) the vesting account :param bool auto_vest: Set to true if the from account should receive the SHARES as SHARES, or false if it should receive them as CORE. (defaults to ``False``) .. method:: get_withdraw_vesting_routes(self, account: str, **kwargs: str) Get vesting withdraw route for an account. This is a shortcut for :py:meth:`viz.account.Account.get_withdraw_routes`. :param str account: account name :return: list with routes .. method:: create_account(self, account_name: str, json_meta: Optional[Dict[str, Any]] = None, password: str = None, master_key: str = None, active_key: str = None, regular_key: str = None, memo_key: str = None, additional_master_keys: Optional[List[str]] = None, additional_active_keys: Optional[List[str]] = None, additional_regular_keys: Optional[List[str]] = None, additional_master_accounts: Optional[List[str]] = None, additional_active_accounts: Optional[List[str]] = None, additional_regular_accounts: Optional[List[str]] = None, store_keys: bool = True, fee: float = 0, delegation: float = 0, creator: str = None, referrer: str = '') Create new account. The brainkey/password can be used to recover all generated keys (see :py:mod:`vizbase.account` for more details. By default, this call will use ``default_account`` to register a new name ``account_name`` with all keys being derived from a new brain key that will be returned. The corresponding keys will automatically be installed in the wallet. .. note:: Account creations cost a fee that is defined by the network. If you create an account, you will need to pay for that fee! **You can partially pay that fee by delegating SHARES.** .. warning:: Don't call this method unless you know what you are doing! Be sure to understand what this method does and where to find the private keys for your account. .. note:: Please note that this imports private keys (if password is present) into the wallet by default. :param str account_name: (**required**) new account name :param dict json_meta: Optional meta data for the account :param str password: Alternatively to providing keys, one can provide a password from which the keys will be derived :param str master_key: Main master key :param str active_key: Main active key :param str regular_key: Main regular key :param str memo_key: Main memo_key :param list additional_master_keys: Additional master public keys :param list additional_active_keys: Additional active public keys :param list additional_regular_keys: Additional regular public keys :param list additional_master_accounts: Additional master account names :param list additional_active_accounts: Additional active account names :param list additional_regular_accounts: Additional regular account names :param bool store_keys: Store new keys in the wallet (default: ``True``) :param float fee: (Optional) If set, `creator` pay a fee of this amount, and delegate the rest with SHARES (calculated automatically). :param float delegation: amount of SHARES to be delegated to a new account :param str creator: which account should pay the registration fee (defaults to ``default_account``) :param str referrer: account who will be set as referrer, defaults to creator :raises AccountExistsException: if the account already exists on the blockchain .. method:: _store_keys(self, *args) Store private keys to local storage.