2

https://github.com/paritytech/subxt/blob/master/subxt/examples/tx_basic.rs

I want to call a function in my substrate pallet. I am using the

  • substrate-node-template
  • subxt
  • subxt_signer
use subxt::{OnlineClient, PolkadotConfig};
use subxt_signer::sr25519::dev;

#[subxt::subxt(runtime_metadata_path = "./src/artifacts/metadata.scale")]
pub mod polkadot {}
{
   // ...

   let account = dev::alice();
   let call = polkadot::tx().template_module().do_something(32);
   api.tx()
      .sign_and_submit_then_watch_default(&call, &account)
      .await
      .unwrap();
      
  // ...
}

but sign_and_submit_then_watch_default is giving error for &account. This is the error that I get

the trait bound `subxt_signer::sr25519::Keypair: subxt::tx::Signer<PolkadotConfig>` is not satisfied
the trait `subxt::tx::Signer<PolkadotConfig>` is not implemented for `subxt_signer::sr25519::Keypair`

I have tried using sp_core and changing versions but nothing seems to work.

My current versions are:

subxt = "0.31.0"
subxt-signer = "0.31.0"
3
  • 1
    Could you run a cargo tree -i subxt and a cargo tree -i subxt-signer in your example and report back the result? The likely explanation for this sort of mismatch is that the versions of subxt and subxt-signer are not in fact both 0.31.
    – jsdw
    Aug 15 at 10:20
  • @jsdw For both, the versions are the same. subxt-signer v0.31.0 || subxt v0.31.0
    – Haider
    Aug 15 at 12:01
  • Aha, I forgot about that "subxt" feature flag :)
    – jsdw
    Aug 16 at 12:24

1 Answer 1

3

I found the solution to the problem. In my case, I needed to make changes to Cargo.toml.

subxt-signer = { version = "0.31.0", features = ["subxt"]}

I had to add features = ["subxt"] to make it work.

Your Answer

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

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