Cosmos Integration
Integrate Para with Cosmos ecosystem in your Flutter applications
Para provides Cosmos blockchain signing capabilities in Flutter applications through a secure bridge-based architecture. The integration supports message signing and transaction signing for major Cosmos networks including Cosmos Hub, Osmosis, Juno, and Stargaze.
Signing-Only Integration: This integration focuses on cryptographic signing operations. Transaction broadcasting and on-chain interactions require additional implementation using Cosmos RPC endpoints.
Prerequisites
Flutter Project Setup
Flutter Project Setup
- Flutter 3.1.3 or higher
- Para Flutter SDK integrated into your project
- Cosmos wallet created through Para
- Web browser support (for bridge communication)
Para Configuration
Para Configuration
- Valid Para API key
- Project configured with Cosmos network support
- User authenticated with Para SDK
- Internet connectivity for bridge and RPC operations
Architecture
Paraβs Cosmos integration uses a bridge-based architecture for enhanced security:
- Flutter App β Para Bridge β CosmJS Signers β Cosmos Networks
- All signing operations are performed through a secure web bridge
- Compatible with CosmJS v0.33.1 for maximum ecosystem compatibility
- Supports both Proto (Direct) and Amino signing methods
Dependencies
The Para Flutter SDK includes built-in Cosmos support. No additional dependencies are required beyond the standard Para SDK.
Supported Networks
Para currently supports 6 Cosmos networks with pre-configured settings:
Network | Chain ID | Prefix | Default Denom |
---|---|---|---|
Cosmos Hub | cosmoshub-4 | cosmos | uatom |
Osmosis | osmosis-1 | osmo | uosmo |
Juno | juno-1 | juno | ujuno |
Stargaze | stargaze-1 | stars | ustars |
Provider Testnet | provider | cosmos | uatom |
Osmosis Testnet | osmo-test-5 | osmo | uosmo |
Basic Usage
Initialization
Wallet Operations
Transaction Signing
Para supports both Proto (Direct) and Amino signing methods for Cosmos transactions. Both methods require a properly formatted SignDoc encoded as base64.
What is a SignDoc? A SignDoc is a structured representation of a transaction that needs to be signed. It contains the transaction body, auth info, chain ID, and account details. Youβll need to use a Cosmos SDK library to properly construct SignDocs. Learn more in the Cosmos SDK documentation.
Transaction Signing Only: Para provides cryptographic signatures for transactions. Youβll need to use a Cosmos SDK library or RPC client to construct the SignDoc and broadcast the signed transaction.
Proto/Direct Signing
Amino Signing
Network Configuration
Para supports the following Cosmos networks with pre-configured settings. You can initialize the signer for any supported network:
Limited Network Support: Para currently supports only the 6 networks listed above. Custom chains cannot be added through the SDK - support for additional Cosmos chains requires platform-level configuration by the Para team. Contact support if you need a specific chain added.
Error Handling
Para provides comprehensive error handling with 11 specific error types to help you handle different failure scenarios:
Common Error Scenarios
Wallet Selection Errors
Wallet Selection Errors
missingWalletId
: You must callselectWallet()
before any signing operationsinvalidWalletType
: The selected wallet is not configured for Cosmos signinginvalidWalletAddress
: The walletβs Cosmos address cannot be derived
Signing Errors
Signing Errors
signingFailed
: Generic signing failure - check error message for detailsprotoSigningFailed
: Proto/Direct signing failed - check SignDoc formataminoSigningFailed
: Amino signing failed - check SignDoc structureinvalidSignDoc
: SignDoc is malformed or improperly encodedinvalidTransaction
: Transaction data is invalid or malformed
Network & Bridge Errors
Network & Bridge Errors
bridgeError
: Communication with Para bridge failednetworkError
: RPC endpoint is unreachable or returned an error
Complete Example
Hereβs a practical example showing Cosmos integration with proper error handling:
Limitations
Important Limitations: Understanding these constraints is crucial for successful integration.
Network Support
Network Support
- Limited to 6 networks: Only Cosmos Hub, Osmosis, Juno, Stargaze, and their testnets are supported
- No custom chains: Cannot add support for new Cosmos chains without platform updates
- RPC dependency: Balance queries and some operations require reliable RPC access
Transaction Capabilities
Transaction Capabilities
- Signing only: Para provides cryptographic signatures, not transaction broadcasting
- No fee estimation: You must calculate and provide gas fees manually
- No transaction construction: You must build SignDocs using external tools
- Bridge dependency: All operations require internet connectivity for bridge communication
CosmJS Compatibility
CosmJS Compatibility
- Version locked: Uses CosmJS v0.33.1 for compatibility (not latest version)
- Limited message types: Supports standard Cosmos SDK messages only
- No custom types: Complex or custom message types may not be supported
Best Practices
Security
Security
- Always validate wallet selection before signing operations
- Never expose or log private signing data
- Verify chain IDs match expected networks
- Handle all error cases with proper user feedback
- Validate SignDoc content before signing
Performance
Performance
- Initialize the signer once and reuse it across operations
- Cache address and balance information when appropriate
- Implement proper timeout handling for network operations
- Use loading states during all async operations
- Handle bridge connectivity issues gracefully
User Experience
User Experience
- Show clear loading indicators during signing operations
- Provide meaningful error messages with specific error types
- Display transaction details before requesting signatures
- Format addresses and amounts for readability
- Implement retry mechanisms for failed operations
Development
Development
- Test with all supported networks during development
- Implement proper error handling for all CosmosSignerException types
- Use the bridge timeout configuration for long-running operations
- Validate all user inputs before constructing SignDocs
- Keep CosmJS dependency version consistent with Para requirements
Testing
Para provides E2E tests for Cosmos functionality in the examples repository:
Manual Testing Checklist
Test the following scenarios to ensure proper integration:
Wallet Operations
Wallet Operations
- Initialize signer with different chain configurations
- Select wallet and verify wallet type validation
- Get address for different networks (cosmos, osmo, juno, stars)
- Query balance with default and custom denominations
- Handle wallet selection errors appropriately
Message Signing
Message Signing
- Sign simple text messages
- Sign empty messages (should fail gracefully)
- Sign large messages (test message size limits)
- Verify signature format and encoding
- Test message signing timeout scenarios
Transaction Signing
Transaction Signing
- Sign Proto/Direct SignDocs with valid structure
- Sign Amino SignDocs with proper message types
- Test with invalid SignDoc formats (should fail with proper errors)
- Verify signature and public key returned format
- Test transaction signing across different networks
Error Handling
Error Handling
- Test all 11 CosmosSignerException error types
- Verify error messages are helpful and actionable
- Test network connectivity issues
- Test bridge communication failures
- Verify proper error propagation to UI