PyPI Package - near-state
Project description
near-state
Async Python client for querying NEAR Protocol on-chain state via RPC.
Requirements
Python 3.9+
Installation
pip install near-state
Quick Start
import asyncio from near_state import NearStateClient
async def main(): async with NearStateClient() as client: balance = await client.get_balance_near("wrap.near") print(f"Balance: {balance} NEAR")
asyncio.run(main())
Usage
Account & Balance
import asyncio from near_state import NearStateClient
async def main(): async with NearStateClient() as client: account = await client.get_account("wrap.near") print(account)
yocto = await client.get_balance("wrap.near")
print(f"yoctoNEAR: {yocto}")
near = await client.get_balance_near("wrap.near")
print(f"NEAR: {near}")
asyncio.run(main())
Contract State
import asyncio from near_state import NearStateClient
async def main(): async with NearStateClient() as client: state = await client.get_state("wrap.near") print(state)
asyncio.run(main())
Blocks & Transactions
import asyncio from near_state import NearStateClient
async def main(): async with NearStateClient() as client: block = await client.get_block("final") print(block)
tx = await client.get_transaction(
"tx-hash-here", "sender.near"
)
print(tx)
asyncio.run(main())
Access Keys & Network
import asyncio from near_state import NearStateClient
async def main(): async with NearStateClient() as client: key = await client.get_access_key("wrap.near", "ed25519:pubkey") print(key)
keys = await client.get_access_key_list("wrap.near")
print(keys)
validators = await client.get_validators()
print(validators)
info = await client.get_network_info()
print(info)
asyncio.run(main())
Custom RPC Endpoint
from near_state import NearStateClient
client = NearStateClient(rpc_url="https://rpc.testnet.near.org")
API Reference
| Method | Description |
|---|---|
get_account(account_id) |
Account info |
get_balance(account_id) |
Balance in yoctoNEAR |
get_balance_near(account_id) |
Balance in NEAR |
get_state(account_id, prefix_base64) |
Contract state |
get_block(block_id) |
Block details |
get_transaction(tx_hash, sender_id) |
Transaction details |
get_validators() |
Current validators |
get_access_key(account_id, public_key) |
Single access key |
get_access_key_list(account_id) |
All access keys |
get_network_info() |
Network info |
License
MIT
Project details
Release history Release notifications | RSS feed
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 near_state-1.0.29317.tar.gz.
File metadata
- Download URL: near_state-1.0.29317.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8de500cc626aec3add595b721a87a3821f8fd6f12749c05ca317e904918ecef9
|
|
| MD5 |
7106509196f39a2a7c700f8d184091c4
|
|
| BLAKE2b-256 |
26f0829db7a8d338ce874b3cbb7b711452a52a3371c51fb67bf764de1c1dfdf3
|
File details
Details for the file near_state-1.0.29317-py3-none-any.whl.
File metadata
- Download URL: near_state-1.0.29317-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbb3c41833da55d4e2f67f3c54b1f7aa3e803e46051b7dbddb2cdd6d63893100
|
|
| MD5 |
3fd405bd3f6dd77fdf88c9f5e05fe5e2
|
|
| BLAKE2b-256 |
cae43ee5fc74b4da21b043f3403605d099b8e09f74be90007372093fc9950ecb
|