SingleSigner::with_nonce
Consume self and return a SingleSigner with nonce defined.
Signature
impl<S: Secret, I: MaybeDefined<UserIndex>> SingleSigner<S, I, Undefined<Nonce>> {
pub fn with_nonce(self, nonce: Nonce) -> SingleSigner<S, I, Defined<Nonce>>;
}Example
use {
anyhow::Result,
dango_sdk::{Secp256k1, SingleSigner},
grug::Addr,
std::str::FromStr,
};
fn build() -> Result<SingleSigner<Secp256k1, _, _>> {
let signer = SingleSigner::new(
Addr::from_str("0x0000000000000000000000000000000000000000")?,
Secp256k1::new_random(),
)
.with_nonce(0);
Ok(signer)
}Parameters
nonce — Nonce. The next unused nonce for this account.
Returns
SingleSigner<S, I, Defined<Nonce>> — the same signer with nonce defined.
Notes
- Use
0for a brand-new account that has never signed a transaction. Otherwise callwith_query_nonce(orquery_next_noncedirectly). - A signer with
Defined<UserIndex> + Defined<Nonce>implementsSigner.
See also
with_query_nonce— fetch the next nonce from the chain.query_next_nonce.