[Ethereum] How to create a transaction with same nonce

nonce

How do I create a new transaction that has the same nonce as a previous transaction?

I sent a txn with 4Gwei gas price and I want to cancel it by sending a 0 Eth txn with the same nonce.

I am running geth 1.7.1.

Best Answer

Simply pass nonce parameter to sendtransaction. Suppose the transaction you want to cancel has nonce 13. Then try sending a transaction from same account with same nonce.

eth.sendtransaction({from:fromAccount,to:fromAccount, value:web3.toWei(0,"ether") nonce: 13, gasPrice:10000000000})

Note that you need to send the gas price higher than you sent previously. Make it around 10GWei.