address— a standard address; also called “internal address”.address?— nullable address, i.e., either a standard address ornull; also called “internal or none”.any_address— any kind of address, including external addresses.
Components
A standard, internaladdress consists of:
- a
int8workchain — currently, there are only two: masterchain (-1) and basechain (0); - a
uint256hash — a 256-bit account ID.
address has methods to retrieve these components:
address type occupy 267 bits:
- 3 bits for the standard address prefix —
0b100 - 8-bit workchain
- 256-bit hash
address are automatically validated at runtime: if parsing succeeds, the resulting address is guaranteed to be valid.
Comparison
Compare addresses using== or !=. Internally, an address is represented as a raw slice without references, so == and != test for bits equality.
Embedding
Embed a constant value of typeaddress using the address() function:
Nullable address
A nullable address often represents a potentially absent value:- There might be an
adminAddressin the contract’s storage, but it may be unset. - There might be an
sendExcessesTofield in a message: if exists, send surplus there; if not, keep it.
address? represents a “none address”: either an internal address or none. Check for null before usage:
address? is serialized and is not null, it occupies 267 as the standard address. If it is null, then it occupies only 2 zero bits, a so-called addr_none.
The “none” address can be created using createAddressNone().
Any address
All external messages from outside world to blockchain contracts, such as wallet contracts, come from external addresses. To represent internal and external addresses, as well as nullable addresses, useany_address:
Casts
To manually operate on the bits of anaddress, cast it to a slice:
slice at the TVM level, such cast is permitted and is safe. Conversely, the cast in another direction is unsafe, because no validation is performed at runtime and any further use might fail: