Addressing on Radix

High Level Overview

In previous version of Scrypto, addresses used to be represented as hex encoded strings. In general, hex encoded addresses have two key issues:

  • They are not checksummed, therefore, mistakes in the address can neither be corrected nor detected statically. Without having a checksum, verifying the correctness of an address would require a service which has access to a node and is able to provide information on whether anything exists at the provided address or not.

  • Without having a human readable part, it is difficult to determine what an address is used for just by looking at it. Even when an entity byte is present in an address, it still requires interpretation. As an example, a hex string could be a package address or a resource address. There is no way to tell what the type of addressed entity is without using an external service.

Scrypto addresses have moved away from being hex encoded and are now Bech32m encoded, where they are made up of a Human Readable Part (HRP), separator, and a base32m encoded data part which includes a 6 character checksum of the HRP and data.

bech32 format

The human readable part is made up of two specifiers that are separated by an underscore ("_"). These are:

  • Entity Specifier: Specifies the type of entity that this address is for. As an example, in the case of the address being used to address an account component, the entity specifier would be "account". This makes it clear at first glance what the address is meant to be used for.

  • Network Specifier: Specifies the network that the address is used for. This helps distinguish mainnet address from stokenet address, and so on; making it clear what network the address is use for.

The introduction of Bech32m address encoding to Scrypto comes with a number of benefits:

  • All addresses are now checksummed and therefore typological errors can be detected and corrected.

  • The entity specifier makes it clear what the address is meant to represent.

Encoded Data

The data encoded in the Bech32m address is the byte representation of the address, which is an array of 30 bytes that is made up of two main parts:

  1. Entity Byte: This is the first byte in the address and it defines the type of entity being addressed.

  2. Address Bytes: These are the remaining 29 bytes in the array and they are the address of the entity.

address byte format

The supported entity types and their entity byte representation are given in entity_type.rs.

The byte-representation of addresses is lower-level concept and is not something that you will need to use on day-to-day basis.

Entity Specifiers

Entity specifiers are the first part of the Bech32m HRPs used in Scrypto, they are used to specify the type of entity being addressed in a human readable way.

For example, account_ or resource_. Any entity specifier starting with internal_ is of a non-global "internal" entity, and can’t be interacted with directly, aside from very specific instances, such as vault recalls/freezes.

A full list of entity specifiers are given in hrpset.rs.

Network Specifiers

The address HRP contains a network specifier which is used to specify which network the entity is on. The table below contains all of the relevant network specifiers:

Network Name

Network Specifier

Mainnet

rdx

Local Simulator

sim

Testnet with hex id n

tdx_n_