Skip to main content

MsgSend


_80
import {
_80
LCDClient,
_80
MnemonicKey,
_80
MsgMultiSend,
_80
StdTx,
_80
Account,
_80
} from "@terra-money/terra.js";
_80
_80
const {
_80
TESTNET_LCD_URL = "http://localhost:1317",
_80
TESTNET_CHAIN_ID = "localterra",
_80
} = process.env;
_80
_80
async function main() {
_80
const client = new LCDClient({
_80
URL: TESTNET_LCD_URL,
_80
chainID: TESTNET_CHAIN_ID,
_80
gasPrices: "0.15uluna",
_80
gasAdjustment: 1.4,
_80
});
_80
_80
const keys = {
_80
test1: new MnemonicKey({
_80
mnemonic:
_80
"notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius",
_80
}),
_80
test2: new MnemonicKey({
_80
mnemonic:
_80
"quality vacuum heart guard buzz spike sight swarm shove special gym robust assume sudden deposit grid alcohol choice devote leader tilt noodle tide penalty",
_80
}),
_80
test3: new MnemonicKey({
_80
mnemonic:
_80
"symbol force gallery make bulk round subway violin worry mixture penalty kingdom boring survey tool fringe patrol sausage hard admit remember broken alien absorb",
_80
}),
_80
};
_80
_80
const wallet = client.wallet(keys.test1);
_80
const output = new MsgMultiSend.Output(
_80
"terra199vw7724lzkwz6lf2hsx04lrxfkz09tg8dlp6r",
_80
"1000000uluna"
_80
);
_80
_80
const tx = await wallet.createTx({
_80
msgs: [
_80
new MsgMultiSend(
_80
[
_80
new MsgMultiSend.Input(keys.test1.accAddress, "1000000uluna"),
_80
new MsgMultiSend.Input(keys.test2.accAddress, "1000000uluna"),
_80
new MsgMultiSend.Input(keys.test3.accAddress, "1000000uluna"),
_80
],
_80
[output, output, output]
_80
),
_80
],
_80
});
_80
_80
const signatures = await Promise.all(
_80
["test1", "test2", "test3"].map(async (keyName) => {
_80
const key = keys[keyName] as MnemonicKey;
_80
const acc = (await client.auth.accountInfo(key.accAddress)) as Account;
_80
_80
tx.account_number = acc.account_number;
_80
tx.sequence = acc.sequence;
_80
_80
return key.createSignature(tx);
_80
})
_80
);
_80
_80
const stdTx = new StdTx(tx.msgs, tx.fee, signatures, tx.memo);
_80
_80
await client.tx
_80
.broadcastSync(stdTx)
_80
.then((result) => {
_80
console.log(result);
_80
})
_80
.catch((err) => {
_80
console.error(err.message);
_80
});
_80
}
_80
_80
main().catch(console.error);