Metadata-Version: 2.4
Name: near-state
Version: 1.0.29317
Summary: PyPI Package - near-state
License: MIT
Project-URL: Homepage, https://github.com/worksOnMyFridge/near-state
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: requests<3.0,>=2.31
Requires-Dist: aiohttp<4.0,>=3.9

# 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
