#bech32 #cosmwasm #blockchain #cosmos

cw-bech32

Helper utilities for working with bech32 addresses in CosmWasm contracts

1 stable release

new 1.0.0 Mar 30, 2025

#8 in #bech32

Apache-2.0

14KB
54 lines

cw-bech32

A simple Rust library for handling bech32 addresses in CosmWasm smart contracts.

Features

  • Split and join bech32 addresses
  • Convert addresses between different bech32 prefixes
  • Trait for working with bech32 addresses

Usage

use cosmwasm_std::Addr;
use cw_bech32::{Bech32Addr, WithBech32};

// Convert from one prefix to another
let cosmos_address = "cosmos1...";
let osmo_address = Bech32Addr::convert(cosmos_address, "osmo")?;

// Split a bech32 address into prefix and data parts
let (prefix, data) = Bech32Addr::split("cosmos1...")?;

// Join prefix and data into a bech32 address
let address = Bech32Addr::join("osmo", &data);

Licenses

This repo is licensed under Apache 2.0.


lib.rs:

cw-bech32

Helper utilities for working with bech32 addresses in CosmWasm contracts.

This crate provides simple utilities to:

  • Split and join bech32 addresses
  • Convert between different bech32 prefix formats
  • Handle bech32 addresses in a type-safe manner

Dependencies

~4.5–8MB
~160K SLoC