Icon SunFilledIcon MoonStars
Icon SunFilledIcon MoonStars

Icon LinkTransaction

enum TransactionType : uint8 {
    Script = 0,
    Create = 1,
    Mint = 2,
}
nametypedescription
typeTransactionTypeTransaction type.
dataOne of TransactionScript, TransactionCreate, or TransactionMintTransaction data.

Transaction is invalid if:

  • type > TransactionType.Create
  • gasLimit > MAX_GAS_PER_TX
  • blockheight() < maturity
  • inputsCount > MAX_INPUTS
  • outputsCount > MAX_OUTPUTS
  • witnessesCount > MAX_WITNESSES
  • No inputs are of type InputType.Coin or InputType.Message with input.dataLength == 0
  • More than one output is of type OutputType.Change for any asset ID in the input set
  • Any output is of type OutputType.Change for any asset ID not in the input set
  • More than one input of type InputType.Coin for any Coin ID in the input set
  • More than one input of type InputType.Contract for any Contract ID in the input set
  • More than one input of type InputType.Message for any Message ID in the input set

When serializing a transaction, fields are serialized as follows (with inner structs serialized recursively):

  1. uint8, uint16, uint32, uint64: big-endian right-aligned to 8 bytes.
  2. byte[32]: as-is.
  3. 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.

Icon LinkTransactionScript

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,
}
nametypedescription
gasPriceuint64Gas price for transaction.
gasLimituint64Gas limit for transaction (including predicate gas).
maturityuint32Block until which tx cannot be included.
scriptLengthuint16Script length, in instructions.
scriptDataLengthuint16Length of script input data, in bytes.
inputsCountuint8Number of inputs.
outputsCountuint8Number of outputs.
witnessesCountuint8Number of witnesses.
receiptsRootbyte[32]Merkle root of receipts.
scriptbyte[]Script to execute.
scriptDatabyte[]Script input data (parameters).
inputsInput[]List of inputs.
outputsOutput[]List of outputs.
witnessesWitness[]List of witnesses.

Given helper len() that returns the number of bytes of a field.

Transaction is invalid if:

  • Any output is of type OutputType.ContractCreated
  • scriptLength > MAX_SCRIPT_LENGTH
  • scriptDataLength > MAX_SCRIPT_DATA_LENGTH
  • scriptLength * 4 != len(script)
  • scriptDataLength != len(scriptData)
  • gasLimit is less than the sum of all predicateGasUsed for InputType.Coin or InputType.Message where predicate length is greater than zero.

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.

Icon LinkTransactionCreate

nametypedescription
gasPriceuint64Gas price for transaction.
gasLimituint64Gas limit for transaction (including predicate gas).
maturityuint32Block until which tx cannot be included.
bytecodeLengthuint16Contract bytecode length, in instructions.
bytecodeWitnessIndexuint8Witness index of contract bytecode to create.
storageSlotsCountuint16Number of storage slots to initialize.
inputsCountuint8Number of inputs.
outputsCountuint8Number of outputs.
witnessesCountuint8Number of witnesses.
saltbyte[32]Salt.
storageSlots(byte[32], byte[32]])[]List of storage slots to initialize (key, value).
inputsInput[]List of inputs.
outputsOutput[]List of outputs.
witnessesWitness[]List of witnesses.

Transaction is invalid if:

  • Any input is of type InputType.Contract or InputType.Message where input.dataLength > 0
  • Any output is of type OutputType.Contract or OutputType.Variable or OutputType.Message
  • More than one output is of type OutputType.Change with asset_id of zero
  • Any output is of type OutputType.Change with non-zero asset_id
  • It does not have exactly one output of type OutputType.ContractCreated
  • bytecodeLength * 4 > CONTRACT_MAX_SIZE
  • tx.data.witnesses[bytecodeWitnessIndex].dataLength != bytecodeLength * 4
  • bytecodeWitnessIndex >= tx.witnessesCount
  • The keys of storageSlots are not in ascending lexicographic order
  • The computed contract ID (see below) is not equal to the contractID of the one OutputType.ContractCreated output
  • storageSlotsCount > MAX_STORAGE_SLOTS
  • The Sparse Merkle tree root of storageSlots is not equal to the stateRoot of the one OutputType.ContractCreated output

Creates a contract with contract ID as computed here.

Icon LinkTransactionMint

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.

nametypedescription
txPointerTXPointerThe location of the Mint transaction in the block.
outputsCountuint8Number of outputs.
outputsOutput[]List of outputs.

Transaction is invalid if:

  • Any output is not of type OutputType.Coin
  • Any two outputs have the same asset_id
  • txPointer is zero or doesn't match the block.
Icon ListDetailsOn this page