Address format conversion between Ethereum hex addresses and Cosmos bech32 addresses
0x0000000000000000000000000000000000000400
Related Module: Address conversion utilities
The Bech32 precompile provides address format conversion functionality between Ethereum hex addresses and Cosmos bech32 addresses.
address
to a Bech32 string with a desired prefix
(e.g. cosmos
).address
.0x0000000000000000000000000000000000000400
.
hexToBech32
hexToBech32(address addr, string memory prefix) → string memory
Description: Converts an Ethereum hex address to Cosmos bech32 format using the specified prefix.
addr
(address): The Ethereum hex address to convertprefix
(string): The bech32 prefix to use (e.g., “cosmos”)bech32ToHex
bech32ToHex(string memory bech32Address) → address
Description: Converts a Cosmos bech32 address to Ethereum hex format.
bech32Address
(string): The bech32 formatted address to convert