Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Glossary

Transaction Input (TxIn)

A Transaction Input (TxIn) is a component of a blockchain transaction in the UTXO model that references and authorizes the spending of a previous unspent transaction output.
Chainscore © 2026
definition
BLOCKCHAIN GLOSSARY

What is Transaction Input (TxIn)?

A fundamental component of a blockchain transaction that specifies the source of funds being spent.

A Transaction Input (TxIn) is a data structure within a blockchain transaction that references and authorizes the spending of a previous unspent transaction output (UTXO). It acts as a pointer to the source of the funds, containing critical information such as the transaction ID (txid) and output index (vout) of the UTXO being consumed, a digital signature (or scriptSig) proving ownership, and a sequence number. In the UTXO model used by Bitcoin and similar blockchains, inputs do not specify an amount; the value is defined by the UTXO they reference.

The primary function of a TxIn is to provide cryptographic proof that the spender has the right to control the referenced funds. This is achieved through an unlocking script (often a digital signature) that satisfies the conditions—such as a public key hash or a more complex smart contract—encoded in the locking script of the previous UTXO. This process of linking an input to a prior output is what creates the verifiable chain of ownership, ensuring that only the legitimate owner can spend the coins.

A single transaction typically contains one or more inputs, which are collectively used to fund the transaction's outputs. For example, to send 1.5 BTC, a user's wallet might combine two inputs: one from a 1.0 BTC UTXO and another from a 0.6 BTC UTXO, totaling 1.6 BTC. The excess 0.1 BTC would typically be sent back to the sender as change in a new output. Each input must be signed individually, and the sum of the values of all referenced UTXOs must be greater than or equal to the sum intended for the outputs.

Key technical components of a TxIn include the outpoint (the txid and vout pair uniquely identifying the UTXO), the scriptSig (the unlocking data), and the sequence field. The sequence field was originally intended for transaction replacement but is now commonly used in layer-2 protocols like the Lightning Network for enforcing relative timelocks. Understanding inputs is essential for analyzing transaction fees, as the fee is calculated as: total input value - total output value.

In contrast to the account-based model used by Ethereum, where balances are stored in state, the UTXO model's input-output linkage provides inherent advantages for scalability and privacy through CoinJoin and other aggregation techniques. However, it also introduces complexity, as wallets must manage a set of discrete, chain-linked transaction fragments rather than a single balance.

how-it-works
BITCOIN CORE

How a Transaction Input Works

A technical breakdown of the Transaction Input (TxIn), the component that authorizes the spending of previous transaction outputs and forms the basis of Bitcoin's chain of ownership.

A Transaction Input (TxIn) is a data structure within a Bitcoin transaction that references and authorizes the spending of a specific Unspent Transaction Output (UTXO) from a previous transaction. It acts as a cryptographic proof of ownership, containing two essential fields: a pointer to the UTXO being spent (via a transaction ID and output index) and an unlocking script (commonly called scriptSig) that satisfies the spending conditions—like a digital signature—encoded in that UTXO's locking script. Without a valid input, a transaction cannot consume funds, making it the fundamental mechanism for transferring value on-chain.

The primary function of a TxIn is to solve the cryptographic puzzle set by the previous output's locking script. For a standard Pay-to-Public-Key-Hash (P2PKH) output, the input's scriptSig must provide a valid digital signature and the corresponding public key. This process validates the spender's right to use the coins. Each input also includes a sequence number, a legacy field originally intended for transaction replacement (Replace-By-Fee) and now used to signal Opt-In RBF or locktime constraints. It's crucial to understand that inputs do not specify an amount; the value is defined solely by the UTXO they reference.

A single transaction typically aggregates multiple inputs to meet a desired payment amount, similar to using several bills and coins to make a cash purchase. This aggregation is managed by the wallet software. When creating a transaction, the wallet selects UTXOs from its control, constructs an input for each, and calculates the total input value. The sum of all inputs must equal or exceed the sum of the new outputs (recipients) plus the transaction fee. Any surplus is sent back to the sender as change output, creating a new UTXO. This design ensures the total bitcoin in circulation is always accounted for.

