I'm trying to call my node's chain_getBlock RPC method. I expect to provide a block hash, and get back a complete block.

For starters, I've confirmed that the call I plan to make works as expected when just using curl directly.

# This call works
$ curl -H "Content-Type:application/json;charset=utf-8" -d '{"jsonrpc":"2.0", "id":1, "method":"chain_getBlock", "params": ["505914d65fcf1049e630441127ca8cba338ff7f048a06508e2f987514125d481"]}'


Then I try to make the exact same call from Rust code, and I get an error. I'm not clear how my two requests are different or how to debug further.

use jsonrpsee::{

async fn main() -> anyhow::Result<()> {
    let client = HttpClientBuilder::default().build("http://localhost:9933")?;

    let s = String::from("505914d65fcf1049e630441127ca8cba338ff7f048a06508e2f987514125d481");
    let params = rpc_params!{s};
    let rpc_response: Result<Option<String>, _> = client.request("chain_getBlock", params).await;

    match rpc_response {
        Ok(Some(s)) => println!("ok some {s}"),
        Ok(None) => println!("ok none"),
        Err(e) => println!("%%%Error: {e:?}"),


The output from that Rust code is: %%%Error: ParseError(Error("invalid type: map, expected a string", line: 1, column: 0))

1 Answer 1


As the error said. The result is a map.

let rpc_response: Result<Option<serde_json::Value>, _> = client.request("chain_getBlock", params).await;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.