> ## 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.

# Cosmos Integration

> Sign transactions for Cosmos chains using Para's unified wallet architecture

export const Card = ({imgUrl, title, description, href, horizontal = false, newTab = false}) => {
  const [isHovered, setIsHovered] = useState(false);
  const handleClick = e => {
    e.preventDefault();
    if (newTab) {
      window.open(href, '_blank', 'noopener,noreferrer');
    } else {
      window.location.href = href;
    }
  };
  return <div className={`not-prose relative my-2 p-[1px] rounded-xl transition-all duration-300 ${isHovered ? 'bg-gradient-to-r from-[#FF4E00] to-[#874AE3]' : 'bg-gray-200'}`} onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}>
      <a href={href} onClick={handleClick} className={`not-prose flex ${horizontal ? 'flex-row' : 'flex-col'} font-normal h-full bg-white overflow-hidden w-full cursor-pointer rounded-[11px] no-underline`}>
        {imgUrl && <div className={`relative overflow-hidden flex-shrink-0 ${horizontal ? 'w-[30%] rounded-l-[11px]' : 'w-full'}`} onClick={e => e.stopPropagation()}>
            <img src={imgUrl} alt={title} className="w-full h-full object-cover pointer-events-none select-none" draggable="false" />
            <div className="absolute inset-0 pointer-events-none" />
          </div>}
        <div className={`flex-grow px-6 py-5 ${horizontal ? 'w-[70%]' : 'w-full'} flex flex-col ${horizontal && imgUrl ? 'justify-center' : 'justify-start'}`}>
          {title && <h2 className="font-semibold text-base text-gray-800 m-0">{title}</h2>}
          {description && <div className={`font-normal text-gray-500 re leading-6 ${horizontal || !imgUrl ? 'mt-0' : 'mt-1'}`}>
              <p className="m-0 text-xs">{description}</p>
            </div>}
        </div>
      </a>
    </div>;
};

## Quick Start

```dart theme={null}
import 'package:para/para.dart';

// Sign a Cosmos transaction
final para = Para(apiKey: 'your-api-key');
final wallet = (await para.fetchWallets()).firstWhere((w) => w.type == 'COSMOS');

final transaction = CosmosTransaction(
  to: 'cosmos1recipient...',
  amount: '1000000', // 1 ATOM in micro-units
  chainId: 'theta-testnet-001', // Cosmos Hub testnet (use 'cosmoshub-4' for mainnet)
  format: 'proto',
);

final result = await para.signTransaction(
  walletId: wallet.id!,
  transaction: transaction.toJson(),
  chainId: 'theta-testnet-001',
);
print('Transaction signed: ${result.signedTransaction}');
```

## Common Operations

### Sign Transactions for Different Chains

```dart theme={null}
// Sign ATOM transaction on Cosmos Hub testnet
final atomTx = CosmosTransaction(
  to: 'cosmos1recipient...',
  amount: '1000000', // 1 ATOM
  denom: 'uatom',
  chainId: 'theta-testnet-001', // Testnet
  format: 'proto',
);

// Sign OSMO transaction on Osmosis testnet
final osmoTx = CosmosTransaction(
  to: 'osmo1recipient...',
  amount: '1000000', // 1 OSMO
  denom: 'uosmo',
  chainId: 'osmo-test-5', // Testnet
  format: 'proto',
);

// Sign JUNO transaction on Juno mainnet
final junoTx = CosmosTransaction(
  to: 'juno1recipient...',
  amount: '1000000', // 1 JUNO
  denom: 'ujuno',
  chainId: 'juno-1',
  format: 'proto',
);
```

### Sign Transaction

```dart theme={null}
final transaction = CosmosTransaction(
  to: 'cosmos1recipient...',
  amount: '1000000', // 1 ATOM
  denom: 'uatom',
  memo: 'Transfer via Para',
  chainId: 'theta-testnet-001', // Testnet
  format: 'proto', // or 'amino' for legacy
);

final result = await para.signTransaction(
  walletId: wallet.id!,
  transaction: transaction.toJson(),
  chainId: 'theta-testnet-001',
  rpcUrl: 'https://rpc.sentry-01.theta-testnet.polypore.xyz',
);
// Cosmos returns: { signBytes, signDoc, format }
print('Signed: ${result.signedTransaction}');
```

### Check Balance

```dart theme={null}
final balance = await para.getBalance(
  walletId: wallet.id!,
  rpcUrl: 'https://cosmos-rpc.publicnode.com',
  chainPrefix: 'cosmos',
  denom: 'uatom',
);
print('Balance: $balance uatom');

// Different chain
final osmoBalance = await para.getBalance(
  walletId: wallet.id!,
  rpcUrl: 'https://osmosis-rpc.publicnode.com',
  chainPrefix: 'osmo',
  denom: 'uosmo',
);
```

### Sign Message

```dart theme={null}
final message = 'Hello, Cosmos!';
final result = await para.signMessage(
  walletId: wallet.id!,
  message: message,
);
print('Signature: ${result.signedTransaction}');
```

## Supported Networks

### Testnets

