What return type should I use in subxt to be able to parse the result from author_pendingExtrinsics?

I have implemented a wrapper call and returning a vector of OpaqueExtrinsic:

async fn author_pending_extrinsics(&self) -> Result<Vec<OpaqueExtrinsic>, subxt::Error> {
   self.rpc.request("author_pendingExtrinsics", rpc_params![]).await;

This is okay, but I need to get the signer and the nonce from the results. It should be possible as polkadot-js there is a type called Extrinsic with all the information I need.

Running the call in the polkadot-js web ui returns:

3: author.pendingExtrinsics: Vec<Extrinsic>
    isSigned: true
    method: {
      args: {
        dest: {
          Id: 4hNgHEdC6EZYHPFJrxFt19m3zBMbTb6ZErSbo9idCpX6n2zU
        value: 9,500,000,000,000
      method: transfer
      section: balances
    era: {
      ImmortalEra: 0x00
    nonce: 1
    signature: 0xbe779752c8893fc895cbca17b2b47b8fcde7627f1dd93d022354ba13d777f361befebc9f0862c5821c995ff1145d543114ea55fa89120d85b16815775f67658e
    signer: {
      Id: 4hNohKFDvDG8qf5SHPjhg3dhGFe4uRp136tm8eHNQ72xSYXB
    tip: 0

I have searched in the auto generated docs for my project(cargo doc --open) but could not find any suitable existing or auto generated type.

1 Answer 1


Currently, Subxt doesn't expose the things you'd need to be able to decode these in a sensible way.

If you wanted to try it anyway, you could take the following steps:

  1. Add the RPC method a definition like this to LegacyRpcMethods (or otherwise call it:
async fn author_pending_extrinsics(&self) -> Result<Vec<Bytes>, subxt::Error> {
   self.rpc.request("author_pendingExtrinsics", rpc_params![]).await;

(I'm sortof guessing but I think that's what you need)

  1. Run something like this (not really tested):
use subxt::{OnlineClient, PolkadotConfig};
use subxt::{

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let rpc_client = RpcClient::from_url("ws://localhost:9944").await?;
    let rpc_methods = LegacyRpcMethods::<PolkadotConfig>::new(rpc_client.clone());
    let api = OnlineClient::<PolkadotConfig>::from_rpc_client(rpc_client).await?;

    // Get pending exts:
    let pending_exts = rpc_methods.author_pending_extrinsics().await?;

    // Make them the right shape:
    let pending_exts = pending_exts.into_iter().map(|e| e.0).collect();

    // Feed them into our Extrinsics struct (this new fn would need to be made pub)
    let exts = Extrinsics::new(
        // Some internal cache object:
        // ExtrinsicPartTypeIds::new would need to be made pub too:
        <PolkadotConfig as Config>::Hash::random(),

    // from here you can do all of the usual stuff that Subxt can 
    // with extrinsics (iterate, decode them etc).


You can see that a couple of things need making public and it's hideous (because this isn't a public API).

Please open an issue in the Subxt repo if you'd like this to be a public interface and we can discuss the use case and talk there :)

  • The real problem I was trying to solve was about getting the nonce compensated for pending extrinsics, and we fixed it in this github.com/paritytech/subxt/pull/1250 @jsdw if you have a look at my other PR we will have some examples how to use it as well there.
    – Simson
    Nov 21 at 1:40
  • Ah ok great, I'm still catching up after some time off :)
    – jsdw
    Nov 21 at 11:37

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.