-2

I am using web3.py and ganache to tranfer Ether between two account. In the tutorial that I'm learning from a part of code is like below:

nonce=wb3.eth.get_transaction_count(account_1)
tx={
    'nonce':nonce  ,
    'to':account_2,
    'value':wb3.to_wei(1, 'ether'),
    'gas':2000000,
    'gasPrice':wb3.to_wei('50', 'gwei')
    
    }

I understand that in block chain nonce should be a unique number to create a random hash. But in the code above, I can just use exact transaction count (for example 3) for nonce variable. Could anyone explain it to me please?

i tried some other numbers and it will be cause an error.

1 Answer 1

0

The purpose of the nonce is defined in the blockchain protocol. It defines the order of transactions and it has to be continuous. So if the first nonce = 0, it becomes the meaning of transactions count by the nature. Read more here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.