# Tx helper
Allows to easily perform common transaction operations.
# Provided operations
- Creates a transaction having the given
msgs
, signs it with the givenWallet
and sends it to the blockchain. Optional parameters can befee
and broadcastingmode
, that can be of type "sync", "async" or "block".
static Future<TransactionResult> createSignAndSendTx(
List<StdMsg> msgs,
Wallet wallet, {
StdFee? fee,
BroadcastingMode? mode,
http.Client? client,
})
1
2
3
4
5
6
7
2
3
4
5
6
7
# Usage examples
final info = NetworkInfo(
bech32Hrp: 'did:com:',
lcdUrl: 'http://localhost:1317',
);
final mnemonic = ['will', 'hard', ..., 'man'];
final wallet = Wallet.derive(mnemonic, info);
final deposit = StdCoin(denom: 'ucommercio', amount: '10');
final msgDeposit = MsgSend(
fromAddress: wallet.bech32Address,
toAddress: "did:com:14ttg3eyu88jda8udvxpwjl2pwxemh72w0grsau",
amount: [deposit],
);
try {
await TxHelper.createSignAndSendTx([msgDeposit], wallet);
} catch (error) {
throw error;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20