All Projects → near → near-jsonrpc-client-rs

near / near-jsonrpc-client-rs

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
Lower-level API for interfacing with the NEAR Protocol via JSONRPC.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to near-jsonrpc-client-rs

Hprose Nodejs
Hprose is a cross-language RPC. This project is Hprose 2.0 for Node.js
Stars: ✭ 297 (+828.13%)
Mutual labels:  rpc, rpc-client
Hprose Golang
Hprose is a cross-language RPC. This project is Hprose for Golang.
Stars: ✭ 1,143 (+3471.88%)
Mutual labels:  rpc, rpc-client
Rpc Websockets
JSON-RPC 2.0 implementation over WebSockets for Node.js and JavaScript/TypeScript
Stars: ✭ 344 (+975%)
Mutual labels:  rpc, rpc-client
hrpc
Common interface definition based rpc implementation
Stars: ✭ 21 (-34.37%)
Mutual labels:  rpc, rpc-client
Hprose Objc
Hprose is a cross-language RPC. This project is Hprose 2.0 Client for Objective-C
Stars: ✭ 130 (+306.25%)
Mutual labels:  rpc, rpc-client
rony
Fast and Scalable RPC Framework
Stars: ✭ 41 (+28.13%)
Mutual labels:  rpc, rpc-client
rpc
RPC-like client-service implementation over messaging queue
Stars: ✭ 26 (-18.75%)
Mutual labels:  rpc, rpc-client
Hprose Java
Hprose is a cross-language RPC. This project is Hprose 2.0 for Java
Stars: ✭ 542 (+1593.75%)
Mutual labels:  rpc, rpc-client
Hprose Delphi
Hprose is a cross-language RPC. This project is Hprose 2.0 for Delphi and FreePascal
Stars: ✭ 100 (+212.5%)
Mutual labels:  rpc, rpc-client
Multirpc
A Discord rich presence manager app with a cool GUI and support for custom status and multiple profiles
Stars: ✭ 94 (+193.75%)
Mutual labels:  rpc, rpc-client
cli
Command Line Interface for @imqueue
Stars: ✭ 20 (-37.5%)
Mutual labels:  rpc, rpc-client
Hprose Php
Hprose is a cross-language RPC. This project is Hprose 3.0 for PHP
Stars: ✭ 1,952 (+6000%)
Mutual labels:  rpc, rpc-client
hprose-as3
Hprose for ActionScript 3.0
Stars: ✭ 18 (-43.75%)
Mutual labels:  rpc, rpc-client
Armeria
Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
Stars: ✭ 3,392 (+10500%)
Mutual labels:  rpc, rpc-client
nodejs grpc
GRPC based API CRUD using Nodejs at both server and client side
Stars: ✭ 17 (-46.87%)
Mutual labels:  rpc, rpc-client
Rpcx Java
rpcx implementation in Java for server side and client side
Stars: ✭ 71 (+121.88%)
Mutual labels:  rpc, rpc-client
Hprose Js
Hprose is a cross-language RPC. This project is Hprose 2.0 RPC for JavaScript
Stars: ✭ 133 (+315.63%)
Mutual labels:  rpc, rpc-client
Hprose Html5
Hprose is a cross-language RPC. This project is Hprose 2.0 Client for HTML5
Stars: ✭ 237 (+640.63%)
Mutual labels:  rpc, rpc-client
thrift-typescript
Generate TypeScript from Thrift IDL files
Stars: ✭ 129 (+303.13%)
Mutual labels:  rpc
RRQMSocket
TouchSocket是.Net(包括 C# 、VB.Net、F#)的一个整合性的、超轻量级的网络通信框架。包含了 tcp、udp、ssl、http、websocket、rpc、jsonrpc、webapi、xmlrpc等一系列的通信模块。一键式解决 TCP 黏分包问题,udp大数据包分片组合问题等。使用协议模板,可快速实现「固定包头」、「固定长度」、「区间字符」等一系列的数据报文解析。
Stars: ✭ 286 (+793.75%)
Mutual labels:  rpc

near-jsonrpc-client

Lower-level API for interfacing with the NEAR Protocol via JSONRPC.

Crates.io Documentation MIT or Apache 2.0 Licensed Dependency Status

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.

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 for a comprehensive list of helpful demos. You can run the examples with cargo. For example: cargo run --example view_account.

For all intents and purposes, the predefined structures in methods should suffice, if you find that they don't or you crave extra flexibility, well, you can opt in to use the generic constructor methods::any() with the any feature flag.

In this example, we retrieve only the parts from the genesis config response that we care about.

# in Cargo.toml
near-jsonrpc-client = { ..., features = ["any"] }
use serde::Deserialize;
use serde_json::json;

use near_jsonrpc_client::{methods, JsonRpcClient};
use near_primitives::serialize::dec_format;
use near_primitives::types::*;

#[derive(Debug, Deserialize)]
struct PartialGenesisConfig {
    protocol_version: ProtocolVersion,
    chain_id: String,
    genesis_height: BlockHeight,
    epoch_length: BlockHeightDelta,
    #[serde(with = "dec_format")]
    min_gas_price: Balance,
    #[serde(with = "dec_format")]
    max_gas_price: Balance,
    #[serde(with = "dec_format")]
    total_supply: Balance,
    validators: Vec<AccountInfo>,
}

impl methods::RpcHandlerResponse for PartialGenesisConfig {}

let mainnet_client = JsonRpcClient::connect("https://rpc.mainnet.near.org");

let genesis_config_request = methods::any::<Result<PartialGenesisConfig, ()>>(
    "EXPERIMENTAL_genesis_config",
    json!(null),
);

let partial_genesis = mainnet_client.call(genesis_config_request).await?;

println!("{:#?}", partial_genesis);

By default, near-jsonrpc-client uses native-tls. On Linux, this introduces a dependency on the system openssl library. In some situations, for example when cross-compiling, it can be problematic to depend on non-Rust libraries.

If you wish to switch to an all-Rust TLS implementation, you may do so using the rustls-tls feature flag. Note that the native-tls feature is enabled by default. Therefore, to disable it and use rustls-tls instead, you must also use default-features = false. The default auth feature must then be declared explicitly.

# in Cargo.toml
near-jsonrpc-client = { ..., default-features = false, features = ["auth","rustls-tls"] }

Releasing

Versioning and releasing of this crate is automated and managed by custom fork of 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 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 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

at your option.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].