https://github.com/near/near-jsonrpc-client-rs
Lower-level API for interfacing with the NEAR Protocol via JSONRPC.
https://github.com/near/near-jsonrpc-client-rs
blockchain jsonrpc near-protocol rpc rpc-client rust
Last synced: 10 months ago
JSON representation
Lower-level API for interfacing with the NEAR Protocol via JSONRPC.
- Host: GitHub
- URL: https://github.com/near/near-jsonrpc-client-rs
- Owner: near
- License: apache-2.0
- Created: 2021-08-18T11:21:54.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-06-18T04:00:45.000Z (12 months ago)
- Last Synced: 2025-07-30T22:41:58.373Z (11 months ago)
- Topics: blockchain, jsonrpc, near-protocol, rpc, rpc-client, rust
- Language: Rust
- Homepage: https://docs.rs/near-jsonrpc-client
- Size: 378 KB
- Stars: 51
- Watchers: 11
- Forks: 43
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# near-jsonrpc-client
Lower-level API for interfacing with the NEAR Protocol via JSONRPC.
[](https://crates.io/crates/near-jsonrpc-client)
[](https://docs.rs/near-jsonrpc-client)
[](#license)
[](https://deps.rs/crate/near-jsonrpc-client/0.5.1)
## Usage
Each one of the valid JSON RPC methods are defined in the `methods` module.
For instance, to make a `tx` request, you start with the `tx` module
and construct a request using the `methods::tx::RpcTransactionStatusRequest` struct.
```rust
use near_jsonrpc_client::{methods, JsonRpcClient};
use near_jsonrpc_primitives::types::transactions::TransactionInfo;
let mainnet_client = JsonRpcClient::connect("https://archival-rpc.mainnet.near.org");
let tx_status_request = methods::tx::RpcTransactionStatusRequest {
transaction_info: TransactionInfo::TransactionId {
hash: "9FtHUFBQsZ2MG77K3x3MJ9wjX3UT8zE1TczCrhZEcG8U".parse()?,
account_id: "miraclx.near".parse()?,
},
};
// call a method on the server via the connected client
let tx_status = mainnet_client.call(tx_status_request).await?;
println!("{:?}", tx_status);
```
Check out [`the examples folder`](https://github.com/near/near-jsonrpc-client-rs/tree/master/examples) for a comprehensive list of helpful demos. You can run the examples with `cargo`. For example: `cargo run --example view_account`.
## Releasing
Versioning and releasing of this crate is automated and managed by [custom fork](https://github.com/miraclx/cargo-workspaces/tree/grouping-versioning-and-exclusion) of [`cargo-workspaces`](https://github.com/pksunkara/cargo-workspaces). To publish a new version of this crate, you can do so by bumping the `version` under the `[workspace.metadata.workspaces]` section in the [package manifest](https://github.com/near/near-jsonrpc-client-rs/blob/master/Cargo.toml) and submit a PR.
We have CI Infrastructure put in place to automate the process of publishing all crates once a version change has merged into master.
However, before you release, make sure the [CHANGELOG](https://github.com/near/near-jsonrpc-client-rs/blob/master/CHANGELOG.md) is up to date and that the `[Unreleased]` section is present but empty.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as below, without any additional terms or conditions.
## License
Licensed under either of
* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or )
* MIT license
([LICENSE-MIT](LICENSE-MIT) or )
at your option.