address— a standard address; also called “internal address”address?(nullable) — a pattern to say “potentially missing”; also called “internal or none”, sometimes “maybe address”any_address— allows storing external addresses as well (for emitting logs to the off-chain, for example)
Address = workchain + hash
A standard (internal)address consists of:
- workchain (int8) — currently masterchain (-1) or basechain (0)
- hash (aka “account ID”, uint256) — 256 bits
address has methods to retrieve these properties:
address occupies 267 bits: ‘100’ (standard address no anycast) + workchain + hash.
For a detailed description, see Addresses overview in TON.
During deserialization (for example, when a message contains an address field), the value is automatically validated.
If parsing succeeds, the resulting address is guaranteed to be valid.
Operator == works for addresses
Compare addresses using == or !=. Internally, it is represented as a binary slice without references, that’s why == just tests for bits equality.
Embedding a const address into a contract
A constant address can be embedded using theaddress() function:
Nullable address as “missing”
A nullable address is often used to represent a potentially absent value. Examples:adminAddressin a storage, but it may be unsetsendExcessesToin a message — if exists, send money there; if not, keep on contract’s balance
address? means “internal or none”.
From the type system perspective, it either holds an address or null. So, it must be checked for null before usage.
When
null, it is serialized as ‘00’ — two zero bits, “addr_none”. So, address? is 2/267 bits.
It aligns with client-side code. For example, storeMaybeAddress in TypeScript emits the same binary format.any_address — internal/external/none
TON also defines external addresses, although they are rarely used. To represent “any address valid for TON”, use any_address.
createAddressNone().
Casting to a slice and vice versa
To manually operate on the bits of an address, cast it to a slice:
getWorkchain() or serialization will fail.