Skip to main content

Overview

Transaction is an important concept in blockchain. If you are not familiar with the concept of transactions and would like to quickly understand it, you can read Transaction Quick Intro.

Typically, we use wallets or SDKs to send transactions, and these tools will assist us in completing complex tasks such as constructing transactions, sending them to the network, and ultimately waiting for the transaction be confirmed or finalized, making the process relatively straightforward.

However, if you wish to delve deeper into the principles of transactions or encounter issues while sending transactions, you may need to understand the details of transactions.

Transactions Fields

A transaction consists of multiple fields, each with its own meaning and purpose. To understand their meanings and how to correctly set these fields, please refer to Transaction Fields. If a transaction fails to send or gets stuck without being mined, it may be due to incorrect settings of certain transaction fields.

Nonce

The nonce field in a transaction is crucial, as it determines the execution order of transactions. Nonce updates are not real-time, so understanding the nonce is essential, especially when there is a need to quickly send transactions to the chain. Additional nonce management guidelines are also provided for such cases.

Transaction Fees

The gas, gasPrice as well as storageLimit fields in a transaction are also crucial. These fields are used to set the execution cost of the transaction. Setting gas too low may result in transaction failure, while setting it too high leads to unnecessary fees. The gasPrice field affects the transaction's priority in the block, particularly in congested networks. storageLimit is a unique field used to specify storage collateral could be used by a transaction. Understanding the transaction fee can help you set the fields more effectively.

Encoding and Signing

After preparing all transaction fields, the transaction needs to be encoded and signed according to specific rules before being sent. It is then sent to the network using the RPC method cfx_sendRawTransaction.

Lifecycle

Once a transaction is sent to the network, it doesn't immediately get mined and executed. Instead, it undergoes a series of state changes. Understanding the transaction lifecycle can help you better comprehend the status changes of a transaction and troubleshoot issues encountered during the transaction sending process.

Transaction Receipt

After a transaction is executed, a transaction receipt is generated. The transaction receipt includes information about the transaction's execution results, whether it was successful, how much fee was paid, and details about the block in which the transaction resides.

Transaction Sending Failures

During the process of sending a transaction, various issues may arise. It could be an error in obtaining values for transaction fields, network problems when calling RPC, or errors when calling the cfx_sendRawTransaction method. We have compiled common issues and solutions related to sending transactions, please refer to Common Transaction Sending Issues.

Pending Transactions

After successfully sending a transaction, it should normally be mined within a few seconds. However, there are cases where a transaction remains pending. This can be due to network congestion and a low gasPrice, or an incorrect nonce setting (often caused by rapid transaction sending). Please refer to Reasons for Pending Transactions to avoid or resolve this issue.

FAQs

Frequently asked questions