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.2.1.tar.gz (30.6 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.2.1-py3-none-any.whl (37.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: viz_python_lib-1.2.1.tar.gz
  • Upload date:
  • Size: 30.6 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.2.1.tar.gz
Algorithm Hash digest
SHA256 a9a76471133926d9b4b9cc927f589b0a447d5d7ea3307d69079f4ba70dabb1b8
MD5 c97e2ec1439c4cba29cebfeab50afdcd
BLAKE2b-256 54424c454c6c0bd0998e8299cd99607b78d44b9532ba484b29ab4704f81a268c

See more details on using hashes here.

Provenance

The following attestation bundles were made for viz_python_lib-1.2.1.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.2.1-py3-none-any.whl.

File metadata

  • Download URL: viz_python_lib-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 37.7 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aae8e7be794c3810a1de16da2253d0bc2ee2579991fb7baf49837cf4858d50d7
MD5 21b8a2935c2907a0bdc7013800a7c9ef
BLAKE2b-256 4686bc6ce0ee35f2ac8eee610a4df2f6dea9711b52da1ee9ea1369630278a223

See more details on using hashes here.

Provenance

The following attestation bundles were made for viz_python_lib-1.2.1-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