Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to custom nonce ? #37

Closed
cctanfujun opened this issue Sep 17, 2018 · 8 comments
Closed

how to custom nonce ? #37

cctanfujun opened this issue Sep 17, 2018 · 8 comments
Labels
question Further information is requested

Comments

@cctanfujun
Copy link

create two transaction in a short time,will cause replacement error due to same nonce,so how to create
custom nonce transcation?Thank you!

@skywinder skywinder added the question Further information is requested label Sep 17, 2018
@shamatar
Copy link
Contributor

shamatar commented Sep 18, 2018

hello @cctanfujun

Right now you have to assemble a transactions manually or by help of transaction intermediate and then set the nonce

   guard case .success(let tx) = transactionIntermediate.assemble(options: someOptions, onBlock: "pending") // may fail, that would mean that gas estimation failed, for example
  var txCopy = tx
  txCopy.nonce = BigUInt(1337)
  let result = web3.eth.sendTransaction(txCopy, options: someOptions, password: "web3swift")

@skywinder
Copy link
Collaborator

@cctanfujun did solve your task?

@cctanfujun
Copy link
Author

@cctanfujun did solve your task?

i finally always set nonce manual,but i think it's difficult and not elegant

@skywinder
Copy link
Collaborator

@cctanfujun thanks for the update. Are any ideas, how to make it easier?

@shamatar 's solution looks pretty straightforward.

Is your code open source or can you show an example? We can check if there is a better solution.

@matijakregar
Copy link

matijakregar commented Oct 26, 2018

I'm having the same problem.

One way to fix it would be that the transaction count is increased/persisted locally (by web3swift) each time a transaction is successfully broadcast.

Now it seems to rely on the eth_getTransactionCount response, which is the same for 2 consecutive transactions in a short time. This means that the second transaction will be rejected with the Transaction with the same hash was already imported. error.

@shamatar
Copy link
Contributor

shamatar commented Oct 26, 2018 via email

@skywinder
Copy link
Collaborator

@shamatar any estimates about estimation of release web3swift 2.0 ? 😉

@TonioMacaronio
Copy link
Collaborator

Everything done in 2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants