Transaction Types Explained

Introduction

OP_NET supports three distinct transaction types, each serving a specific purpose within the network. Understanding these types is essential for building applications that interact correctly with OP_NET.

OP_NET transaction types
OP_NET Transaction Types Transaction Types Deployment Interaction Generic Smart Contract Bitcoin Smart Contract --> Creates Smart Contract --> Calls Bitcoin (straight) --> Transfers
  • Deployment: Deploys new smart contracts to the network.
  • Interaction: Invokes methods on deployed smart contracts.
  • Generic: Standard Bitcoin transfers without contract interaction.

The transaction types are defined by the OPNetTransactionTypes enumeration, available in the OPNetTransactionTypes.ts source file.

OPNetTransactionTypes enum
typescript
enum OPNetTransactionTypes {
    Generic = 0,       // Basic Bitcoin transaction
    Interaction = 1,   // Contract interaction
    Deployment = 2,    // Contract deployment
}

Generic

Generic transactions represent standard Bitcoin transactions that do not involve OP_NET smart contract interaction. It also serves as the base structure for Deployment and Interaction transaction types.

The complete ITransactionBase interface defines the properties common to all transaction types and source code is available in the ITransactionBase.ts file.

Simplified version of ITransactionBase interface
typescript
interface ITransactionBase {
    // Identity
    id: string;              // Transaction ID
    hash: string;            // Transaction hash
    index: number;           // Index in block
    blockNumber?: bigint;    // Block number (if confirmed)

    // Fees & Gas
    burnedBitcoin: bigint;   // Satoshis burned
    priorityFee: bigint;     // Priority fee paid
    maxGasSat: bigint;       // Maximum gas in satoshis
    gasUsed: bigint;         // Gas consumed
    specialGasUsed: bigint;  // Special gas consumed

    // Inputs/Outputs
    inputs: TransactionInput[];    // Transaction inputs
    outputs: TransactionOutput[];  // Transaction outputs

    // Type
    OPNetType: OPNetTransactionTypes;

    // Challenge (if applicable)
    pow?: ProofOfWorkChallenge;

    // Receipt data (inherited from TransactionReceipt)
    receipt?: Uint8Array;
    receiptProofs: string[];
    events: ContractEvents;
    revert?: string;
}

ITransactionBase Properties

Identity

The identity properties uniquely identify a transaction within the OP_NET network. This includes the transaction ID, hash, position index within the block, and the block number if the transaction has been confirmed.

Fees and Gas

Fee and gas properties track the economic aspects of transaction execution. These include the amount of satoshis burned, priority fees paid for faster processing, maximum gas allocation, and the actual gas consumed during execution. Special gas consumption is tracked separately for operations requiring additional computational resources.

Inputs and Outputs

Input and output properties represent the Bitcoin UTXO model underlying OP_NET transactions. Inputs reference previously unspent outputs being consumed, while outputs define new UTXOs created by the transaction.

Type

The type property identifies the transaction category using the OPNetTransactionTypes enumeration, distinguishing between Generic, Deployment, and Interaction transactions.

Challenge

The challenge property contains proof-of-work data when applicable, used for epoch mining submissions where miners provide SHA-1 collision solutions.

Receipt

Receipt properties contain execution results including the raw receipt data, cryptographic proofs for verification, emitted contract events, and revert information if the transaction failed during execution.

Deployment

Deployment transactions represent smart contract deployments on the OP_NET network. These transactions extend the generic transaction structure with additional properties specific to contract creation, including the compiled bytecode, assigned contract address, and optional constructor arguments for initialization.

The complete IDeploymentTransaction interface source code is available in the IDeploymentTransaction.ts file.

Simplified version of IDeploymentTransaction interface
typescript
interface IDeploymentTransaction extends ICommonTransaction<OPNetTransactionTypes.Deployment> {
    // Deployment details
    contractAddress: string;     // Deployed contract address
    contractPublicKey: Address;  // Contract's public key
    bytecode: Uint8Array;        // Contract bytecode

    // Deployer details
    from?: Address;              // Deployer address
    deployerPubKeyHash: Uint8Array; // Deployer's public key hash

    // Initialization
    constructorCalldata?: Uint8Array; // Constructor arguments
}

IDeploymentTransaction Properties

Deployment Details

These properties identify the deployed contract including its assigned address, public key, and the compiled bytecode that defines the contract's logic.

Deployer Details

Deployer properties identify the account responsible for deploying the contract, including the deployer's address and public key hash used for verification.

Initialization

The initialization property contains constructor calldata passed to the contract during deployment, allowing initial state configuration and parameter setting.

Interaction

Interaction transactions represent method calls on deployed smart contracts within the OP_NET network. These transactions extend the generic transaction structure with additional properties specific to contract invocation, including the target contract address, function calldata, and sender identification.

The complete IInteractionTransaction interface source code is available in the IInteractionTransaction.ts file.

Simplified version of IInteractionTransaction interface
typescript
interface IInteractionTransaction extends ICommonTransaction<InteractionType> {
    // Contract details
    calldata?: Uint8Array;       // Function calldata
    contractAddress?: string;    // Target contract
    contractPublicKey: Address;  // Contract's public key

    // Sender details
    from?: Address;              // Sender address (taproot)
    senderPubKeyHash: Uint8Array; // Sender's public key hash
    interactionPubKey: Uint8Array; // Interaction public key

    // Metadata
    contractSecret: Uint8Array;  // Contract secret
    wasCompressed: boolean;      // Was calldata compressed
}

IInteractionTransaction Properties

Contract Details

These properties identify the target contract and the operation being performed, including the encoded function calldata, contract address, and the contract's public key for verification.

Sender Details

Sender properties identify the account initiating the contract interaction, including the sender's taproot address, public key hash, and the interaction-specific public key used for transaction signing.

Metadata

Metadata properties contain additional information about the interaction, including the contract secret used for cryptographic operations and a flag indicating whether the calldata was compressed during transmission.