Skip to main content

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)

Prediction market operations (HF14 / Onix)

All 23 broadcastable pm_* operations are available as serializers in vizbase.operations. Build the operation and sign it with finalizeOp (the same low-level path the built-in helpers use), passing the authority the op requires — active for most PM ops, regular for pm_dispute_vote:

from viz import Client
from vizbase import operations

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

account = "your_account"

# Place a bet: binary market -> side 0/1, outcome_index -1; multi -> side -1, outcome_index 0..N-1
bet = operations.Pm_place_bet(
    account=account,
    market_id=42,
    side=1,
    outcome_index=-1,
    amount="1.500 VIZ",
    min_tokens=0,  # slippage floor (0 = none)
    mode=0,  # 0 instant, 1 batch
)
viz.finalizeOp(bet, account, "active")

Chain governance uses the versioned variant: versioned_chain_properties_update serializes variant 3 (chain_properties_hf9), 4 (chain_properties_hf13) or 5 (chain_properties_pm, the HF14 PM params) automatically from the fields you pass.

Agent keys (HF15)

An agent is a label plus a public key that may sign an explicit list of a principal's operations. It never appears in the account's authorities, so check "authority OR agent":

from viz import Client, agent

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

result = agent.check("alice", "VIZ...public_key...", "transfer", blockchain_instance=viz)
# {"allowed": True, "source": "agent", "role": None, "agent": {...row...}, "operation": "transfer"}

# off-chain scope of your own service
row = agent.find("alice", "VIZ...public_key...", viz)
if row and agent.addon_matches(row, "my-service"):
    ...

Grant or revoke with operations.Set_agent_permission via finalizeOp(op, account, "active"). To broadcast as an agent, sign with the agent key directly: tx.appendWif(agent_wif).

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"

HF16 compatibility

The block stream reads the current block interval from the node, including the 3-second to 1-second HF16 transition. Block and header API responses retain QC, timeout and equivocation extensions as JSON; this library does not serialize or sign block headers. validator_equivocation is virtual operation 106.

committee_worker_create_request uses the existing transaction wire format. From HF16 the node limits the maximum requested amount to 1% of current_supply at creation (rounded down to the smallest VIZ unit), rather than a fixed 500,000 VIZ.

Metadata

Release files for viz-python-lib 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for viz-python-lib 1.4.0
File Size Uploaded Provenance Actions
viz_python_lib-1.4.0.tar.gz 42.7 kB With provenance Details for viz_python_lib-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for viz-python-lib 1.4.0
File Interpreter ABI Platform Actions
viz_python_lib-1.4.0-py3-none-any.whl Python 3 none any Details for viz_python_lib-1.4.0-py3-none-any.whl

Total release size: 92.8 kB

Release files / viz_python_lib-1.4.0.tar.gz

Download URL viz_python_lib-1.4.0.tar.gz
Size 42.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cb07bb2686ce1b230562284c6ca60ac9156eb47b4a56b8bf550da18b75aee4b9
BLAKE2b-256 checksum
How to use checksums
5c7e85445c85f963256ac9bf183a3f1949ec00d7edfc0eff144b3410809b7aa9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / viz_python_lib-1.4.0-py3-none-any.whl

Download URL viz_python_lib-1.4.0-py3-none-any.whl
Size 50.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22a3dbe8b715a57d6ea45fef0dab1805bba30f4454ed25a23b3ee4a01e088d09
BLAKE2b-256 checksum
How to use checksums
ac31f76ba229b3f4e6221b2cece2ed41959d676614e991b86ce105cb5385265f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for viz-python-lib 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for viz_python_lib-1.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page