'Cant submit a Substrate chain extrinsic signed by generated key pair

I was trying to submit items (extrinsics) to my Substrate blockchain instance, but it keeps getting rejected. I use the key pair I generate using from_string function from sp_core::crypto::Pair, but the extrinsics I signed using this key pair does not get submitted to the chain. The key pair that gets generated is the same type from Substrate's/Parity's AccountKeyRing module, but I keep getting InvalidHexString error.

I was able to submit extrinsics signed by AccountKeyring::Bob.pair(). I'm confident the Key Pair I generated is the same type as AccountKeyring::Bob.pair(), but its not working for me for some reason. The secret phrase I provide to the from_string should be valid because it came from subkey tool

Anyways, I get this error in my external client:

thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidHexString(InvalidStringLength)', src/services/route_actions/extrinsic_submitters.rs:25:73

The secret phrase I provided to the from_string function are valid since this is generated from subkey tool (NOT USED IN PROD). This is my code snippet

  let priv_key: String = "endorse doctor arch helmet master dragon wild favorite property mercy vault maze".to_owned();
  let from = Pair::from_string(&priv_key[..], None).unwrap();
  //let from = AccountKeyring::Bob.pair();
  let api = Api::new(client).map(|api| api.set_signer(from)).unwrap();
  ....
  extrinsic_submitters::submit_to_save_item(api, incoming_item, now, datetime);

This is the code for the submission of the extrinsic I have:

#[allow(clippy::redundant_clone)]
    let xt: UncheckedExtrinsicV4<_> = compose_extrinsic!(
      api.clone(),
      "Auditor",
      "save_audit_item",
      now.to_rfc3339().to_string().into_bytes()
    );
  
    println!("[+] Composed Extrinsic:\n {:?}\n", xt);
    
    // send and watch extrinsic until finalized
    let blockh = api.send_extrinsic(xt.hex_encode(), XtStatus::InBlock).unwrap();

the error is thrown at:

let blockh = api.send_extrinsic(xt.hex_encode(), XtStatus::InBlock).unwrap();

This is the subkey tool cmd I used: subkey generate

Secret phrase:       endorse doctor arch helmet master dragon wild favorite property mercy vault maze
  Network ID:        substrate
  Secret seed:       0x78b8fbbbea218509c00d3531e72128d4eae54089f15deb24d721e30b351733ad
  Public key (hex):  0x14e121f6e6cc2891cbbd5f6692e3724672d13e93a3562e3905d4310c2ba1c510
  Account ID:        0x14e121f6e6cc2891cbbd5f6692e3724672d13e93a3562e3905d4310c2ba1c510
  Public key (SS58): 5CY5hAGkTB7RZrouimGJ3S7zTDtnE6yg7z41DHrQeBcoc1PN
  SS58 Address:      5CY5hAGkTB7RZrouimGJ3S7zTDtnE6yg7z41DHrQeBcoc1PN

This is the error I get from my node:

Failed to submit extrinsic: Transaction pool error: Invalid transaction validity: InvalidTransaction::Payment

It looks like there may be multiple reasons why the transaction is invalid, such as too high nonce, not enough funds in the account, and signature is invalid. I generated the keypair item via the info provided by subkey, and the signature should be valid, but I am not certain for sure since the error message is pretty general. My dispatchable function shouldn't cost anything because it has #[pallet::weight(0)]. Any tips how to expand on this InvalidTransaction::Payment error?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source