Skip to main content

Bech32 Encoding

Bech32 is the human-readable encoding format for Cardano addresses. Addresses look like addr_test1vr... (testnet) or addr1q... (mainnet). The Address module handles all Bech32 conversion.

Parse from Bech32

import { Address } from "@evolution-sdk/evolution"

const address = Address.fromBech32(
"addr_test1vrm9x2dgvdau8vckj4duc89m638t8djmluqw5pdrFollw8qd9k63"
)

Convert to Bech32

import { Address } from "@evolution-sdk/evolution"

declare const address: Address.Address

const bech32 = Address.toBech32(address)

Other Formats

import { Address } from "@evolution-sdk/evolution"

declare const address: Address.Address

// To/from hex
const hex = Address.toHex(address)
const fromHex = Address.fromHex(hex)

// To/from bytes
const bytes = Address.toBytes(address)
const fromBytes = Address.fromBytes(bytes)

Bech32 Prefixes

PrefixNetworkAddress Type
addrMainnetBase/enterprise address
addr_testTestnetBase/enterprise address
stakeMainnetReward address
stake_testTestnetReward address

Next Steps

  • Addresses — Address types and operations
  • Hex — Hex encoding for raw data