Overview

The Bech32 precompile provides address format conversion between Ethereum hex (0x...) and Cosmos Bech32 (c8...) representations. Essential for cross-domain UX and contract logic that bridges both address systems. Precompile Address: 0x0000000000000000000000000000000000000400

Methods

MethodDescription
hexToBech32(address, string)Convert hex address to Bech32 with given prefix
bech32ToHex(string)Convert Bech32 address to hex

Example

IBech32 constant bech32 = IBech32(0x0000000000000000000000000000000000000400);

// Convert hex to Bech32
string memory cosmosAddr = bech32.hexToBech32(
    msg.sender,
    "c8"
);

// Convert Bech32 to hex
address evmAddr = bech32.bech32ToHex("c81wskntvnryr5qxpe4tv5k64rhc6kx6ma4...");
For exact signatures and ABI artifacts, see Precompile ABI Reference.