Built-in Objects Documentation
This document provides detailed introduction to the built-in objects defined by the system, including Self object and BVM object. The document covers object names, functions, attributes, methods, and usage examples, aiming to provide clear and accurate function usage guides for developers.
1. Self Object
- Object Name: Self
- Short Description: Represents the "self" concept built-in object, used for handling member access related to the current context.
- Example:python
# Initialize Self object and set attributes def __init__(pubKeyH: hex): self.pubKeyHash = pubKeyH # Add pubKeyHash attribute to self object and assign value # Use Self object attributes def verify_key(signature: string): result = CheckSig(self.pubKeyHash, signature)
2. BVM Object
- Object Name: BVM (Bytecode Virtual Machine)
- Short Description: Represents the bytecode virtual machine built-in object, provides access to virtual machine metadata (such as version, input/output counts).
- Predefined Member Mapping Table:
Member Name Corresponding Value Purpose "version" 1 Virtual machine version number "locktime" 2 Lock time "inputCount" 3 Input data count "outputCount" 4 Output data count "inputsHash" 5 Hash value of input data "unlockingInput" 6 Unlocking input data "outputsHash" 7 Hash value of output data - Example:python
# Process transaction data and verify tx_data = Cat(pretx.VLIO, tx_data) # Concatenate transaction data txid = Hash256(tx_data) # Calculate 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