2

I'm trying to build an Ethereum exchange service, so concurrent schedule is needed and nonce management is the most problem (another topic discussed about it). At specificed moment, I have large request of transactions (txs), so I'm using redis and physical database to storage current nonce and update it +1 while ending (often get nonce from redis, if redis is dead, switch to physical db).
When testing, nonce from redis occasionally is higher than current valid nonce (getTransactionCount), it will be marked as successful transaction (tx) with a valid hash is returned:
Example current nonce is 50, create list txs with higher nonce such as 51, 52,... is all valid and return valid hashes.
The problem at there is if nonce 50 is not filled by a specificed tx, list txs with higher nonce than 50 will wait for a period time and I don't know when it will be expired. I've test a half day to full day but they're not expired. When I create a tx with nonce 50, after a short time, list txs higher none +50 will be broadcasted automatically and become successfull too. I know that I can cancel these txs by creating a self transaction with higher gas but it's not the problem I'm facing.
So, I have 2 question, where can I find list txs higher nonce than current valid nonce eg etherscan.io or my node though I've storaged them on physical DB. And 2nd question is if I don't fill a missing nonce to chain, will list txs be expired for a period time (how long) or they're storaged forever, if I wanna cancel them I must create self transaction with higher gas? Thanks for hearing me so much and have a nice day.
//I'm creating a schedule, which check nonce from node and redis if they're diffrent, create a self transaction with nonce from node but I think this is not a good resolve...

2

So, I have 2 question, where can I find list txs higher nonce than current valid nonce eg etherscan.io or my node though I've storaged them on physical DB.

This is an issue that many people have, and many people have provided answers for. In general, you have two main options here.

  1. Keep track of your pending transactions yourself. As you are broadcasting transactions, you can just save them including their nonce. Then you can just look up transactions with nonce >= current valid nonce.

  2. Query a full node with eth_pendingTransactions. You can then sort through these transactions to look for ones coming from your wallet. This is not foolproof, as the node may be missing some pending transactions, as its pending tx pool may be full, or it just has not seen all of your transactions yet.

if I don't fill a missing nonce to chain, will list txs be expired for a period time (how long) or they're storaged forever, if I wanna cancel them I must create self transaction with higher gas?

ETH transactions do not expire based on time. As long as they are valid in normal ways (i.e. nonce is valid, sender has enough ETH for gas), the transaction will continue to be valid. If you want to speed the transaction up, you can always create a new one with the same parameters but a higher gas price.

| improve this answer | |
  • Thanks for your reply. So, my option is creating a schedule, which check nonce from node and redis, if they're diffrent, create a self transaction with nonce from node... is temporarily a suitable option at current time bro? I hope in the near future, Ethereum may have a feature to fix that soon and I'm very excited to wait. Thanks again and have a nice day. – mmo2112 Oct 25 '19 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.