Crates.io | nimiq_rpc |
lib.rs | nimiq_rpc |
version | 0.5.0 |
source | src |
created_at | 2019-12-29 19:50:46.042283 |
updated_at | 2024-11-08 16:29:00.879706 |
description | Nimiq RPC client for Rust |
homepage | |
repository | https://github.com/nimiq-community/rust-client |
max_upload_size | |
id | 193305 |
size | 62,240 |
Rust implementation of the Nimiq RPC client specs.
A Nimiq RPC client library in Rust. This client library implements the Nimiq RPC specification.
The client uses the jsonrpsee
library to handle JSON-RPC 2.0 requests and responses. For more information about this
library see the jsonrpsee HTTP client documentation.
use nimiq_rpc::Client;
#[tokio::main]
async fn main() {
let client = Client::new("http://seed-host.com:8648/".to_string());
// If your node uses credentials
let client = Client::new_with_credentials("http://seed-host.com:8648/".to_string(), "user".to_string(), "password".to_string());
println!("{:?}", client.accounts().await.unwrap());
println!("{:?}", client.block_number().await.unwrap());
println!("{:?}", client.hashrate().await.unwrap());
println!("{:?}", client.log("*", "log").await.unwrap());
}
Docs.rs link to the official crate documentation. And check out the Nimiq RPC specs for details.
Add the crate to your Cargo.toml
file.
This implementation was originally contributed by Eligioo.
Please send your contributions as pull requests. Refer to the issue tracker for ideas.