Skip to content

account

Crypto wallets (or accounts) can be created and represented in unique ways on different blockchains. For developers interacting with account types on Daodst, during wallet integration on their dApp frontend, it is important to understand that accounts on Daodst are implemented to be compatible with Ethereum type addresses.

Create an account

To create an account, you create a private key, a keystore file (a password-protected private key), or a seed phrase (a string of words that gives access to multiple private keys).

Besides having different security features, the biggest difference between them is that the private key or keystore file only creates an account. Creating a seed phrase can give you control over many accounts, all of which can be accessed using the same phrase.

The Cosmos blockchain, like Daodst, supports account creation using mnemonic phrases, also known as Hierarchical Deterministic Key Generation (HD Keys). This allows users to create accounts on multiple blockchains without having to manage multiple keys.

HD keys generate addresses by taking a mnemonic phrase and combining it with a piece of information called a derivation path. Blockchains can differ in the derivation paths they support. Therefore, to access all accounts via a mnemonic phrase on a blockchain, it is important to use a specific derivation path for that blockchain.

Proxy account

The terms 'account' and 'address' are often used interchangeably to describe crypto wallets. In the Cosmos SDK, an account specifies a pair of public key (PubKey) and private key (PrivKey). Derivation paths define private keys, public keys, and addresses.

A PubKey can be derived to generate various addresses in different formats, which are used to identify users (among other parties) within the application. A common address form for Cosmos chains is the bech32 format (eg dst1 ...). Addresses are also associated with messages to identify the sender of the message.

A PrivKey is used to generate a digital signature attesting that the address associated with the PrivKey approves a given message. Attestation is performed by applying a cryptographic scheme called the Elliptic Curve Digital Signature Algorithm (ECDSA) to the PrivKey to generate a public key that is compared to the address in the message.

Daodst Account

Daodst defines its own custom account type to implement HD wallet compatible with Ethereum type addresses. It uses Ethereum's ECDSA secp256k1 curve as the key (eth_secp265k1) and satisfies the full BIP44 path of EIP84. Do not confuse this cryptographic curve with Bitcoin's ECDSA secp256k1 curve.

The root HD path for Daodst based accounts is m/44'/60'/0'/0. Daodst uses Coin type 60 to support Ethereum type accounts, unlike many other Cosmos chains which use Coin type 118 (list of coin types

The custom Daodst EthAccount satisfies the AccountI interface from the Cosmos SDK authentication module and contains additional fields required for Ethereum type addresses:

// EthAccountI represents the interface of an Daodst compatible account
type EthAccountI interface {
    authtypes.AccountI
    // EthAddress returns the ethereum Address representation of the AccAddress
    EthAddress() common.Address
    // CodeHash is the keccak256 hash of the contract code (if any)
    GetCodeHash() common.Hash
    // SetCodeHash sets the code hash to the account fields
    SetCodeHash(code common.Hash) error
    // Type returns the type of Ethereum Account (EOA or Contract)
    Type() int8
}

address and public key

BIP-0173 defines a new format for Segregated Witness output addresses that includes a human-readable portion identifying Bech32 usage. Daodst uses the following HRPs (human-readable prefixes) as base HRPs:

Network Mainnet Testnet
Daodst dst dst

There are 3 main types of HRP for addresses/public keys available by default on Daodst:

  • The account's address and key, which identify the user (such as the sender of a message). They are derived using the eth_secp256k1 curve.
  • The validator operator's address and key, used to identify the validator's operator. They are derived using the eth_secp256k1 curve.
  • The address and key of the consensus node, used to identify the verification nodes participating in the consensus. They are derived using the ed25519 curve
Name bech32 address prefix bech32 public key prefix curve address byte length public key byte length
account dst dstpub eth_secp256k1 20 33 (compressed)
Validator operations dstvaloper dstvaloperpub eth_secp256k1 20 33 (compressed)
consensus node dstvalcons dstvalconspub ed25519 32

Customer's address format

Eth account number can be represented in Bech32 (dst1...) and hexadecimal (0x...) formats for Ethereum's Web3 tooling compatibility.

