Conversions

How to convert between different aspects of data for

Token Denominations

In Cosmos, every denomination amount is formatted as an unsigned integer. With this, the chain does not have to deal with fractions. For an EVM chain this amount is typically 10**18 power, while Juno and other native Cosmos chains use the 10**6 power. This means if I want to send you 1 JUNO, I am actually sending 1,000,000 of the smaller token. You can figure out which power a token uses by its prefix character in the denomination. In the case of JUNO, the actual denomination is shown as ujuno. This u signals that it is using any amount times 10**6 to get the human readable amount.

circle-info

10JUNO = 10,000,000ujuno 0.5 JUNO = 500,000ujuno 0.00001 JUNO = 10ujuno This means the smallest amount anyone can send is 0.000001 JUNO

Address Conversions

Valoper -> Base

Convert the validator operator wallet to a standard base address

// npm i @cosmjs/encoding
import {toBech32, fromBech32} from '@cosmjs/encoding'

let toPrefix = "juno"

let initial = "junovaloper196ax4vc0lwpxndu9dyhvca7jhxp70rmcqcnylw"
let converted = toBech32(toPrefix, fromBech32(initial).data)

console.log(converted)
// juno196ax4vc0lwpxndu9dyhvca7jhxp70rmcl99tyh

Juno -> Other Chain

circle-info

You can only convert between the same cointype, so converting a JUNO (118) to EVM address such as Terra's 330 will not properly convert. This is not possible to do without their private key

Web UI

Typescript

Python

CLI

Hex -> Valcons

With this, you can now make a mapping between a junovaloper and signing junovalcons address

Hex -> Bech32

Convert juno address between hex and bech32 format.

circle-info

TIP

The command will accept either hex or bech32 coded address as the [address] argument. The command will return the same output for either.

circle-info

TIP

Your bech32 encoded juno local addresses can be queried with junod keys list

Example usage:

Returns:

Raw Bytes -> Hex

Convert raw bytes output (eg. [10 21 13 127]) to hex.

Example command:

Returns:

Public Key -> Valcons

Convert a validators public key to the validator consensus tendermint address

circle-info

PubKey -> Hex, Base64, or Bech32

Decode a ED25519 pubkey from hex, base64, or bech32.

circle-info

TIP

The command will accept hex, base64 or bech32 coded keys as [pubkey] argument. The command will return the same output for any of these inputs.

circle-info

TIP

Your bech32 encoded validator pubkey can be queried with junod tendermint show-validator

Example usage:

Returns:

Last updated