✏️
go-conflux-sdk
  • README
  • Quickstart
  • Getting Started
    • Run a Node locally
    • Interacting with a Node
    • Deploy and Interact with Smart Contracts
    • Subscription
  • Smart Contracts
    • Smart Contract Overview
    • Getting Started with Solidity
    • Compiling Solidity source code
    • Interacting with Smart Contracts
    • Application Binary Interface
    • Contracts Supported
  • Transactions
    • Conflux Transactions
    • Obtaining CFX
    • Gas & Storage Collateral
    • Account Manager
    • Transfer CFX
    • Transaction Nonce
    • Batch Call snd Send Transactions
  • Other
    • Call/BatchCall RPC Hook
    • Conflux Addreess
  • Conflux-ABIGEN
  • ChangeLog
  • References
Powered by GitBook
On this page

Was this helpful?

  1. Transactions

Transaction Nonce

PreviousTransfer CFXNextBatch Call snd Send Transactions

Last updated 3 years ago

Was this helpful?

The nonce is an increasing numeric value which is used to uniquely identify transactions. A nonce can only be used once and until a transaction is mined, it is possible to send multiple versions of a transaction with the same nonce, however, once mined, any subsequent submissions will be rejected.

You can obtain the next available nonce via the method:

nonce,err := client.GetNextNonce(<address>, <epoch>)

If you want send transaction continuously, the better way is to obtain the next available nonce within the pending transactions in txpool via method:

nonce,err := client.TxPool().NextNonce(<address>)

However, go-conflux-sdk apply function Client.GetNextUsableNonce for convinent, it will get nonce by txpool_nextNonce first and if failed then get nonce by cfx_getNextNonce

nonce,err := client.GetNextUsableNonce(<address>)

The nonce can then be used to create your transaction object

var utx types.UnsignedTransaction
utx.Nonce = nonce
cfx_getNextNonce
txpool_nextNonce