The Bech32 format is the default format for Cosmos-SDK queries and transactions via CLI and REST clients. On the other hand, the hexadecimal format is Ethereum common.Address represents Cosmos sdk.AccAddress.

  • Address (Bech32): dst1z3t55m0l9h0eupuz3dp5t5cypyv674jj7mz2jw
  • Address (EIP55 hexadecimal): 0x91defC7fE5603DFA8CC9B655cF5772459BF10c6f
  • Compress public key: {"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"AsV5oddeB+hkByIJo/4lZiVUgXTzNfBPKC73cZ4K1YD2"}

address translation

stcd debug addr

can be used to convert addresses between hexadecimal and bech32 formats. For example: Bech32

  $ stcd debug addr dst1z3t55m0l9h0eupuz3dp5t5cypyv674jj7mz2jw
   Address: [20 87 74 109 255 45 223 158 7 130 139 67 69 211 4 9 25 175 86 82]
   Address (hex): 14574A6DFF2DDF9E07828B4345D3040919AF5652
   Bech32 Acc: dst1z3t55m0l9h0eupuz3dp5t5cypyv674jj7mz2jw
   Bech32 Val: dstvaloper1z3t55m0l9h0eupuz3dp5t5cypyv674jjn4d6nn

Hex

  $ stcd debug addr 14574A6DFF2DDF9E07828B4345D3040919AF5652
   Address: [20 87 74 109 255 45 223 158 7 130 139 67 69 211 4 9 25 175 86 82]
   Address (hex): 14574A6DFF2DDF9E07828B4345D3040919AF5652
   Bech32 Acc: dst1z3t55m0l9h0eupuz3dp5t5cypyv674jj7mz2jw
   Bech32 Val: dstvaloper1z3t55m0l9h0eupuz3dp5t5cypyv674jjn4d6nn

Key export

We can use stcd's keys show command with the flags --bech (acc|val|cons) to get addresses and keys, as described above,

Ordinary account

  $ stcd keys show dev0 --bech acc
- name: dev0
   type: local
   address: dst1z3t55m0l9h0eupuz3dp5t5cypyv674jj7mz2jw
   pubkey: '{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"AsV5oddeB+hkByIJo/4lZiVUgXTzNfBPKC73cZ4K1YD2"}'
   mnemonic: ""

validator

  $ stcd keys show dev0 --bech val
- name: dev0
   type: local
   address: dstvaloper1z3t55m0l9h0eupuz3dp5t5cypyv674jjn4d6nn
   pubkey: '{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"AsV5oddeB+hkByIJo/4lZiVUgXTzNfBPKC73cZ4K1YD2"}'
   mnemonic: ""

consensus

  $ stcd keys show dev0 --bech cons
- name: dev0
   type: local
   address: dstvalcons1rllqa5d97n6zyjhy6cnscc7zu30zjn3f7wyj2n
   pubkey: '{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"A/fVLgIqiLykFQxum96JkSOoTemrXD0tFaFQ1B0cpB2c"}'
   mnemonic: ""

Account query

You can use CLI, gRPC or

command line interface

# NOTE: the --output (-o) flag will define the output format in JSON or YAML (text)
stcd q auth account $(stcd keys show dev0 -a) -o text

'@type': /ethermint.types.v1.EthAccount
base_account:
account_number: "0"
address: dst1z3t55m0l9h0eupuz3dp5t5cypyv674jj7mz2jw
pub_key:
   '@type': /ethermint.crypto.v1.ethsecp256k1.PubKey
   key: AsV5oddeB+hkByIJo/4lZiVUgXTzNfBPKC73cZ4K1YD2
sequence: "1"
code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470

Cosmos gRPC and REST

# GET /cosmos/auth/v1beta1/accounts/{address}
curl -X GET "http://localhost:10337/cosmos/auth/v1beta1/accounts/dst14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" -H "accept: application/json"

JSON-RPC To retrieve Ethereum hex addresses using Web3, use the JSON-RPC eth_accounts or personal_listAccounts endpoints

# query against a local node
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545

curl -X POST --data '{"jsonrpc":"2.0","method":"personal_listAccounts","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545