forked from silentnoname/cosmos-learn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-multiSend.js
39 lines (34 loc) · 1.11 KB
/
4-multiSend.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { SigningStargateClient } from "@cosmjs/stargate";
import pkg from '@cosmjs/launchpad';
async function multiSend(client, from, recipients) {
let ops = [];
for (let recipient of recipients) {
let msg = {
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
value: {
fromAddress: from,
toAddress: recipient,
amount: pkg.coins(10000, "uatom")
},
};
ops.push(msg);
}
const fee = {
amount: pkg.coins(800, "uatom"),
gas: "180000",
};
let result = await client.signAndBroadcast(from, ops, fee, '');
console.log("Broadcasting result:", result);
}
async function start() {
const mnemonic = "";//enter mnemonic
const addresses =[""];//enter addresses
const rpcEndpoint = "https://rpc.cosmos.network";
const wallet = await pkg.Secp256k1HdWallet.fromMnemonic(
mnemonic
);
const [account] = await wallet.getAccounts();
const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, wallet);
multiSend(client, account.address, addresses)
}
start();