Crate unc_jsonrpc_client

Source
Expand description

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

§Layout

Each one the valid public JSON RPC methods are pre-defined in specialized modules within the methods module.

Inside every method module (e.g methods::query) there’s;

Calling a constructed request on a client returns with the response and error types for that method.

§Examples

  1. Request server status from testnet RPC

    use unc_jsonrpc_client::{methods, JsonRpcClient};
    
    let client = JsonRpcClient::connect("https://rpc.testnet.unc.org");
    
    let request = methods::status::RpcStatusRequest; // no params
    
    // call a method on the server via the connected client
    let server_status = client.call(request).await?;
    
    println!("{:?}", server_status);
  2. Query transaction status from mainnet RPC

    use unc_jsonrpc_client::{methods, JsonRpcClient};
    use unc_jsonrpc_primitives::types::transactions::TransactionInfo;
    
    let client = JsonRpcClient::connect("https://archival-rpc.mainnet.unc.org");
    
    let tx_status_request = methods::tx::RpcTransactionStatusRequest {
        transaction_info: TransactionInfo::TransactionId {
            tx_hash: "9FtHUFBQsZ2MG77K3x3MJ9wjX3UT8zE1TczCrhZEcG8U".parse()?,
            sender_account_id: "miraclx.unc".parse()?,
        },
    };
    
    let tx_status = client.call(tx_status_request).await?;
    
    println!("{:?}", tx_status);

Modules§

auth
Helpers for client authentication.
errors
Error types.
header
Client headers.
methods
This module contains all the RPC methods.

Structs§

JsonRpcClient
A unc JSON RPC Client.
JsonRpcClientConnector
unc JSON RPC client connector.

Constants§

UNC_MAINNET_ARCHIVAL_RPC_URL
UNC_MAINNET_RPC_URL
UNC_TESTNET_ARCHIVAL_RPC_URL
UNC_TESTNET_RPC_URL

Traits§

AsUrl

Type Aliases§

MethodCallResult