Python library for VIZ blockchain
Project description
Python Library for VIZ
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file viz_python_lib-1.2.0.tar.gz.
File metadata
- Download URL: viz_python_lib-1.2.0.tar.gz
- Upload date:
- Size: 30.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d5f43b260986f78a6540c4572c265348d94496542c5d6d05a323cca886b7d8c
|
|
| MD5 |
2284d37ec64df7cb4a1eb79d76cbe743
|
|
| BLAKE2b-256 |
61671a6c048e4186afc5efd53a6ec619f9402f289742652eac4f499a4e5a49eb
|
File details
Details for the file viz_python_lib-1.2.0-py3-none-any.whl.
File metadata
- Download URL: viz_python_lib-1.2.0-py3-none-any.whl
- Upload date:
- Size: 37.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce21e47a056768a868f8681774eb6e09cc91560975b8a40e1e7b22a042474809
|
|
| MD5 |
967d4fa5d3409747de7c2749775970ed
|
|
| BLAKE2b-256 |
98f916f19bc8239952557ae646004dec4e11930aba588e805787d8ee5f8fdec9
|