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.2.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.2-py3-none-any.whl (37.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: viz_python_lib-1.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 4d5cfd2403f3f33d60cc7c840009b9f51a4ab221f51399228af6a308dad8480a
MD5 96bdb4457f05e423af5d9201824bf77a
BLAKE2b-256 7450a6e10498f2bc77f6ce5c316af2e019b2d6ae0465d4e0e3447473b5049d81

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: viz_python_lib-1.2.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ff3601d5cb9819224ab6424bfe90b2b20c6645398b22fde91111889b6a81e1fe
MD5 28a60f8776153653060ef46be28a847e
BLAKE2b-256 89e87e152612ae72f97718aa73d1dd848e21a8f88bd63951d31f900436f501b6

See more details on using hashes here.

Provenance

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