I'm trying to call the do_something function in template_pallet runtime. I'm running locally the node substrate version : 4.0.0-dev-2ad9b78c7b5

I'm trying to send an extrinsics from Rust code using substrate-api-client, here is my code:

let client = WsRpcClient::with_default_url();
                let mut api = Api::<AssetRuntimeConfig, _>::new(client).unwrap();

                let signer = AccountKeyring::Alice.pair();

                let version = api.get_system_version().unwrap();
                println!("Runtime version {} running...", version);

                // Obtenez les métadonnées du runtime
                let metadata = api.metadata();
                for pallet in metadata.pallets() {
                    println!("{}", pallet.name());
                    println!("     {:?}", pallet.print_calls())

                let function_name = "do_something";
                let pallet = "TemplateModule";
                let something: u32 = 42;

                let xt = compose_extrinsic!(&api, pallet, function_name, something);
                match xt {
                    Some(extrinsic) => {
                        match api.submit_and_watch_extrinsic_until(extrinsic, XtStatus::InBlock) {
                            Ok(result) => {
                                if let Some(block_hash) = result.block_hash {
                                    println!("[+] Bloc Hash is: {:?}", block_hash);
                                } else {
                                    eprintln!("No Hash returned");
                            Err(e) => eprintln!("Err: {:?}", e),
                    None => {
                        eprintln!("Impossible to load the extrinsinc");

I got a panic

Err: RpcClient(ExtrinsicFailed("Unexpected Response: {\"jsonrpc\":\"2.0\",\"error\":{\"code\":1002,\"message\":\"Verification Error: Runtime error: Execution fai
led: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed\\nWASM backtrace:\\nerror while executing at wasm backtrace:\\n    0: 0x7d
84b - node_template_runtime.wasm!rust_begin_unwind\\n    1: 0x2422 - node_template_runtime.wasm!core::panicking::panic_fmt::h6cdc99c0b517ca33\\n    2: 0x23f16 - 
node_template_runtime.wasm!TaggedTransactionQueue_validate_transaction\",\"data\":\"RuntimeApi(\\\"Execution failed: Execution aborted due to trap: wasm trap: wa
sm `unreachable` instruction executed\\\\nWASM backtrace:\\\\nerror while executing at wasm backtrace:\\\\n    0: 0x7d84b - node_template_runtime.wasm!rust_begin
_unwind\\\\n    1: 0x2422 - node_template_runtime.wasm!core::panicking::panic_fmt::h6cdc99c0b517ca33\\\\n    2: 0x23f16 - node_template_runtime.wasm!TaggedTransactionQueue_validate_transaction\\\")\"},\"id\":\"1\"}"))

in BC node side panicked at substrate_node/runtime/src/lib.rs:340:1: Bad input data provided to validate_transaction: Codec error

Need some help. Thanks a lot.

  • Which repo is this from? Is it substrate-node-template?
    – Ronin
    Commented Mar 31 at 10:50
  • Yes it is, exactly Commented Mar 31 at 14:46
  • Could you try using subxt? There have been many minor issues with substrate-api-client, so after attempting to debug it, I switched to subxt.
    – AurevoirXavier
    Commented Apr 1 at 1:58
  • 1
    That was I'm trying, is it possible to give me a sample with subxt ? I don't see any easy sample code for that Commented Apr 1 at 8:52


Your Answer

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