testnet
GitHub

Understanding Maroo Address Formats

integration intermediate

A guide to the different address formats used in Maroo and how to convert between them.

Prerequisites

  • Basic understanding of blockchain addresses (e.g., Ethereum hex addresses).

Ethereum Hexadecimal Address

This is the standard 42-character address format used by Ethereum, starting with 0x. It is used when interacting with the EVM via JSON-RPC, in Solidity smart contracts, and with tools like MetaMask, Hardhat, and Foundry.

Example: 0x71C7656EC7ab88b098defB751B7401B5f6d8976F

Cosmos Bech32 Address

This is the human-readable address format used by the Cosmos SDK. It includes a Human-Readable Part (HRP) which is maroo for Maroo, providing built-in error detection. This format is used for native Cosmos SDK transactions, staking, governance, and when using the marood command-line tool.

Example: maroo1g9aher02v4dmf49m26de25d2n0a2th8g3z4x9a
Note: Both address formats are derived from the same underlying public key. They are simply different string representations of the same account.

Converting Between Formats

You will often need to convert between these formats. For example, a user might provide their maroo... address, but your smart contract needs the 0x... format. Here's how to do it in Go and JavaScript.
import (
    sdk "github.com/cosmos/cosmos-sdk/types"
    "github.com/ethereum/go-ethereum/common"
)

// Bech32 to Hex
bech32Addr := "maroo1g9aher02v4dmf49m26de25d2n0a2th8g3z4x9a"
accAddr, err := sdk.AccAddressFromBech32(bech32Addr)
if err != nil { panic(err) }
hexAddr := common.BytesToAddress(accAddr.Bytes()).Hex()
// hexAddr is "0x71C7656EC7ab88b098defB751B7401B5f6d8976F"

// Hex to Bech32
hexAddrStr := "0x71C7656EC7ab88b098defB751B7401B5f6d8976F"
accAddr = common.HexToAddress(hexAddrStr).Bytes()
bech32Addr, err = sdk.Bech32ifyAddressBytes("maroo", accAddr)
if err != nil { panic(err) }
// bech32Addr is "maroo1g9aher02v4dmf49m26de25d2n0a2th8g3z4x9a"

Specialized Prefixes

In addition to the standard account prefix maroo, the Cosmos SDK defines other prefixes for different roles within the network, as configured in config/config.go. While you will interact with the maroo prefix most often, it's good to recognize the others:
  • maroovaloper: For validator operators (e.g., for staking-related messages).
  • maroovalcons: For validator consensus public keys.
  • maroopub: For account public keys.
  • maroovaloperpub: For validator operator public keys.
Source: maroo
ESC
Type to search