A transaction (tx for short) is a blockchain storage operation that transfers cryptoassets or other information between wallets. A transaction is sent after it is created in a wallet and signed by a digital signature based on a private key. Transactions are verified by blockchain miners (validators), who receive a commission for doing so. The transaction fee is always paid by the sender.
A validated transaction is included in a block – part of a chain (blockchain), it is not possible to send the same coins (tokens) twice. Once a transaction is stored in the blockchain, it can be found by its hash, often called the transaction identifier (tx id). Each transaction hash is unique within the blockchain.
Information about all transactions in public blockchains is transparent and publicly available, including the sender and receiver addresses, the amount transferred, and other data. Some blockchains provide a way to hide the underlying transaction data through anonymization technologies. Transactions can be created either in a wallet connected to the network (onchain) or without a connection, with delayed sending (offchain).
Inputs and Outputs
A transaction’s financial scheme consists of an input (input), the amount of crypto-asset to be transferred, and an output (output). Inputs are the crypto-assets available in a wallet, received in incoming payments, which are sent in a transaction. When a transaction is sent, an outgoing payment of the correct amount is created, which is called an output. The outputs of one transaction are then used by the new owner as inputs of new transactions.
Nodes on the network keep track of the active transaction outputs stored in the blockchain – their total amount is always equal to the amount of coins circulating in the blockchain at the time the last block was created. Outputs that have not yet been used in a subsequent transaction are called Unspent Transactions Output (UTXO).
Sending and Confirmation
To send cryptoassets or metadata, the user must sign the transaction with his private key – creating a digital signature. A hash – its checksum – is created for each transaction. The hash depends not only on the data of the transaction itself, but also on the hash of the previous transaction. Even if you send a second transaction for the same amount to the same recipient, a new hash will be created.
Once sent, the transaction is translated into the blockchain. Nodes on the network verify that the transaction matches protocol rules, and then it can be included in the blockchain. Prior to confirmation, the transaction is in the unconfirmed transaction queue (mempool) of the miners’ wallets. Once a transaction is placed in the block and confirmed by the miners, no information about it can be changed, and the transaction data is available through the wallet APIs or blockchain browsers.
The transaction may be rejected or not used by the miners. Too low a fee is the most common reason why a transaction is delayed or cannot be confirmed, especially during periods of high network congestion. Rejected transactions are excluded from the mempool after a few days and do not appear in the blockchain, while crypto-assets remain at the sender’s address.
In Bitcoin and some other cryptocurrencies, there are methods to speed up the confirmation of an already sent transaction by increasing the fee. For example, this is the Replace-by-fee (RBF) technology.
Privacy
Some blockchains use encryption technologies to hide information about the sender, recipient and the amount of crypto assets transferred. In the Monero blockchain, the anonymity of transactions is ensured by two technologies – circular signatures and hidden addresses. Anonymous transactions are available in other networks, such as Zcash and Dash.
Is it possible to undo a transaction?
A transaction can theoretically be changed or redirected only before confirmation by the miners. Once a transaction is added to a block, it remains in the blockchain forever and will be stored on all full nodes of the network. To change any transaction already stored in the blockchain, you would have to recreate all the blocks after the one in which it is written.
There are tools to return a transaction after it has been sent to the wrong address or the address of a smart contract that does not accept deposits. The sender and recipient must enter a password. If the recipient does not enter a password, the transaction is automatically returned to the sender. But to use this feature, you need to use a special wallet or manually add the necessary script to the transaction before sending it. Kirobo’s Retrievable Transfer tool for Bitcoin and Etherium, for example, makes this possible.