The structure of an input creates Bitcoin's immutable chain of ownership. By pointing to a prior output's unique identifier, it forges a verifiable link back through the blockchain's history. This is how full nodes verify that the coins being spent haven't already been used in a different transaction—a check for double-spending. The network rules require every referenced UTXO to be unspent and valid, enforcing the core security model. Analyzing the inputs of a transaction, therefore, reveals the entire provenance of the funds being moved, from their coinbase generation or prior receipt to their current transfer.

Beyond standard payments, inputs enable advanced blockchain functionalities. They are integral to multi-signature schemes, where an input must provide multiple signatures, and Pay-to-Script-Hash (P2SH) or Pay-to-Taproot transactions, where the unlocking script reveals a redeem script or satisfies a Taproot spending condition. The design of inputs also underpins CoinJoin privacy protocols, where multiple participants combine their inputs into a single transaction to obscure the linkage between senders and receivers. Understanding inputs is essential for developers building wallets, analyzing on-chain data, or working with smart contracts on Bitcoin-derived platforms.

key-features
BITCOIN & UTXO-BASED BLOCKCHAINS

Key Features of a Transaction Input

A Transaction Input (TxIn) is a data structure that references and spends a previous transaction's unspent output (UTXO). It is a fundamental component of the Unspent Transaction Output (UTXO) model, proving ownership and authorizing the transfer of value.

01

Previous Transaction Hash & Index

This pair of fields acts as a precise pointer to the Unspent Transaction Output (UTXO) being spent.

  • Transaction Hash (txid): The cryptographic hash of the transaction containing the UTXO.
  • Output Index (vout): The position (starting from 0) of the specific output within that transaction's outputs list. Together, they uniquely identify the source of the funds, forming the basis of Bitcoin's chain of ownership.
02

Unlocking Script (ScriptSig)

The ScriptSig is the data field that provides the cryptographic proof required to satisfy the spending conditions (the locking script) of the referenced UTXO.

  • It typically contains a digital signature and a public key.
  • The script is executed alongside the referenced output's locking script. The transaction is only valid if the combined script evaluates to true.
  • This mechanism enforces ownership without revealing identities.
03

Sequence Number

A 32-bit field originally intended for transaction replacement (Replace-By-Fee) and relative timelocks.

  • Default value: 0xFFFFFFFF (4294967295) indicates the input is final and cannot be replaced.
  • nSequence < 0xFFFFFFFF: Can enable Relative Timelocks (CHECKSEQUENCEVERIFY), requiring a specific number of blocks or time to pass after the input's confirmation before it can be spent.
  • It is a critical component for advanced contract protocols like payment channels.
04

Witness Data (SegWit)

Introduced with the Segregated Witness (SegWit) upgrade, witness data is moved outside the traditional input structure to a separate field, solving transaction malleability.

  • Contains the signature and other witness elements (like public keys) previously in the ScriptSig.
  • Witness data is not part of the transaction ID hash, making the txid immutable.
  • Enables more complex scripts (like Taproot) and improves scalability by reducing the effective size of transactions for fee calculation.
05

Coinbase Input (Special Case)

The first transaction in every block is the coinbase transaction, which creates new bitcoin. Its input has unique properties:

  • Previous Transaction Hash: Set to 32 bytes of zeros (a null hash).
  • Output Index: Set to 0xFFFFFFFF (4294967295).
  • ScriptSig (Coinbase Data): Contains arbitrary data, including the block height and an extra nonce for mining. It does not spend a UTXO. This special input is the genesis of new currency supply in the system.
06

Input Validation Process

For a transaction to be valid, every input must pass a series of checks:

  1. Existence & Unspent Check: The referenced UTXO must exist and not already be spent (no double-spend).
  2. Script Validation: The input's unlocking script and the UTXO's locking script must execute successfully together.
  3. Value Conservation: The sum of the input values must be >= the sum of the output values (the difference is the transaction fee).
  4. Signature Verification: All required cryptographic signatures must be valid for the current transaction's data.
visual-explainer
BITCOIN CORE CONCEPT

Visualizing Transaction Inputs

A transaction input (TxIn) is the component of a Bitcoin transaction that specifies the source of funds being spent. It is a reference to a previous transaction's output, proving the spender has the right to use those coins.

