near-api-lib 0.1.0-alpha

A Rust library for seamless NEAR blockchain development, offering tools for account management, transaction operations, and blockchain queries.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use near_api_lib::accounts::view_state;
use near_api_lib::JsonRpcProvider;
use near_primitives::types::AccountId;
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    env_logger::init();

    let provider = Arc::new(JsonRpcProvider::new("https://rpc.testnet.near.org"));

    let contract_id: AccountId = "contract.near-api-rs.testnet".parse::<AccountId>()?;

    let result = view_state(provider, contract_id, None).await;
    println!("response: {:#?}", result);

    Ok(())
}