-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathsigned_msg_send.ts
48 lines (37 loc) · 1.23 KB
/
signed_msg_send.ts
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
40
41
42
43
44
45
46
47
48
import { coins, DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing";
import { defaultRegistryTypes, SigningStargateClient } from "@cosmjs/stargate";
async function main() {
const mnemonic = "your wallet mnemonic";
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: "akash" });
// get first account
const [account] = await wallet.getAccounts();
// Setup a send message
const message = {
fromAddress: account.address,
toAddress: "akash123...",
amount: coins(10, "akt")
};
// Set the appropriate typeUrl and attach the encoded message as the value
const msgAny = {
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
value: message
};
// You can use your own RPC node, or get a list of public nodes from akashjs
const rpcEndpoint = "http://your.rpc.node";
const myRegistry = new Registry(defaultRegistryTypes);
const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, wallet, {
registry: myRegistry
});
const fee = {
amount: [
{
denom: "uakt",
amount: "5000"
}
],
gas: "800000"
};
const msg = await client.sign(account.address, [msgAny], fee, "send funds with akashjs");
console.log(msg);
}
main();