Skip to main content
Transfer tokens between Cosmos accounts using CosmJS with Para’s secure wallet infrastructure.

Prerequisites

Setup CosmJS Libraries

Send Tokens

import { useCosmjsProtoSigner } from "@getpara/react-sdk/cosmos";
import { SigningStargateClient, coins } from "@cosmjs/stargate";

const RPC_URL = "https://rpc.cosmos.directory/cosmoshub";

function TokenTransfer() {
  const { protoSigner, isLoading } = useCosmjsProtoSigner();

  const address = protoSigner?.address;

  const sendTokens = async () => {
    if (!protoSigner || !address) return;

    const recipient = "cosmos1...";
    const amount = coins(1000000, "uatom");

    const fee = {
      amount: coins(5000, "uatom"),
      gas: "200000",
    };

    try {
      const client = await SigningStargateClient.connectWithSigner(RPC_URL, protoSigner);

      const result = await client.sendTokens(
        address,
        recipient,
        amount,
        fee,
        "Sent via Para"
      );

      console.log("Transaction hash:", result.transactionHash);
      console.log("Gas used:", result.gasUsed);
    } catch (error) {
      console.error("Transfer failed:", error);
    }
  };

  if (isLoading) return <div>Loading...</div>;

  return (
    <div>
      <p>From: {address}</p>
      <button onClick={sendTokens}>Send 1 ATOM</button>
    </div>
  );
}

Next Steps