testnet
GitHub

Understanding Maroo Address Formats

quickstart beginner

Learn about the two primary address formats used on the Maroo network—EVM hexadecimal and Cosmos Bech32—and how to convert between them.

Prerequisites

  • A basic understanding of blockchain accounts.

EVM Hexadecimal Addresses

This is the standard address format used by Ethereum and other EVM chains. It's a 42-character string starting with 0x.

  • Format: 0x followed by 40 hexadecimal characters (e.g., 0x71C7656EC7ab88b098defB751B7401B5f6d8976F).
  • When to use: When interacting with smart contracts, using wallets like MetaMask, or using Ethereum-native tools and libraries (Ethers.js, Web3.py).

Cosmos Bech32 Addresses

This is the human-readable address format native to the Cosmos SDK. It includes a prefix to identify the network and a checksum to prevent errors.

  • Format: A network-specific prefix (e.g., maroo) followed by a string of characters (e.g., maroo1...).
  • Maroo Prefixes: As defined in config/config.go, Maroo uses maroo for user accounts, maroovaloper for validators, etc.
  • When to use: When using Cosmos-native tools like the marood CLI, interacting with staking or governance modules, or sending IBC transactions.

Converting Between Formats

Since both address formats point to the same account, you can easily convert between them. This is often necessary when, for example, you have a 0x address from MetaMask but need the maroo address to query its balance using the marood CLI.
package main

import (
	"fmt"
	"github.com/cosmos/cosmos-sdk/types"
	"github.com/ethereum/go-ethereum/common"
	"github.com/delight-labs/maroo/config"
)

func main() {
	// Ensure Maroo prefixes are set for the SDK config
	cfg := types.GetConfig()
	config.SetBech32Prefixes(cfg)
	cfg.Seal()

	// --- Conversion from Hex to Bech32 ---
	hexAddrStr := "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
	hexAddr := common.HexToAddress(hexAddrStr)
	bech32Addr, err := types.Bech32ifyAddressBytes("maroo", hexAddr.Bytes())
	if err != nil {
		panic(err)
	}
	fmt.Printf("Hex '%s' is Bech32 '%s'\n", hexAddrStr, bech32Addr)

	// --- Conversion from Bech32 to Hex ---
	bech32AddrToConvert := "maroo1h82d8f7st5panty5d2p22z3a2q525e593qavpj"
	_, addrBytes, err := types.ParseBech32AddressAndBytes(bech32AddrToConvert)
	if err != nil {
		panic(err)
	}
	hexResult := common.BytesToAddress(addrBytes)
	fmt.Printf("Bech32 '%s' is Hex '%s'\n", bech32AddrToConvert, hexResult.Hex())
}
Note: Many block explorers for Maroo will automatically show both address formats on an account's page.
Source: maroo
ESC
Type to search