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
```python
from pyonear.crypto import InMemorySigner, KeyType from pyonear.accountid import AccountId from pyonear.cryptohash import CryptoHash from pyonear.transaction import Transaction, TransferAction signer = InMemorySigner.fromrandom(AccountId("alice.near"), KeyType.ED25519) signerid = AccountId("alice.near") signer = InMemorySigner.fromrandom(signerid, KeyType.ED25519) publickey = signer.publickey nonce = 0 receiverid = AccountId("bob.near") blockhash = CryptoHash.default() # replace with a real blockhash actions = [TransferAction(1000000)] transaction = Transaction(signerid, publickey, nonce, receiverid, blockhash, 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