Skip to content

Built-in Objects Reference


The UTXO_Compiler contract language provides two built-in objects: BVM and self. This document covers the names, purposes, properties, methods, and usage examples for each object, aiming to provide developers with a clear and accurate usage guide.


1. Self Object

  • Object Name: Self
  • Description: A built-in object representing the concept of "self", used for member access related to the current context.
  • Example:
    python
    # Using the Self object property
    def verify_key(signature: string):
        result = CheckSig(self.pubKeyHash, signature)

2. BVM Object

  • Object Name: BVM (Bytecode Virtual Machine)
  • Description: A built-in object representing the bytecode virtual machine, providing access to VM metadata such as version, input/output counts.
  • Predefined Member Mapping Table:
    Member NameCorresponding ValuePurpose
    "version"1VM version number
    "locktime"2Lock time
    "inputCount"3Number of inputs
    "outputCount"4Number of outputs
    "inputsHash"5Hash of input data
    "unlockingInput"6Unlocking input data
    "outputsHash"7Hash of output data
  • Example:
    python
    # Process transaction data and verify
    tx_data = Cat(pretx.VLIO, tx_data)  # concatenate transaction data
    txid = Hash256(tx_data)  # compute transaction ID
    
    # Access BVM object metadata
    meta_data = BVM.unlockingInput  # get unlocking input metadata
    {meta_data_txid, meta_data_remain} = Split(meta_data, 32)  # extract transaction ID from metadata
    
    EqualVerify(txid, meta_data_txid)  # verify transaction ID consistency

Next Steps


🇨🇳 中文版

Released under the MIT License.