Crates.io | pyonear |
lib.rs | pyonear |
version | 0.2.0 |
source | src |
created_at | 2023-01-24 14:00:28.140785 |
updated_at | 2023-01-24 14:58:13.969654 |
description | Python bindings for NEAR Rust primitives. |
homepage | |
repository | https://github.com/kevinheavey/pyonear |
max_upload_size | |
id | 766690 |
size | 187,856 |
pyonear
is a Python binding to the NEAR Rust API crates. It provides
fast and robust wrappers for building, signing and (de)serializing transactions.
The wrapped types come from the near-primitives,
near-crypto and
near-vm-errors crates.
pip install pyonear
>>> from pyonear.crypto import InMemorySigner, KeyType
>>> from pyonear.account_id import AccountId
>>> from pyonear.crypto_hash import CryptoHash
>>> from pyonear.transaction import Transaction, TransferAction
>>> signer = InMemorySigner.from_random(AccountId("alice.near"), KeyType.ED25519)
>>> signer_id = AccountId("alice.near")
>>> signer = InMemorySigner.from_random(signer_id, KeyType.ED25519)
>>> public_key = signer.public_key
>>> nonce = 0
>>> receiver_id = AccountId("bob.near")
>>> block_hash = CryptoHash.default() # replace with a real blockhash
>>> actions = [TransferAction(1_000_000)]
>>> transaction = Transaction(signer_id, public_key, nonce, receiver_id, block_hash, actions).sign(signer)
>>> transaction.to_base64()
'CgAAAGFsaWNlLm5lYXIA++M56uPzUi8ezkHqJBLjc7ZCzJk88zoIpF5XkjUM13kAAAAAAAAAAAgAAABib2IubmVhcgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAANAQg8AAAAAAAAAAAAAAAAAALK42W7t/vpUmDAgtChTUWEVvSE3cQZWRla8spN6KfNv9fWn16klROeblzH480b0a+NSL16YfnvWLnd2C9KLTQk='
Pre-requisites: Rust >= 1.65, Python >= 3.7, Poetry >= 1.1.14
poetry install
(one time only)poetry shell
maturin develop
pytest
make lint