Transactions are the fundamental unit of execution in the Stacks blockchain. Each transaction is originated from a Stacks 2.0 account, and is retained in the Stacks blockchain history for eternity. This guide helps you understand Stacks 2.0 transactions.
Transactions go through phases before being finally confirmed, and available for all, on the Stacks 2.0 network.
- Generate: Transactions are assembled according to the encoding specification.
- Validate and sign: Transactions are validated to confirm they are well-formed. Required signatures are filled in.
- Broadcast: Transactions are sent to a node.
- Register: A miner receives transactions, verifies, and adds them to the "mempool," a holding area for all the pending transactions.
- Process: Miners review the mempool and select transactions for the next block to be mined. Depending on the transaction type, different actions can happen during this step. For example, post-conditions could be verified for a token transfer, smart-contract defined tokens could be minted, or an attempt to call an existing smart contract method could be made.
- Confirm: Miners successfully mine blocks with a set of transactions. The transactions inside are successfully propagated to the network.
A transaction can have one of three states once it is registered:
The Stacks 2.0 supports a set of different transaction types:
|Coinbase||The first transaction in a new block (an entity holding several transactions). Used to register for block rewards. These are not manually generated and broadcasted like other types of transactions.|
|Token transfer||Asset transfer from a sender to a recipient|
|Contract deploy||Contract instantiation|
|Contract call||Contract call for a public, non read-only function|
|Poison Microblock||Punish leaders who intentionally equivocate about the microblocks they package|
A sample of each transaction type can be found in the Stacks Blockchain API response definition for transactions.
Read-only contract call calls do not require transactions. Read more about it in the network guide.