Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue parameterizing a custom Nonce #1558

Closed
Fiono11 opened this issue Apr 26, 2024 · 1 comment
Closed

Issue parameterizing a custom Nonce #1558

Fiono11 opened this issue Apr 26, 2024 · 1 comment

Comments

@Fiono11
Copy link

Fiono11 commented Apr 26, 2024

I am trying to run the following example from https://docs.rs/subxt/latest/subxt/book/usage/transactions/index.html#constructing-a-transaction-payload:

#![allow(missing_docs)]
use subxt::config::polkadot::PolkadotExtrinsicParamsBuilder as Params;
use subxt::{OnlineClient, PolkadotConfig};
use subxt_signer::sr25519::dev;

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

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a new API client, configured to talk to Polkadot nodes.
    let api = OnlineClient::<PolkadotConfig>::new().await?;

    // Build a balance transfer extrinsic.
    let dest = dev::bob().public_key().into();
    let tx = polkadot::tx().balances().transfer_allow_death(dest, 10_000);

    let latest_block = api.blocks().at_latest().await?;

    // Configure the transaction parameters; we give a small tip and set the
    // transaction to live for 32 blocks from the `latest_block` above.
    let tx_params = Params::new()
        .tip(1_000)
        .mortal(latest_block.header(), 32)
        .build();

    // submit the transaction:
    let from = dev::alice();
    let hash = api.tx().sign_and_submit(&tx, &from, tx_params).await?;
    println!("Balance transfer extrinsic submitted with hash : {hash}");

    Ok(())
}

But with the following params instead:

let tx_params = Params::new()
    .nonce(100)
    .build();

When I try to submit the transaction it gets stuck without any error. Any idea what may cause that?

@Fiono11
Copy link
Author

Fiono11 commented Apr 27, 2024

Managed to solve this by requesting the subsequent nonce to the legacy RPC. But it still should work with a random nonce, just like the one that comes from the last finalized block with the new RPC, right?

@Fiono11 Fiono11 closed this as completed Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant