-
Notifications
You must be signed in to change notification settings - Fork 2
Address Format
Eg edited this page May 6, 2021
·
5 revisions
In the Cosmos Network, there are 3 addresses.
- new standard address format defined in BIP173.
- In the bitcoin, Base58Check is mostly used address format.
data structure
- human-readable part(HRP) prefix
- separator("1")
- data part (data+checksum)
HRP (human readable part) | Definition | Example |
---|---|---|
cosmos | Cosmos Account Address | cosmos1qaa9zej9a0ge3ugpx3pxyx602lxh3ztqda85ee |
cosmospub | Cosmos Account Public Key | |
cosmosvaloper | Cosmos Validator Operator Address | cosmosvaloper1qaa9zej9a0ge3ugpx3pxyx602lxh3ztqgfnp42 |
cosmosvaloperpub | Cosmos Validator Operator Public Key | |
cosmosvalcons | Cosmos Validator Consensus Address | cosmosvalcons17ktnf2yk5a5fgd4uxs3zgn7cv2hp38zuw8j35e |
cosmosvalconspub | Cosmos Validator Consensus Public Key | cosmosvalconspub1zcjduepqgx5wxl6eygqf6rx4gura2dy5vzelthjgqntk7q9l2hnpjqam6atsq8u0lx |
cosmos-sdk/types/address.go
// Bech32MainPrefix defines the main SDK Bech32 prefix of an account's address
Bech32MainPrefix = "cosmos"
// PrefixAccount is the prefix for account keys
PrefixAccount = "acc"
// PrefixValidator is the prefix for validator keys
PrefixValidator = "val"
// PrefixConsensus is the prefix for consensus keys
PrefixConsensus = "cons"
// PrefixPublic is the prefix for public keys
PrefixPublic = "pub"
// PrefixOperator is the prefix for operator keys
PrefixOperator = "oper"
// PrefixAddress is the prefix for addresses
PrefixAddress = "addr"
// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
Bech32PrefixAccAddr = Bech32MainPrefix
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
Bech32PrefixAccPub = Bech32MainPrefix + PrefixPublic
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
Bech32PrefixValAddr = Bech32MainPrefix + PrefixValidator + PrefixOperator
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
Bech32PrefixValPub = Bech32MainPrefix + PrefixValidator + PrefixOperator + PrefixPublic
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
Bech32PrefixConsAddr = Bech32MainPrefix + PrefixValidator + PrefixConsensus
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
Bech32PrefixConsPub = Bech32MainPrefix + PrefixValidator + PrefixConsensus + PrefixPublic
https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/addresses/bech32.md
https://github.com/cosmos-gaminghub/explorer-backend/tree/example/address-format
- generate secp256k1 private key
- generate public key from private key
- generate address from public key
- generate accAddress from address
- generate secp256k1 private key
- generate public key from private key
- generate address from public key
- generate valAddress from address
- generate ed25519 private key
- generate public key from private key
- generate address from public key
- generate consAddress from address
When using API, some value are encoded with Base64.
"proposer_address": "9Zc0qJanaJQ2vDQiJE/YYq4YnFw="
When decoding this value, you can see F59734A896A7689436BC3422244FD862AE189C5C
.
This is Address.
- example2 http://198.13.33.206:26657/genesis
{
"address": "F59734A896A7689436BC3422244FD862AE189C5C",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "Qajjf1kiAJ0M1UcH1TSUYLP13kgE128Av1XmGQO711c="
},
"power": "8174386",
"name": "CCN"
},
When decoding this value, you can see 41A8E37F5922009D0CD54707D5349460B3F5DE4804D76F00BF55E61903BBD757
. This is PubKey.