createSignAndSendTx static method
Future<TransactionResult>
createSignAndSendTx(
- List<
StdMsg> msgs, - Wallet wallet, {
- StdFee? fee,
- BroadcastingMode? mode,
- Client? client,
Creates a transaction having the given msgs,
signs it with the given Wallet and sends it to the blockchain.
Optional parameters can be fee and broadcasting mode,
that can be of type "sync", "async" or "block".
Implementation
static Future<TransactionResult> createSignAndSendTx(
List<StdMsg> msgs,
Wallet wallet, {
StdFee? fee,
BroadcastingMode? mode,
http.Client? client,
}) async {
// Set values for optional parameters
final msgsNumber = msgs.isNotEmpty ? msgs.length : 1;
fee = fee ??
calculateDefaultFee(
msgsNumber: msgsNumber,
fee: defaultAmount,
denom: defaultDenom,
gas: defaultGas,
);
mode = mode ?? BroadcastingMode.SYNC;
final stdTx = TxBuilder.buildStdTx(stdMsgs: msgs, fee: fee);
final signedTx = await TxSigner.signStdTx(
wallet: wallet,
stdTx: stdTx,
client: client,
);
return TxSender.broadcastStdTx(
wallet: wallet,
stdTx: signedTx,
mode: mode.value,
);
}