Addressing

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 27 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 bytes in the array and they are the address of the entity.

address byte format

The following table includes all of the addressable entities as of v0.5.0 and their corresponding entity bytes:

Entity Name

Entity Byte

Resource

0x00

Package

0x01

Normal Component

0x02

Account Component

0x03

System Component

0x04

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. Each one of the entity names and types map to an entity specifier, the table below contains all of the entity specifiers used in Scrypto:

Entity Name

Entity Byte

Entity Specifier

Resource

0x00

resource

Package

0x01

package

Normal Component

0x02

component

Account Component

0x03

account

System Component

0x04

system

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

Mainnet

rdx

Named Testnets

Stokenet

stk

Localnet

loc

Local Simulator

sim

Unnamed Testnet

Numeric Testnet

tdxn_

HRP Map

After combining the entity and network specifiers together, we get the following map of HRPs:

Network Name

Resource

Package

Component

Account

System

Mainnet

Mainnet

resource_rdx

package_rdx

component_rdx

account_rdx

system_rdx

Named Testnets

Stokenet

resource_stk

package_stk

component_stk

account_stk

system_stk

Localnet

resource_loc

package_loc

component_loc

account_loc

system_loc

Localnet

resource_sim

package_sim

component_sim

account_sim

system_sim

Unnamed Testnet

Numeric Testnet

resource_tdxn_

package_tdxn_

component_tdxn_

account_tdxn_

system_tdxn_