Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.getpara.com/llms.txt

Use this file to discover all available pages before exploring further.

Transfer tokens between Cosmos accounts using CosmJS with Para’s secure wallet infrastructure in React Native.

Prerequisites

Send Tokens

import { View, Text, Button } from 'react-native';
import { useParaCosmjsProtoSigner } from '@getpara/react-native-wallet/cosmos';
import { SigningStargateClient, coins } from '@cosmjs/stargate';

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

function TokenTransfer() {
  const { protoSigner, isLoading } = useParaCosmjsProtoSigner();
  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 <Text>Loading...</Text>;

  return (
    <View>
      <Text>From: {address}</Text>
      <Button title="Send 1 ATOM" onPress={sendTokens} />
    </View>
  );
}

Next Steps