enum TransactionType : uint8 {
Script = 0,
Create = 1,
Mint = 2,
}
name | type | description |
---|---|---|
type | TransactionType | Transaction type. |
data | One of TransactionScript , TransactionCreate , or TransactionMint | Transaction data. |
Transaction is invalid if:
type > TransactionType.Mint
inputsCount > MAX_INPUTS
outputsCount > MAX_OUTPUTS
witnessesCount > MAX_WITNESSES
size > MAX_TRANSACTION_SIZE
. The size of a transaction is calculated as the sum of the sizes of its static and dynamic parts, as determined by canonical serialization. InputType.Coin
or InputType.Message
with input.dataLength
== 0 OutputType.Change
for any asset ID in the input set OutputType.Change
for any asset ID not in the input set InputType.Coin
for any Coin ID in the input set InputType.Contract
for any Contract ID in the input set InputType.Message
for any Message ID in the input set When serializing a transaction, fields are serialized as follows (with inner structs serialized recursively):
uint8
, uint16
, uint32
, uint64
: big-endian right-aligned to 8 bytes. byte[32]
: as-is. byte[]
: as-is, with padding zeroes aligned to 8 bytes. When deserializing a transaction, the reverse is done. If there are insufficient bytes or too many bytes, the transaction is invalid.
TransactionScript
enum ReceiptType : uint8 {
Call = 0,
Return = 1,
ReturnData = 2,
Panic = 3,
Revert = 4,
Log = 5,
LogData = 6,
Transfer = 7,
TransferOut = 8,
ScriptResult = 9,
MessageOut = 10,
Mint = 11,
Burn = 12,
}
name | type | description |
---|---|---|
scriptGasLimit | uint64 | Gas limits the script execution. |
scriptLength | uint16 | Script length, in instructions. |
scriptDataLength | uint16 | Length of script input data, in bytes. |
policyTypes | uint32 | Bitfield of used policy types. |
inputsCount | uint8 | Number of inputs. |
outputsCount | uint8 | Number of outputs. |
witnessesCount | uint8 | Number of witnesses. |
receiptsRoot | byte[32] | Merkle root of receipts. |
script | byte[] | Script to execute. |
scriptData | byte[] | Script input data (parameters). |
policies | Policy [] | List of policies, sorted by PolicyType . |
inputs | Input [] | List of inputs. |
outputs | Output [] | List of outputs. |
witnesses | Witness [] | List of witnesses. |
Given helper max_gas()
returns the maximum gas that the transaction can use.
Given helper len()
that returns the number of bytes of a field.
Given helper count_ones()
that returns the number of ones in the binary representation of a field.
Given helper count_variants()
that returns the number of variants in an enum.
Given helper sum_variants()
that sums all variants of an enum.
Transaction is invalid if:
OutputType.Change
with identical asset_id
fields. OutputType.ContractCreated
scriptLength > MAX_SCRIPT_LENGTH
scriptDataLength > MAX_SCRIPT_DATA_LENGTH
scriptLength * 4 != len(script)
scriptDataLength != len(scriptData)
max_gas(tx) > MAX_GAS_PER_TX
PolicyType.GasPrice
count_ones(policyTypes) > count_variants(PolicyType)
policyTypes > sum_variants(PolicyType)
len(policies) > count_ones(policyTypes)
Note: when signing a transaction,
receiptsRoot
is set to zero.Note: when verifying a predicate,
receiptsRoot
is initialized to zero.Note: when executing a script,
receiptsRoot
is initialized to zero.
The receipts root receiptsRoot
is the root of the binary Merkle tree of receipts. If there are no receipts, its value is set to the root of the empty tree, i.e. 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
.
TransactionCreate
name | type | description |
---|---|---|
bytecodeLength | uint16 | Contract bytecode length, in instructions. |
bytecodeWitnessIndex | uint8 | Witness index of contract bytecode to create. |
policyTypes | uint32 | Bitfield of used policy types. |
storageSlotsCount | uint16 | Number of storage slots to initialize. |
inputsCount | uint8 | Number of inputs. |
outputsCount | uint8 | Number of outputs. |
witnessesCount | uint8 | Number of witnesses. |
salt | byte[32] | Salt. |
policies | Policy [] | List of policies. |
storageSlots | (byte[32], byte[32]])[] | List of storage slots to initialize (key, value). |
inputs | Input [] | List of inputs. |
outputs | Output [] | List of outputs. |
witnesses | Witness [] | List of witnesses. |
Given helper max_gas()
returns the maximum gas that the transaction can use.
Given helper count_ones()
that returns the number of ones in the binary representation of a field.
Given helper count_variants()
that returns the number of variants in an enum.
Given helper sum_variants()
that sums all variants of an enum.
Transaction is invalid if:
InputType.Contract
or InputType.Message
where input.dataLength > 0
OutputType.Contract
or OutputType.Variable
or OutputType.Message
OutputType.Change
with asset_id
of zero OutputType.Change
with non-zero asset_id
OutputType.ContractCreated
bytecodeLength * 4 > CONTRACT_MAX_SIZE
tx.data.witnesses[bytecodeWitnessIndex].dataLength != bytecodeLength * 4
bytecodeWitnessIndex >= tx.witnessesCount
storageSlots
are not in ascending lexicographic order contractID
of the one OutputType.ContractCreated
output storageSlotsCount > MAX_STORAGE_SLOTS
max_gas(tx) > MAX_GAS_PER_TX
storageSlots
is not equal to the stateRoot
of the one OutputType.ContractCreated
output PolicyType.GasPrice
count_ones(policyTypes) > count_variants(PolicyType)
policyTypes > sum_variants(PolicyType)
len(policies) > count_ones(policyTypes)
Creates a contract with contract ID as computed here .
TransactionMint
The transaction is created by the block producer and is not signed. Since it is not usable outside of block creation or execution, all fields must be fully set upon creation without any zeroing.
This means that the transaction ID must also include the correct txPointer
value, not zeroed out.
name | type | description |
---|---|---|
txPointer | TXPointer | The location of the Mint transaction in the block. |
inputContract | InputContract | The contract UTXO that assets are minted to. |
outputContract | OutputContract | The contract UTXO that assets are being minted to. |
mintAmount | uint64 | The amount of funds minted. |
mintAssetId | byte[32] | The asset IDs corresponding to the minted amount. |
Transaction is invalid if:
txPointer
is zero or doesn't match the block. outputContract.inputIndex
is not zero