Crypto Wallets (or Accounts) can be created and represented in unique ways on different blockchains. For developers who interface with account types on a Cosmos EVM chain, e.g. during wallet integration on their dApp frontend, it is therefore important to understand that accounts in the Cosmos EVM are implemented to be compatible with Ethereum type addresses.
cosmos1...
). Addresses are also associated with messages to identify the sender of the message.
The PrivKey is used to generate digital signatures to prove that an address associated with the PrivKey approved of a given message. The proof is performed by applying a cryptographic scheme to the PrivKey, known as Elliptic Curve Digital Signature Algorithm (ECDSA), to generate a PubKey that is compared with the address in the message.
Account
type to implement a HD wallet that is compatible with Ethereum type addresses. It uses Ethereum’s ECDSA secp256k1 curve for keys (eth_secp265k1
) and satisfies the EIP84 for full BIP44 paths. This cryptographic curve is not to be confused with Bitcoin’s ECDSA secp256k1 curve.
The root HD path for EVM-based accounts is m/44'/60'/0'/0
. It is recommended to use the Coin type 60
to support Ethereum type accounts, unlike many other Cosmos chains that use Coin type 118
(list of coin types
The custom Cosmos EVM EthAccount satisfies the AccountI
interface from the Cosmos SDK auth module and includes additional fields that are required for Ethereum type addresses:
Addresses
/PubKeys
available by default on the Cosmos EVM:
message
). They are derived using the eth_secp256k1
curve.eth_secp256k1
curve.ed25519
curve.Address bech32 Prefix | Pubkey bech32 Prefix | Curve | Address byte length | Pubkey byte length | |
---|---|---|---|---|---|
Accounts | cosmos | cosmospub | eth_secp256k1 | 20 | 33 (compressed) |
Validator Operator | cosmosvaloper | cosmosvaloperpub | eth_secp256k1 | 20 | 33 (compressed) |
Consensus Nodes | cosmosvalcons | cosmosvalconspub | ed25519 | 20 | 32 |
EthAccount
can be represented in both Bech32 (e.g. cosmos1...
) and hex (0x...
) formats for Ethereum’s Web3 tooling compatibility.
The Bech32 format is the default format for Cosmos-SDK queries and transactions through CLI and REST clients. The hex format on the other hand, is the Ethereum common.Address
representation of a Cosmos sdk.AccAddress
.
cosmos1z3t55m0l9h0eupuz3dp5t5cypyv674jj7mz2jw
0x91defC7fE5603DFA8CC9B655cF5772459BF10c6f
{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"AsV5oddeB+hkByIJo/4lZiVUgXTzNfBPKC73cZ4K1YD2"}
appd debug addr <address>
can be used to convert an address between hex and bech32 formats. For example:
Bech32
appd keys
) only supports addresses and public keys in Bech32 format.keys show
command of appd
with the flag --bech <type> (acc|val|cons)
to obtain the addresses and keys as mentioned above,
Accounts
eth_accounts
or personal_listAccounts
endpoints: