This guide covers essential information for developers building applications on BitBadges Chain that interact with both EVM and Cosmos SDK functionality.
Table of Contents
Transaction Signing Capabilities
BitBadges Chain supports two types of transactions, each with specific signing requirements:
Transaction Type
Signing Key Type
Hash Algorithm
Use Case
ethsecp256k1 (Ethereum-style)
EVM contract calls, precompile calls
Native Cosmos SDK messages (e.g., MsgDelegate, MsgTransferTokens)
Who Can Sign What?
β
ETH Wallets (ethsecp256k1 keys)
Can sign:
MsgEthereumTx transactions
Direct EVM contract calls
Precompile calls from Solidity contracts
Any Ethereum-compatible transaction
Cannot sign:
Standard Cosmos SDK messages (different hash algorithm)
Other native Cosmos messages
Example:
β
Cosmos Wallets (standard secp256k1 keys)
Can sign:
Standard Cosmos SDK messages
All native Cosmos SDK messages
Cannot sign:
MsgEthereumTx transactions (different signature format)
Cannot directly call EVM contracts
Cannot call precompiles from native Cosmos transactions
Example:
β Cross-Compatibility
Not supported out of the box:
ETH wallets cannot sign standard Cosmos messages
Cosmos wallets cannot sign MsgEthereumTx
Why?
Different hash algorithms (Keccak256 vs SHA256)
Different signature formats
EVM ante handler routes by transaction type
Workaround:
Use precompiles from Solidity contracts (ETH wallets) to access Cosmos SDK functionality
Use native Cosmos messages (Cosmos wallets) for direct SDK access
Address Conversion
BitBadges Chain uses a unified address system where Ethereum addresses (20 bytes) and Cosmos addresses (Bech32 format) represent the same underlying account when using ethsecp256k1 keys.
Conversion Mechanics
EVM Address β Cosmos Address
When an EVM address is used in Cosmos SDK operations, it's automatically converted:
Key Points:
Same 20-byte value, different encoding
EVM: 0x hex prefix (e.g., 0x1234...5678)
Cosmos: Bech32 with bb prefix (e.g., bb1abc...xyz)
Cosmos Address β EVM Address
The reverse conversion is also possible:
0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb
Solidity contracts, EVM transactions
Cosmos SDK messages, queries
Important Notes
Same Account, Different Representations
An account with an ethsecp256k1 key has the same 20-byte address in both formats
The Bech32 encoding is just a different way to represent the same bytes
Automatic Conversion in Precompiles
Precompiles automatically convert EVM addresses to Cosmos addresses
No manual conversion needed when calling precompile methods
Address Validation
Cosmos SDK validates addresses using Bech32 format
Both represent the same underlying account
Precompile Caller Limitations
Understanding msg.sender in Precompiles
When a Solidity contract calls a precompile, the precompile uses contract.Caller() to identify the caller. This has important implications for authorization and security.
1. Direct Contract Calls Only
The caller is always the immediate caller (the contract making the precompile call), not the original transaction signer.
Example:
Implication:
Precompile sees the contract address as the caller
Original user address is not directly available
Authorization must be handled at the contract level
2. No Cross-Contract Delegation
If Contract A calls Contract B, which then calls the precompile:
Implication:
Precompile only sees Contract B as the caller
Contract A's identity is not visible to the precompile
3. Authorization Patterns
Because the precompile sees the contract address, not the user address, you need to design authorization carefully:
Pattern 1: Contract-Level Authorization
Pattern 2: Pass User Address Explicitly
Pattern 3: Use Approval System
Security Considerations
Impersonation Prevention
Precompile always uses contract.Caller() to prevent spoofing
Cannot be manipulated by malicious contracts
Authorization Design
Design contracts to handle authorization before calling precompile
Don't rely on precompile seeing the original user address
Multi-Contract Scenarios
Be aware that intermediate contracts are invisible to precompile
Design authorization to account for this
Key Types and Compatibility
Key Type Comparison
Key Type
Algorithm
Hash Function
Address Format
Can Sign MsgEthereumTx
Can Sign Cosmos Messages
Both (EVM hex + Cosmos Bech32)
β No (different format)
Account Creation
When creating accounts:
For EVM Compatibility:
For Cosmos-Only:
Key Registration
The codebase registers both key types:
This allows the ante handler to recognize and verify signatures from both key types.
1. Choose the Right Key Type
Use ethsecp256k1 if you need:
Precompile calls from Solidity
Compatibility with Ethereum tooling
Use standard secp256k1 if you need:
Only native Cosmos SDK functionality
No EVM interaction required
2. Address Handling
In Solidity contracts: Use EVM addresses (hex format)
In Cosmos SDK code: Use Bech32 addresses
Precompiles handle conversion automatically
3. Authorization Patterns
For contracts calling precompiles:
Implement authorization at the contract level
Don't rely on precompile seeing original user address
Use approval patterns when needed
4. Transaction Types
Use MsgEthereumTx for:
Precompile calls from Solidity
Use standard Cosmos messages for:
Direct SDK module interaction
Better gas efficiency for simple operations
Native Cosmos tooling compatibility
5. Testing Considerations
Test with both key types if your app supports both
Verify address conversions work correctly
Test authorization patterns with contract intermediaries
Aspect
ETH Wallets (ethsecp256k1)
Cosmos Wallets (secp256k1)
β
Via Solidity contracts
Decimal Handling and the Precisebank Module
BitBadges Chain uses different decimal precisions for Cosmos SDK and EVM compatibility:
Cosmos SDK (x/bank): Uses 9 decimals with base denom ubadge
EVM (precisebank module): Uses 18 decimals for Ethereum compatibility
The precisebank module bridges these two systems, automatically handling conversions between Cosmos and EVM decimal representations.
Unit Conversions
Base unit in Cosmos SDK (x/bank)
Base unit in EVM (smallest unit)
Conversion Relationships:
1 BADGE = 1 * 10^9 ubadge (Cosmos)
1 BADGE = 1 * 10^18 abadge (EVM)
1 ubadge = 1 * 10^9 abadge
Working with EVM Contracts
When writing Solidity contracts or interacting with EVM precompiles:
Working with Cosmos SDK
When working with native Cosmos SDK messages or queries:
Automatic Conversion
The precisebank module handles conversions automatically:
EVM β Cosmos: When EVM contracts interact with Cosmos SDK modules, amounts are converted from 18 decimals to 9 decimals
Cosmos β EVM: When Cosmos SDK operations interact with EVM, amounts are converted from 9 decimals to 18 decimals
Important: Always use the correct decimal precision for the context you're working in. The precisebank module handles the conversion, but you must provide amounts in the correct format for your context.
Common Mistakes
Mixing decimal precisions
Not accounting for context
In Solidity contracts: Always use 18 decimals
In Cosmos SDK messages: Always use 9 decimals
The precisebank module handles the bridge automatically
EVM Query Challenges / Invariants
EVM queries allow you to gate token transfers or set invariants based on read-only queries to EVM smart contracts. This is a powerful feature for integrating with existing DeFi protocols, compliance registries, and cross-chain state verification.
See invariants or approval criterie -> EVM Query Challenges section for more details.
Additional Resources