Skip to main content

Python library for VIZ blockchain

Project description

Python Library for VIZ

Tests Status Documentation Status

Usage examples

Award someone

from viz import Client

node = "wss://node.viz.cx/ws"
viz = Client(node=node, keys=["5...your_private_regular_key..."])

initiator = "your_account"
receiver = "id"
percent = 10.5 # 10.5%
viz.award(receiver, percent, "with love", None, initiator)

Award someone with fixed reward

from viz import Client

node = "wss://node.viz.cx/ws"
viz = Client(node=node, keys=["5...your_private_regular_key..."])

initiator = "your_account"
receiver = "id"
reward_amount = 3.5 # "3.50 VIZ"
max_energy = 30 # 30%
viz.fixed_award(receiver, reward_amount, max_energy, "with fixed reward", None, initiator)

Send a custom operation

from viz import Client

node = "wss://node.viz.cx/ws"
viz = Client(node=node, keys=["5...your_private_regular_key..."])

account = "your_account"
required_regular_auths = [account]
protocol = "color.place"
custom_json = {"x": 35, "y": 70, "color": "#e50000"}
viz.custom(protocol, custom_json, None, required_regular_auths)

Get data from custom protocol

from viz import Client
from viz.account import Account
from viz.block import Block
from viz.instance import set_shared_blockchain_instance
import json

viz = Client("wss://node.viz.cx/ws")
set_shared_blockchain_instance(viz)

account_name = "id"
protocol = "V"
account = Account(account_name, protocol=protocol)

counter_inside_protocol = account["custom_sequence"]
last_used_in_block = account["custom_sequence_block_num"]

block = Block(last_used_in_block)

for tx in block["transactions"]:
    for op_type, op_data in tx["operations"]:
        if op_type != "custom":
            continue
        if op_data.get("id") != protocol:
            continue
        if account_name not in op_data.get("required_regular_auths", []):
            continue

        raw_json = op_data.get("json")
        try:
            json_from_protocol = json.loads(raw_json) if raw_json else None
        except json.JSONDecodeError:
            json_from_protocol = None

        print(json_from_protocol)

Any direct RPC call

from viz import Client

viz = Client("wss://node.viz.cx/ws")
viz.rpc.get_dynamic_global_properties()

Installation

Current published version could be installed via

pip install viz-python-lib

Manual installation:

Install poetry

cd viz-python-lib/
poetry install

Development

Dependencies

Linux dependencies

sudo apt-get install libffi-dev libssl-dev python3-dev

Windows dependencies

Install regular version of OpenSSL (not Light) suitable for your core processor.

MacOS dependencies

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. This means that you will need to install and export some OpenSSL settings yourself, before you can install viz-python-lib:

brew install openssl

and then use the following commands:

export CFLAGS="-I$(brew --prefix openssl)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

viz_python_lib-1.3.0.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viz_python_lib-1.3.0-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

Details for the file viz_python_lib-1.3.0.tar.gz.

File metadata

  • Download URL: viz_python_lib-1.3.0.tar.gz
  • Upload date:
  • Size: 33.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for viz_python_lib-1.3.0.tar.gz
Algorithm Hash digest
SHA256 b6549e1ce1f411a6eba3e53041c90e7800ded5e29fd4cf3099483c909363f906
MD5 58aa9f3a9a06f311dd4c4760ae4badb8
BLAKE2b-256 e0b3326d61fa7034967e983993cf118f0e59649c9fd9106af9f704d290b247fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for viz_python_lib-1.3.0.tar.gz:

Publisher: pypi.yml on VIZ-Blockchain/viz-python-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file viz_python_lib-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: viz_python_lib-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 41.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for viz_python_lib-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c02c34ba4055ab6bf6c3e309914627f4bc3925acd7aa2923dd6984b3e28b553
MD5 8edd9ee1e2565db8d3afdf37cff5783e
BLAKE2b-256 56409357250542b89d3208d2b13ab513acac42300e5396da435bbfc4eacaad36

See more details on using hashes here.

Provenance

The following attestation bundles were made for viz_python_lib-1.3.0-py3-none-any.whl:

Publisher: pypi.yml on VIZ-Blockchain/viz-python-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page