A transaction input is a data structure that points to a previous unspent transaction output (UTXO). It acts as a cryptographic proof of ownership, authorizing the transfer of value. Each input contains three critical pieces of data: a pointer to the specific UTXO (via a transaction ID and output index), an unlocking script (commonly called a scriptSig), and a sequence number. The unlocking script provides the digital signature and public key that satisfy the conditions—or locking script—of the referenced UTXO, proving the spender controls the private key.

To visualize this, imagine a transaction as a set of levers (inputs) pulling value from specific, locked treasure chests (UTXOs). Each lever can only be pulled by the correct key (the signature). A single transaction can have multiple inputs, which are aggregated to meet the total output value. This design is fundamental to Bitcoin's UTXO model, where the entire state of the network is a set of discrete, spendable outputs, not account balances. Inputs are the mechanism for selecting and consuming these discrete units of value.

The process of creating an input involves the wallet software scanning the blockchain for UTXOs belonging to the user, a function often called coin selection. Once selected, the wallet constructs the input by referencing the chosen UTXO's location and generating a digital signature for it. This signature is placed in the scriptSig field. Importantly, once a UTXO is referenced as an input in a valid, confirmed transaction, it is permanently marked as spent and cannot be used again, preventing double-spending.

Advanced input features include the sequence number, which was originally intended for transaction replacement (replace-by-fee) and timelock functionality. Furthermore, inputs are the site of various script types, from the standard Pay-to-Public-Key-Hash (P2PKH) to more complex multisig or Pay-to-Script-Hash (P2SH) schemes. Analyzing the inputs of a transaction reveals its provenance, linking it directly to the history of all coins being moved, which is essential for blockchain analysis and auditing.

components
TRANSACTION ANATOMY

Core Components of a TxIn

A Transaction Input (TxIn) is a data structure that references a previous unspent transaction output (UTXO) to be consumed. It contains the cryptographic proof and unlocking conditions required to spend it.

01

Previous Transaction Hash (txid)

The transaction ID (txid) is the cryptographic hash of the previous transaction that created the UTXO being spent. This 32-byte identifier acts as a pointer to the specific output in the blockchain's ledger, allowing the network to locate and verify the source of the funds.

  • Purpose: Uniquely identifies the source transaction.
  • Format: A 32-byte double SHA-256 hash, typically represented as a 64-character hex string.
  • Example: a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d
02

Output Index (vout)

The output index (vout) is a zero-based integer that specifies which output from the referenced previous transaction is being spent. A single transaction can have multiple outputs, so this index is required to pinpoint the exact UTXO.

  • Purpose: Identifies the specific output within the source transaction.
  • Value: Typically 0 for the first output, 1 for the second, etc.
  • Mechanism: Combined with the txid, it forms a globally unique identifier for a UTXO: txid:vout.
03

Unlocking Script (scriptSig)

The unlocking script (scriptSig) provides the cryptographic proof that the spender is authorized to consume the referenced UTXO. It contains data like digital signatures and public keys that satisfy the conditions (the locking script) placed on the output.

  • Purpose: Provides authorization to spend.
  • Content: In a Pay-to-Public-Key-Hash (P2PKH) input, this includes a signature and the full public key.
  • Validation: The scriptSig is concatenated with the output's locking script and executed. A result of TRUE validates the spend.
04

Sequence Number

The sequence number is a 4-byte field originally intended for transaction replacement (Replace-by-Fee) and relative timelocks. It allows a transaction to be updated before confirmation.

  • Default Value: 0xFFFFFFFF (4294967295) indicates the input is final.
  • Relative Timelocks: A value with the most significant bit cleared (< 0x80000000) can encode a relative lock-time (e.g., 1000 blocks).
  • Mechanism: The input cannot be spent until the specified sequence delay has passed relative to the confirmation of the output it spends.
05

Witness Data (SegWit)

For Segregated Witness (SegWit) inputs, signature and public key data are moved from the scriptSig to a separate witness field. This reduces the transaction's size for fee calculation and enables script versioning.

  • Purpose: Stores witness data (signatures, etc.) separately.
  • Location: In a separate data structure, not in the traditional input.
  • Impact: Lowers transaction weight, fixing transaction malleability and enabling scaling solutions like the Lightning Network.
06

Outpoint (txid + vout)

The combination of the Previous Transaction Hash (txid) and the Output Index (vout) is formally known as an outpoint. This pair is the fundamental reference to a specific, spendable UTXO on the blockchain.

  • Definition: A unique pointer to a blockchain UTXO.
  • Uniqueness: Guarantees no double-spend, as each UTXO can only be referenced as an input once.
  • Database Key: In a node's UTXO set, the outpoint is often used as the primary key to track unspent outputs.
TRANSACTION INPUT ARCHITECTURES

TxIn vs. Account Model Input

A structural comparison of how two dominant blockchain models define and authorize transaction inputs.

FeatureUTXO Model (TxIn)Account Model (Input)

Core Unit

Unspent Transaction Output (UTXO)

Account State & Nonce

Input Structure

Reference to previous TxOut + unlocking script

Sender address, nonce, signature, value

State Tracking

Stateless; validity proven by referencing chain history

Stateful; global account state is maintained

Parallel Processing

High (independent UTXOs)

Limited (account nonce sequencing)

Privacy Model

Pseudonymous; links between addresses are not explicit

Pseudonymous; all activity tied to a persistent address

Fee Calculation

Based on transaction size (vbytes)

Based on computational complexity (gas)

Example Protocols

Bitcoin, Litecoin, Cardano

Ethereum, Solana, BNB Smart Chain

Authorization Proof

Digital signature satisfying script (e.g., Script, Plutus)

Digital signature from account's private key

ecosystem-usage
TRANSACTION INPUT (TXIN)

Ecosystem Usage

A Transaction Input (TxIn) is a reference to a previous unspent transaction output (UTXO) that is being consumed to fund a new transaction. It is a fundamental data structure in UTXO-based blockchains like Bitcoin, specifying the source of funds and the authorization to spend them.

01

Core Components

A TxIn contains two primary pieces of data:

  • Outpoint: A pointer to the previous UTXO, consisting of the Transaction ID (txid) and the Output Index (vout).
  • ScriptSig (or Witness): The unlocking script that provides authorization, such as a digital signature and a public key, proving ownership of the referenced UTXO.
02

Spending Mechanism

To spend a UTXO, a new transaction's input must reference it exactly via its outpoint. The input's unlocking script is then executed in conjunction with the referenced output's locking script. If the combined script evaluates as true, the UTXO is successfully spent and cannot be used again, preventing double-spending.

03

Coinbase Input

The first input in a block's coinbase transaction is a special case. It has no previous outpoint to reference. Instead, it is created from nothing to reward the miner and contains arbitrary data (the coinbase field), which can include the block height and extra nonce for mining.

04

Input Verification

Network nodes validate every TxIn by checking:

  • The referenced UTXO exists and is unspent.
  • The unlocking script satisfies the UTXO's locking conditions.
  • The transaction's signatures are cryptographically valid.
  • The input is not a double-spend attempt within the mempool or blockchain.
05

Fee Calculation

Transaction fees are not explicitly stated in a TxIn. They are calculated as the sum of all inputs minus the sum of all outputs. Any leftover satoshis that are not allocated to a new output are collected by the miner as the fee, incentivizing block inclusion.

06

Segregated Witness (SegWit) Impact

With SegWit, the signature data (witness) was moved out of the ScriptSig and into a separate, discounted part of the transaction. This changed the structure of a TxIn, reducing its on-chain footprint for complex scripts and fixing transaction malleability.

TRANSACTION INPUT (TXIN)

Common Misconceptions

A transaction input (TxIn) is a fundamental building block of a blockchain transaction, referencing a previous unspent output to be consumed. This section clarifies widespread misunderstandings about its role, security, and mechanics.

A transaction input (TxIn) is a data structure that points to and authorizes the spending of a previous unspent transaction output (UTXO). It does not contain the actual funds; instead, it provides a cryptographic reference (the previous transaction hash and output index) and a proof of ownership, typically a digital signature created with the sender's private key. Each input must be fully spent in the transaction it is used in, with any leftover value returned to the spender as change output. This mechanism ensures the integrity of the UTXO model used by Bitcoin and similar blockchains.

