Output
March 14, 2024 ยท View on GitHub
enum OutputType : uint8 {
Coin = 0,
Contract = 1,
Change = 2,
Variable = 3,
ContractCreated = 4,
}
| name | type | description |
|---|---|---|
type | OutputType | Type of output. |
data | One of OutputCoin, OutputContract, OutputChange, OutputVariable, or OutputContractCreated. | Output data. |
Transaction is invalid if:
type > OutputType.ContractCreated
OutputCoin
| name | type | description |
|---|---|---|
to | byte[32] | Receiving address or predicate root. |
amount | uint64 | Amount of coins to send. |
asset_id | byte[32] | Asset ID of coins. |
OutputContract
| name | type | description |
|---|---|---|
inputIndex | uint16 | Index of input contract. |
balanceRoot | byte[32] | Root of amount of coins owned by contract after transaction execution. |
stateRoot | byte[32] | State root of contract after transaction execution. |
Transaction is invalid if:
inputIndex >= tx.inputsCounttx.inputs[inputIndex].type != InputType.Contract
Note: when signing a transaction,
balanceRootandstateRootare set to zero.Note: when verifying a predicate or executing a script,
balanceRootandstateRootare initialized to zero.
The balance root balanceRoot is the root of the SMT of balance leaves. Each balance is a uint64, keyed by asset ID (a byte[32]).
The state root stateRoot is the root of the SMT of storage slots. Each storage slot is a byte[32], keyed by a byte[32].
OutputChange
| name | type | description |
|---|---|---|
to | byte[32] | Receiving address or predicate root. |
amount | uint64 | Amount of coins to send. |
asset_id | byte[32] | Asset ID of coins. |
Transaction is invalid if:
- any other output has type
OutputType.OutputChangeand asset IDasset_id(i.e. only one change output per asset ID is allowed)
Note: when signing a transaction,
amountis set to zero.Note: when verifying a predicate or executing a script,
amountis initialized to zero.
This output type indicates that the output's amount may vary based on transaction execution, but is otherwise identical to a Coin output. An amount of zero after transaction execution indicates that the output is unspendable and can be pruned from the UTXO set.
OutputVariable
| name | type | description |
|---|---|---|
to | byte[32] | Receiving address or predicate root. |
amount | uint64 | Amount of coins to send. |
asset_id | byte[32] | Asset ID of coins. |
Note: when signing a transaction,
to,amount, andasset_idare set to zero.Note: when verifying a predicate or executing a script,
to,amount, andasset_idare initialized to zero.
This output type indicates that the output's amount and owner may vary based on transaction execution, but is otherwise identical to a Coin output. An amount of zero after transaction execution indicates that the output is unspendable and can be pruned from the UTXO set.
OutputContractCreated
| name | type | description |
|---|---|---|
contractID | byte[32] | Contract ID. |
stateRoot | byte[32] | Initial state root of contract. |