Tutorial GitHub Repository This tutorial demonstrates how to convert between an EVM hex address and a Cosmos bech32 address.Documentation Index
Fetch the complete documentation index at: https://docs.initia.xyz/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Project Setup
First, create a new directory for your project.bech32-converting package.
index.js in the src directory where you will
write your code.
You can use any package that allows you to encode and decode bech32-prefixed
addresses. However, the specific steps for using those packages may vary.
Development
For this tutorial, assume that you have an EVM address0x0901aeeD1d5144987DaE3D95AB219ff75e9bA636 that you want to convert to a
Cosmos address, and then convert it back to an EVM address.
First, import the bech32-converting package and initialize the variable for
the chain’s Bech32 prefix.
src/index.js
EVM Address to Cosmos Address
To convert an EVM address to a Cosmos address, use thebech32-converting
package’s toHex function.
src/index.js
Cosmos Address to EVM Address
To convert a Cosmos address to an EVM address, use thebech32-converting
package’s fromHex function.
src/index.js
src/index.js