Symbolic Transaction¶
Overview¶
In this section, we define data types and validation logic of a Symbolic Transaction.
Data Types¶
In addition to the data types introduced at the ledger level, we define the types related to the transaction validation.
Basic types¶
Int128
is a \(128\)-bit signed integer.
Symbolic Transaction types¶
Datum
is a wrapper aroundF
.AssetValue
is a record type with the following fields:assetPolicy
is of typeAddress
. It is the address of the initial UTxO that contains the token.assetName
is a wrapper around typeF
. It is the datum of the initial UTxO that contains the token.assetQuantity
is of typeInt128
.
Value
is a list[AssetValue]
.Output
is a record type with the following fields:txoAddress
is of typeAddress
. It is the address of the output.txoValue
is of typeValue
. It is the value in the output.txoDatum
is of typeDatum
. It is the extra input to the output's spending condition.
InputRef
is a record type with the following fields:refTxId
is of typeHash Transaction
. It is the hash of the transaction that produced this output.refTxIdx
is a wrapper aroundF
. It is the index of the output in the list of outputs of the transaction that produced this output.
Input
is a record type with the following fields:txiReference
is of typeInputRef
. It is the reference to the output being spent.txiOutput
is of typeOutput
. It is the contents of the output being spent.
Transaction
is a record type with the following fields:[Input]
: list of inputs of the transaction.[Output]
: list of outputs of the transaction.
TransactionWitness
is the supplemental data used in the transaction validation (see below).
UTxO set¶
Transaction outputs can be used to describe the state of the ledger. When a valid transaction is applied to the ledger, its outputs are added to the active UTxO set which is a set of all unspent transaction outputs. When an output becomes spent, it is removed from the set.
In order for an output to be considered spent, the following conditions must be met:
- A valid transaction that contains the output among its inputs must be applied to the ledger.
- The address on the envelope must be the same as the address of the output.
Other transaction inputs are called reference inputs. They influence transaction validation but are not considered spent.
Validation rules¶
We now describe the Symbolic Transaction validation rules.
The transaction validation function has the following signature:
Transaction validation proceeds as follows:
- Decode the first argument as
Hash Value
(usingTransactionWitness
data). - Decode
txeTransactionId
field ofTransactionEnvelope
asHash Transaction
(usingTransactionWitness
data). -
Check that every transaction input is in the active UTxO set:
a. It must be produced by some transaction from an earlier transaction batch or bridged in from the underlying blockchain.
b. It must not be spent in any transaction batch between its creation and the current batch.
-
Check that there is at least one transaction input corresponding to the envelope's address.
- Check that the circuit corresponding to the envelope's address outputs
0
. - Check that all outputs contain non-negative value.
- If checks 3-6 are successful, we set the first output to
0
. Otherwise, we set it to a non-zero value. -
Calculate the multi-asset value difference between the inputs (at the envelope's address) and the outputs, exclude the value of the asset policy associated with the address, hash it, and return as the second output. To this difference, we add decoded first argument and set it as second output of this function.
Note
An address \(A\) can mint and burn tokens of policy \(A\). The circuit that locks outputs at the address is used as a minting policy.