| Network                | Chain ID            | Prefix   | Native Token | RPC URL                                            |
| ---------------------- | ------------------- | -------- | ------------ | -------------------------------------------------- |
| **Cosmos Hub Testnet** | `theta-testnet-001` | `cosmos` | `uatom`      | `https://rpc.sentry-01.theta-testnet.polypore.xyz` |
| **Osmosis Testnet**    | `osmo-test-5`       | `osmo`   | `uosmo`      | `https://rpc.osmotest5.osmosis.zone`               |

### Mainnets

| Network        | Chain ID         | Prefix     | Native Token | Decimals | RPC URL                                |
| -------------- | ---------------- | ---------- | ------------ | -------- | -------------------------------------- |
| **Cosmos Hub** | `cosmoshub-4`    | `cosmos`   | `uatom`      | 6        | `https://cosmos-rpc.publicnode.com`    |
| **Osmosis**    | `osmosis-1`      | `osmo`     | `uosmo`      | 6        | `https://osmosis-rpc.publicnode.com`   |
| **Juno**       | `juno-1`         | `juno`     | `ujuno`      | 6        | `https://rpc-juno.itastakers.com`      |
| **Stargaze**   | `stargaze-1`     | `stars`    | `ustars`     | 6        | `https://rpc.stargaze-apis.com`        |
| **Akash**      | `akashnet-2`     | `akash`    | `uakt`       | 6        | `https://rpc.akash.forbole.com`        |
| **Celestia**   | `celestia`       | `celestia` | `utia`       | 6        | `https://rpc.celestia.pops.one`        |
| **dYdX**       | `dydx-mainnet-1` | `dydx`     | `adydx`      | 18       | `https://dydx-dao-api.polkachu.com`    |
| **Injective**  | `injective-1`    | `inj`      | `inj`        | 18       | `https://injective-rpc.publicnode.com` |

## Complete Example

```dart theme={null}
import 'package:flutter/material.dart';
import 'package:para/para.dart';

class CosmosWalletView extends StatefulWidget {
  final Para para;
  final Wallet wallet;
  
  const CosmosWalletView({required this.para, required this.wallet});
  
  @override
  State<CosmosWalletView> createState() => _CosmosWalletViewState();
}

class _CosmosWalletViewState extends State<CosmosWalletView> {
  String _selectedChain = 'theta-testnet-001';
  bool _isLoading = false;
  String? _result;
  
  final chains = {
    'theta-testnet-001': {'name': 'Cosmos Hub Testnet', 'rpc': 'https://rpc.sentry-01.theta-testnet.polypore.xyz', 'denom': 'uatom', 'prefix': 'cosmos'},
    'osmo-test-5': {'name': 'Osmosis Testnet', 'rpc': 'https://rpc.osmotest5.osmosis.zone', 'denom': 'uosmo', 'prefix': 'osmo'},
  };
  
  @override
  Widget build(BuildContext context) {
    final chain = chains[_selectedChain]!;
    
    return Padding(
      padding: const EdgeInsets.all(16),
      child: Column(
        children: [
          DropdownButton<String>(
            value: _selectedChain,
            items: chains.entries.map((e) => 
              DropdownMenuItem(value: e.key, child: Text(e.value['name']!))
            ).toList(),
            onChanged: (value) => setState(() => _selectedChain = value!),
          ),
          SizedBox(height: 20),
          Text(
            widget.wallet.address ?? 'No address',
            style: TextStyle(fontFamily: 'monospace', fontSize: 12),
          ),
          SizedBox(height: 20),
          ElevatedButton(
            onPressed: _isLoading ? null : _signTransaction,
            child: Text(_isLoading ? 'Signing...' : 'Sign Transaction for ${chain['name']}'),
          ),
          if (_result != null)
            Padding(
              padding: const EdgeInsets.only(top: 20),
              child: Text(_result!, style: TextStyle(fontSize: 12)),
            ),
        ],
      ),
    );
  }
  
  Future<void> _signTransaction() async {
    setState(() => _isLoading = true);
    final chain = chains[_selectedChain]!;
    
    try {
      final transaction = CosmosTransaction(
        to: '${chain['prefix']}1recipient...', // Uses chain prefix
        amount: '1000000', // 1 token in micro-units
        denom: chain['denom']!,
        memo: 'Test transaction from Flutter',
        chainId: _selectedChain,
        format: 'proto',
      );
      
      final result = await widget.para.signTransaction(
        walletId: widget.wallet.id!,
        transaction: transaction.toJson(),
        chainId: _selectedChain,
        rpcUrl: chain['rpc']!,
      );
      setState(() => _result = 'Signed! Signature: ${result.signature}');
    } catch (e) {
      setState(() => _result = 'Error: $e');
    } finally {
      setState(() => _isLoading = false);
    }
  }
}
```

## Proto vs Amino Formats

```dart theme={null}
// Modern Proto format (recommended)
final protoTx = CosmosTransaction(
  to: 'cosmos1recipient...',
  amount: '1000000',
  format: 'proto',
  chainId: 'cosmoshub-4',
);

// Legacy Amino format (compatibility)
final aminoTx = CosmosTransaction(
  to: 'cosmos1recipient...',
  amount: '1000000',
  format: 'amino',
  chainId: 'cosmoshub-4',
);

// Use convenience constructor
final simpleTx = CosmosTransaction(
  to: 'cosmos1recipient...',
  amount: '1000000',
  denom: 'uatom',
  chainId: 'theta-testnet-001',
);
```