security-considerations
TRANSACTION INPUT (TXIN)

Security Considerations

While a transaction input is a fundamental data structure for spending funds, its security implications are critical for wallet developers and users. These considerations focus on preventing unauthorized spending and ensuring transaction validity.

01

Signature Validation

The primary security mechanism for a TxIn is the digital signature contained in its scriptSig (Bitcoin) or witness (SegWit). This proves ownership of the referenced UTXO. A critical vulnerability occurs if:

  • The signature is malformed or invalid.
  • The signing logic has a bug, allowing a signature to be replayed.
  • The signed data (sighash) does not commit to all critical parts of the transaction, enabling transaction malleability.
02

Double-Spend Prevention

A TxIn references a specific, unspent transaction output (UTXO). The core security of the blockchain relies on the consensus mechanism preventing the same UTXO from being spent twice. Key attacks include:

  • Race Attacks: Broadcasting two conflicting transactions simultaneously.
  • Finney Attacks: A miner including a double-spend in a block they mine. Security depends on waiting for sufficient block confirmations before considering a spend final.
03

Input Script & Smart Contract Logic

For non-standard transactions (e.g., multisig, timelocks), the unlocking script in the TxIn must satisfy the conditions in the referenced output's locking script. Security risks include:

  • Script injection: Maliciously crafted data in the input script could exploit bugs in a node's script interpreter.
  • Logic flaws: Incorrectly constructed conditions in the input script could allow unauthorized unlocking.
  • Resource exhaustion: Overly complex script validation could be used in a Denial-of-Service (DoS) attack.
04

Fee Sniping & Mempool Security

TxIns are visible in the mempool before confirmation. This exposes transactions to several attacks:

  • Fee Sniping: A miner replaces a low-fee transaction by double-spending its inputs with a higher-fee transaction, stealing the fee.
  • Mempool Griefing: An attacker broadcasts a transaction spending the same UTXOs as a victim's pending transaction, causing conflicts and delays. Using Replace-By-Fee (RBF) or Child-Pays-For-Parent (CPFP) can mitigate some risks but introduces other trade-offs.
05

Wallet & Key Management

The security of a TxIn ultimately depends on the security of the private keys used to create its signatures. Critical considerations for wallet software:

  • Key Generation: Must use cryptographically secure random number generators.
  • Signing Environment: Private keys should never be exposed to untrusted environments (e.g., web browsers without proper isolation).
  • Path Derivation: In HD Wallets, ensuring the derivation path is secure and deterministic. A compromised key renders all UTXOs it controls vulnerable.
06

Inherited Risks from Referenced Output

A TxIn inherits the security properties of the UTXO it spends. If the originating transaction was insecure, the input may be too. Examples:

  • Spending from a coinbase transaction requires waiting for 100 confirmations on Bitcoin to mitigate the risk of a chain reorganization.
  • Spending from an output that was itself received in a double-spend attack is inherently invalid.
  • The scriptPubKey of the spent output defines the security model (e.g., multisig thresholds, hash preimage requirements).
TRANSACTION INPUT

Frequently Asked Questions

Transaction Inputs (TxIn) are the fundamental building blocks that define where the value in a Bitcoin or UTXO-based transaction originates. These questions cover their structure, purpose, and role in the blockchain.

A Transaction Input (TxIn) is a data structure within a Bitcoin transaction that references and authorizes the spending of a previous unspent transaction output (UTXO). It acts as a pointer to the source of funds, proving the sender has the right to spend them. Each input must contain:

  • A reference to the previous transaction's hash and the specific output index (Outpoint).
  • An unlocking script, called a scriptSig, which provides cryptographic proof of ownership (e.g., a digital signature).
  • A sequence number, used for features like Replace-By-Fee (RBF). A transaction is only valid if every input's unlocking script successfully satisfies the conditions (the scriptPubKey) of the UTXO it references.
ENQUIRY

Get In Touch
today.

Our experts will offer a free quote and a 30min call to discuss your project.

NDA Protected
24h Response
Directly to Engineering Team
10+
Protocols Shipped
$20M+
TVL Overall
NDA Protected Directly to Engineering Team
Transaction Input (TxIn) - UTXO Model Definition | ChainScore Glossary