SingleSigner::unsigned_transaction
Build the UnsignedTx for a set of messages without producing a signature.
Signature
impl<S: Secret> Signer for SingleSigner<S> {
fn unsigned_transaction(
&self,
msgs: NonEmpty<Vec<Message>>,
chain_id: &str,
) -> grug::StdResult<grug::UnsignedTx>;
}From impl Signer (requires Defined<UserIndex> + Defined<Nonce>).
Example
use {
anyhow::Result,
dango_sdk::{HttpClient, SingleSigner},
grug::{Coins, Message, NonEmpty, QueryClient, Signer},
};
async fn estimate(
http: &HttpClient,
signer: &SingleSigner<impl dango_sdk::Secret>,
) -> Result<u64> {
let messages = NonEmpty::new(vec![
Message::transfer(grug::Addr::mock(0), Coins::one("bridge/usdc", 1_u128)?)?,
])?;
let unsigned = signer.unsigned_transaction(messages, "dango-1")?;
Ok(http.simulate(unsigned).await?.gas_used as u64)
}Parameters
msgs — NonEmpty<Vec<Message>>. The messages to include in the transaction.
chain_id — &str. The target chain id (e.g. "dango-1").
Returns
UnsignedTx — sender, msgs, and a JSON-encoded Metadata { chain_id, user_index, nonce, expiry: None }.
Notes
- The metadata uses the signer's current
user_indexandnonce— values thatsign_transactionwould consume. - Pair with
QueryClient::simulatefor gas estimation; the simulation runs without nonce consumption.
See also
sign_transaction— produce a signedTx.HttpClient::simulate.