Send token using Keplr wallet.
```typescript
import { ChainInfo } from "./chainInfo";
import { Coin, SigningStargateClient, StdFee } from "@cosmjs/stargate";
import { Window as KeplrWindow } from "@keplr-wallet/types";
declare global {
interface Window extends KeplrWindow {}
}
export async function sendTokenExample() {
const { keplr } = window;
if (!keplr) {
return { error: "You need to install Keplr" };
}
try {
await keplr.experimentalSuggestChain(ChainInfo);
await keplr.enable(ChainInfo.chainId);
const offlineSigner = keplr.getOfflineSigner!(ChainInfo.chainId);
if (!offlineSigner) {
return { error: "Error while getting offlineSigner" };
}
const signerAddress = (await offlineSigner.getAccounts())[0].address;
const client = await SigningStargateClient.connectWithSigner(
'"wss://bc.ggez.one:26657"',
offlineSigner
);
const toAddress = "ggez1u7374gx6efl39vsd6mhwn0pw7nhwzqtfjumkfh";
const amount: Coin[] = [
{
amount: "1000000", // 1000000 uggez1 = 1 GGEZ1
denom: "uggez1",
},
];
const fee: StdFee = {
amount: [
{
amount: "100000", // Fee = gas * gas_price = 200000 * 0.5
denom: "uggez1",
},
],
gas: "200000",
};
const memo = "Add memo here"; // It is optional
const response = await client.sendTokens(
signerAddress,
toAddress,
amount,
fee,
memo
);
// If code equal 0 transaction should be successful
if (response.code === 0) {
console.log("Successful Transaction");
} else {
console.log(`Error: ${response.rawLog}`);
}
} catch (error) {
console.error(error);
}
}
```