tip | title | description | author | discussions-to | status | type | layer | created | requires | replaces |
---|---|---|---|---|---|---|---|---|---|---|
54 |
Anchor Output Type |
Defines the IOTA 2.0 Anchor Output used to anchor commitments into Layer 1. |
Philipp Gackstatter (@PhilippGackstatter) <philipp.gackstatter@iota.org> |
Draft |
Standards |
Core |
2023-11-02 |
TIP-21, TIP-22, TIP-38 and TIP-47 |
TIP-18 |
An Anchor Output represents an output in the ledger with two control levels and a permanent Anchor Address. The anchor
owns other outputs that are locked under Anchor Address. The anchor keeps track of state transitions (State Index
counter) and can be used to anchor layer 2 state as metadata into the UTXO ledger. The Anchor ID, the unique identifier,
is generated deterministically by the protocol and is not allowed to change in any future state transitions.
The Anchor Output can be seen as the successor to the Alias Output in TIP-18. However the Anchor Output is not a strict extension of the functionality of the Alias Output.
Compared to the Alias Output:
- Add
Mana
field to theAnchor
. - Remove
Foundry Counter
field. The Account Output can hold Foundries instead. See that TIP for Alias Output migration details. - Remove
Native Tokens
field. See TIP-38 (Native Token Migration) for migration details.
This TIP defines an Anchor Output type for the use case of anchoring state into Layer 1. The prime example for state anchoring are IOTA Smart Contract Chains. This TIP accommodates that use case in particular through the two levels of control given by the state controller and governor. A governor can control the parameters of the chain and who is allowed to change the state, but cannot do so themselves, while a state controller is allowed to update the state.
Data types and subschemas used throughout this TIP are defined in TIP-21.
Protocol parameters used throughout this TIP are defined in TIP-49.
TIP-45 is the basis for output validation in this TIP.
A Metadata Feature that can only be changed by the State Controller.
State Metadata Feature
Defines a map of key-value pairs that is stored in the output, that can only be modified by the State Controller.
Name | Type | Description | |||||||||
Feature Type | uint8 | Set to value 3 to denote a State Metadata Feature. | |||||||||
Entries Count | uint8 | The number of entries in the map. | |||||||||
Entries anyOf |
Metadata EntryA map entry consisting of a string key and an arbitrary byte value.
|
The same syntactic transaction validation rules as for the Metadata Feature defined in Metadata Feature (Additional Transaction Syntactic Validation Rules) apply.
Additional constraints are defined in the Anchor Output section.
An unlock condition defined solely for Anchor Output. It is functionally equivalent to an Address Unlock
Condition, however there are additional transition constraints defined for the Anchor UTXO state machine that can
only be carried out by the State Controller Address
, hence the distinct unlock condition type.
State Controller Address Unlock Condition
Defines the State Controller Address that owns this output. It can unlock the output with the proper Unlock in a transaction that state transitions the anchor output.
Name | Type | Description |
Unlock Condition Type | uint8 | Set to value 4 to denote a State Controller Address Unlock Condition. |
Address oneOf |
Ed25519 AddressAn Address derived from an Ed25519 Public Key. Defined in TIP-38 (Ed25519 Address). Account AddressAn Address derived from an Account ID which can be unlocked by unlocking the corresponding Account. Defined in TIP-38 (Account Address). NFT AddressAn Address derived from an NFT ID which can be unlocked by unlocking the corresponding NFT. Defined in TIP-38 (NFT Address). Anchor AddressAn Address derived from an Anchor ID which can be unlocked by unlocking the corresponding Anchor. Defined in TIP-38 (Anchor Address). Multi AddressDefines a Multi Address that consists of addresses with weights and a threshold value. The Multi Address can be unlocked if the cumulative weight of all unlocked addresses is equal to or exceeds the threshold. Defined in TIP-52 (Multi Address). Restricted AddressAn address that contains another address and allows for configuring its capabilities. Defined in TIP-50 (Restricted Address). |
The additional constraints are defined in the Anchor Output section.
An unlock condition defined solely for Anchor Output. It is functionally equivalent to an Address Unlock
Condition, however there are additional transition constraints defined for the Anchor UTXO state machine that can
only be carried out by the Governor Address
, hence the distinct unlock condition type.
Governor Address Unlock Condition
Defines the Governor Address that owns this output. It can unlock the output with the proper Unlock in a transaction that governance transitions the anchor output.
Name | Type | Description |
Unlock Condition Type | uint8 | Set to value 5 to denote a Governor Address Unlock Condition. |
Address oneOf |
Ed25519 AddressAn Address derived from an Ed25519 Public Key. Defined in TIP-38 (Ed25519 Address). Account AddressAn Address derived from an Account ID which can be unlocked by unlocking the corresponding Account. Defined in TIP-38 (Account Address). NFT AddressAn Address derived from an NFT ID which can be unlocked by unlocking the corresponding NFT. Defined in TIP-38 (NFT Address). Anchor AddressAn Address derived from an Anchor ID which can be unlocked by unlocking the corresponding Anchor. Defined in TIP-38 (Anchor Address). Multi AddressDefines a Multi Address that consists of addresses with weights and a threshold value. The Multi Address can be unlocked if the cumulative weight of all unlocked addresses is equal to or exceeds the threshold. Defined in TIP-52 (Multi Address). Restricted AddressAn address that contains another address and allows for configuring its capabilities. Defined in TIP-50 (Restricted Address). |
The additional constraints are defined in the Anchor Output section.
A transaction may consume an output that belongs to an Anchor Address by transitioning the anchor output with the
matching Anchor ID
. This serves the exact same purpose as providing a signature to unlock an output locked under a
private key backed address, such as Ed25519 Addresses.
On protocol level, anchor unlocking is done using a new unlock type, called Anchor Unlock.
Anchor Unlock
Points to the unlock of a consumed Anchor Output.
Name | Type | Description |
Unlock Type | uint8 | Set to value 3 to denote an Anchor Unlock. |
Anchor Reference Unlock Index | uint16 | Index of input and unlock corresponding to an Anchor Output. |
This unlock is similar to the Reference Unlock. However, it is valid if and only if the input of the transaction
at index Anchor Reference Unlock Index
is an anchor output with the same Anchor ID
as the one derived from the
Address
field of the to-be unlocked output.
Additionally, the Anchor Unlocks must also be ordered to prevent circular dependencies:
If the i-th Unlock of a transaction is an Anchor Unlock and has Anchor Reference Unlock Index
set to k, it must
hold that i > k. Hence, an Anchor Unlock can only reference an Unlock (unlocking the corresponding anchor) at a
smaller index.
For example the scenario where Anchor A
is locked to the address of Anchor B
while Anchor B
is in locked to the
address of Anchor A
introduces a circular dependency and is not well-defined. By requiring the Unlocks to be ordered
as described above, a transaction consuming Anchor A
as well as Anchor B
can never be valid as there would always
need to be one Anchor Unlock referencing a greater index.
- It must hold that 0 ≤
Anchor Reference Unlock Index
<Max Inputs Count - 1
.
- The address of the unlocking condition of the input being unlocked must be an Anchor Address.
- The index
i
of the Anchor Unlock is the index of the input in the transaction that it unlocks.Anchor Reference Unlock Index
must be <i
. Anchor Reference Unlock Index
defines a previous input of the transaction and its unlock. This input must be an Anchor Output withAnchor ID
that refers to the Anchor Address being unlocked.- The referenced Anchor Output must be unlocked.
The Anchor Output is a specific implementation of a UTXO state machine. Anchor ID
, the unique identifier of an
instance of the deployed state machine, is generated deterministically by the protocol and is not allowed to change in
any future transitions.
An Anchor Output is an output with a permanent Anchor Address and owns other outputs that are locked under this Anchor Address.
Anchor Output
An anchor in the ledger that can be controlled by the state and governance controllers.
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||
Output Type | uint8 | Set to value 2 to denote an Anchor Output. | ||||||||||||||||||||||||||||||||||||||||||
Amount | uint64 | The amount of IOTA coins held by the output. | ||||||||||||||||||||||||||||||||||||||||||
Mana | uint64 | The amount of Stored Mana held by the output. | ||||||||||||||||||||||||||||||||||||||||||
Anchor ID | ByteArray[32] | Unique identifier of the anchor, which is the BLAKE2b-256 hash of the Output ID that created it. Anchor Address = Anchor Address Type || Anchor ID. | ||||||||||||||||||||||||||||||||||||||||||
State Index | uint32 | A counter that must increase by 1 every time the anchor is state transitioned. | ||||||||||||||||||||||||||||||||||||||||||
Unlock Conditions Count | uint8 | The number of unlock conditions following. | ||||||||||||||||||||||||||||||||||||||||||
Unlock Conditions atMostOneOfEach |
State Controller Address Unlock ConditionDefines the State Controller Address that owns this output. It can unlock the output with the proper Unlock in a transaction that state transitions the anchor output. Defined in TIP-54 (State Controller Address Unlock Condition).
Governor Address Unlock ConditionDefines the Governor Address that owns this output. It can unlock the output with the proper Unlock in a transaction that governance transitions the anchor output. Defined in TIP-54 (Governor Address Unlock Condition).
|
|||||||||||||||||||||||||||||||||||||||||||
Features Count | uint8 | The number of features following. | ||||||||||||||||||||||||||||||||||||||||||
Features atMostOneOfEach |
Metadata FeatureDefines a map of key-value pairs that is stored in the output. Defined in TIP-38 (Metadata Feature).
State Metadata FeatureDefines a map of key-value pairs that is stored in the output, that can only be modified by the State Controller. Defined in TIP-54 (State Metadata Feature).
|
|||||||||||||||||||||||||||||||||||||||||||
Immutable Features Count | uint8 | The number of immutable features following. Immutable features are defined upon deployment of the UTXO state machine and are not allowed to change in any future state transition. | ||||||||||||||||||||||||||||||||||||||||||
Immutable Features atMostOneOfEach |
Issuer FeatureIdentifies the validated issuer of the UTXO state machine. Defined in TIP-38 (Issuer Feature).
Metadata FeatureDefines a map of key-value pairs that is stored in the output. Defined in TIP-38 (Metadata Feature).
|
- It must hold true that
Unlock Conditions Count = 2
. Unlock Condition Type
of an Unlock Condition must define one of the following types:- State Controller Address Unlock Condition
- Governor Address Unlock Condition
- Unlock Conditions must be sorted in ascending order based on their
Unlock Condition Type
. - Syntactic validation of all present unlock conditions must pass.
- It must hold true that
0
≤Features Count
≤2
. Feature Type
of a Feature inFeatures
must define one of the following types:- Metadata Feature
- State Metadata Feature
- It must hold true that
0
≤Immutable Features Count
≤2
. Feature Type
of a Feature inImmutable Features
must define on of the following types:- Issuer Feature
- Metadata Feature
- Features must be sorted in ascending order based on their
Feature Type
both inFeatures
andImmutable Features
fields. - Syntactic validation of all present features must pass.
Address
of State Controller Address Unlock Condition andAddress
of Governor Address Unlock Condition must be different from the anchor address derived fromAnchor ID
.
- Explicit
Anchor ID
:Anchor ID
is taken as the value of theAnchor ID
field in the anchor output. - Implicit
Anchor ID
: When an anchor output is consumed as an input in a transaction and theAnchor ID
field is zeroed out, take the BLAKE2b-256 hash of theOutput ID
of the input asAnchor ID
. - For every non-zero explicit
Anchor ID
on the output side there must be a corresponding anchor on the input side. The corresponding anchor has the explicit or implicitAnchor ID
equal to that of the anchor on the output side.
Whenever an anchor output is consumed in a transaction, it means that the anchor is transitioned into its next state.
The current state is defined as the consumed anchor output, while the next state is defined as the anchor
output with the same explicit AnchorID
on the output side. There are two types of transitions: state transition
and governance transition
.
- State transition:
- A state transition is identified by an incremented
State Index
. - The
State Index
must be incremented by 1. - The unlock must correspond to the
Address
of State Controller Address Unlock Condition. - State transition can only change the following fields in the next state:
Amount
,Mana
,State Index
,State Metadata Feature
inFeatures
.
- A state transition is identified by an incremented
- Governance transition:
- A governance transition is identified by an unchanged
State Index
in next state. If there is no anchor output on the output side with a corresponding explicitAnchor ID
, the anchor is being destroyed. The next state is the empty state. The transaction is invalid if an Anchor Output is burned and the Can destroy Anchor Outputs flag in the Transaction Capabilities is unset. - The unlock must correspond to the
Address
of Governor Address Unlock Condition. - Governance transition must only change the following fields:
Address
of State Controller Address Unlock Condition,Address
of Governor Address Unlock Condition,Metadata Feature
inFeatures
.
- The
Metadata Feature
is optional, the governor can put additional info about the chain here, for example chain name, fee structure, supported VMs, list of access nodes, etc., anything that helps clients to fetch info (i.e. anchor balances) about the layer 2 network.
- A governance transition is identified by an unchanged
- When a consumed anchor output has Features defined in
Immutable Features
and a corresponding anchor output on the output side,Immutable Features
is not allowed to change.
- When Issuer Feature is present in an output and explicit
Anchor ID
is zeroed out, an input withAddress
field that corresponds toIssuer
must be unlocked in the transaction.
- Indexers and node plugins shall map the anchor address of the output derived with
Anchor ID
to the regular address -> output mapping table, so that given an Anchor Address, its most recent unspent anchor output can be retrieved.
The protocol parameters used in the following test vectors are the same as in TIP-49 (Protocol Parameters Hash).
The following test vector shows the calculation of the storage score according to TIP-47.
Anchor Output (json-encoded):
{
"type": 2,
"amount": "420000000",
"mana": "42",
"anchorId": "0x0000000000000000000000000000000000000000000000000000000000000000",
"stateIndex": 0,
"unlockConditions": [
{
"type": 4,
"address": {
"type": 8,
"accountId": "0x17432c5a7a672503480241125e3952414a7a320441080c624c264b004e09614a"
}
},
{
"type": 5,
"address": {
"type": 8,
"accountId": "0x17432c5a7a672503480241125e3952414a7a320441080c624c264b004e09614a"
}
}
],
"features": [
{
"type": 2,
"entries": {
"iota": "0x322e30"
}
}
],
"immutableFeatures": [
{
"type": 2,
"entries": {
"iota": "0x322e30"
}
}
]
}
Anchor Output (hex-encoded binary serialization):
0x0200b10819000000002a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000002040817432c5a7a672503480241125e3952414a7a320441080c624c264b004e09614a050817432c5a7a672503480241125e3952414a7a320441080c624c264b004e09614a01020104696f74610300322e3001020104696f74610300322e30
Anchor Output Storage Score: 236
.
Copyright and related rights waived via CC0.