Skip to main content

Python bindings for NEAR Rust primitives.

Project description


build PyPI version License: MIT Code style: black

Pyonear

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.

Installation

pip install pyonear

Example usage

>>> 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='

Development

Pre-requisites: Rust >= 1.65, Python >= 3.7, Poetry >= 1.1.14

Steps

  1. poetry install (one time only)
  2. poetry shell
  3. maturin develop
  4. pytest
  5. make lint

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

pyonear-0.1.0.tar.gz (59.0 kB view hashes)

Uploaded Source

Built Distributions

pyonear-0.1.0-cp37-abi3-win_amd64.whl (2.3 MB view hashes)

Uploaded CPython 3.7+ Windows x86-64

pyonear-0.1.0-cp37-abi3-musllinux_1_2_x86_64.whl (3.7 MB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.2+ x86-64

pyonear-0.1.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.5 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64

pyonear-0.1.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (4.1 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ s390x

pyonear-0.1.0-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (4.0 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64

pyonear-0.1.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.5 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

pyonear-0.1.0-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (5.0 MB view hashes)

Uploaded CPython 3.7+ macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page