Could you kindly assist me in transferring ATOMs between two accounts on the same Cosmos chain using the Cosmwasm API? I would be extremely grateful for your help. Thank you in advance.
Here is my code:
import { DirectSecp256k1HdWallet } from “@cosmjs/proto-signing”;
import { assertIsBroadcastTxSuccess, SigningStargateClient, StargateClient } from “@cosmjs/stargate”;
const mnemonic = “pell mixed pig devote pumpkin sport antenna author echo there crystal crisp second chimney field daughter hawk divert section glove abandon advice core rebuild”;
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic);
const [firstAccount] = await wallet.getAccounts();
const rpcEndpoint = “3.80.30.141:1317”;
const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, wallet);
const recipient = “goudla106t4ds07vkhuhsmkwjr94vhlm3lme8tjm994l0”;
const amount = {
denom: “ugoudla”,
amount: “12345”,
};
const result = await client.sendTokens(firstAccount.address, recipient, [amount], “Have fun with your star coins”);
assertIsBroadcastTxSuccess(result);
app.listen(port, () => {
console.log(Server running on port ${port}
)
})