how to track nonce correctly?
for example, by pressing a button, the user initiates a contract transaction from my wallet and I have to generate a nonce for each transaction
Should I store it in the database? Or is there some simple way?

web3 has the functionality of getting a nonce but only for published transactions and if you use it - there will be a lot of transaction underpriced errors

Aug 9, 2022, 9:42 AM
if 1 nonce = transaction why you dont take the transaction count ?
Aug 9, 2022, 12:07 PM
in that case i need to wait all transactions to complete
The "nonce"from getTransactionCount will not be correct unless you wait for each transaction to complete
so. I'm looking for optimal solution to this problem
Aug 9, 2022, 12:20 PM
nice CGI
Aug 9, 2022, 12:21 PM
but you will need to wait for each transaction to complete to send the next, why do you need to know all the nonces in advance? are you trying to fit them all on the same block or something similar?
i think fastest way is to use a database but i dont know how you could do it using the chain
Aug 9, 2022, 12:23 PM
getTransactionCount(address,'pending')
That'll do
Aug 9, 2022, 12:23 PM
the blazingly fast way is using a variable
Aug 9, 2022, 12:23 PM
ah yes, the classic let test = something haha
Aug 9, 2022, 12:24 PM
because one tracsaction could take up to 2 days
I cant wait that time)
i tried on local ganache - works same as getTransactionCount without "pending"
Aug 9, 2022, 12:28 PM
How did you induce the delay on ganache?
Aug 9, 2022, 12:30 PM
-b 10
Aug 9, 2022, 12:30 PM
Worked for me when I was using
Aug 9, 2022, 12:33 PM
is it specific for mumbai only. or for every chain?
Aug 9, 2022, 12:38 PM
Its a web3 method, you can use it on any chain
Might be hard to see in action with chains having lower blocktimes
Aug 9, 2022, 12:39 PM
web3 "protocol"?

what might happen with slow networks?
Aug 9, 2022, 12:40 PM
*any evm chain
Aug 9, 2022, 12:42 PM
so, ganache not an evm chain ?
Aug 9, 2022, 12:43 PM
Well... it is, no idea why its not working on ganache
Aug 9, 2022, 12:44 PM
do you know some local evm that support it?
Aug 9, 2022, 12:45 PM
https://hardhat.org/hardhat-network/docs/explanation/mining-modes
Try that out
Aug 9, 2022, 12:47 PM
maybe because ganache has an automining feature that process every transaction as a block
so maybe it doesnt implement the pending state and the delay is just a timeout
Aug 9, 2022, 12:58 PM
https://pastebin.com/gP91MMh6

it is eip-1898

HEX String - an integer block number
String “earliest” for the earliest/genesis block
String “latest” - for the latest mined block
String “pending” - for the pending state/transactions

i made py example without web3
Aug 9, 2022, 1:09 PM
am i the only one having a 404 error on the pastebin?
Aug 9, 2022, 1:12 PM
i guess so. and i didnt fint such option in harthat

may I simulate that behavior of "real timeout" with some fake transactions?
https://pastebin.com/gP91MMh6
they hate eth url ))
Aug 9, 2022, 1:17 PM
honestly no idea but if you try out it would be if you share the results
Aug 9, 2022, 1:18 PM
okie
Aug 9, 2022, 1:18 PM
thanks!
Aug 9, 2022, 1:19 PM
https://github.com/trufflesuite/ganache/releases/tag/v7.4.0

Coming Soon » Build a real pending block!

they are doing it since feb 2021
so, i cant use it as "test env" lol
Aug 9, 2022, 1:32 PM
damn lol
hardhat uses the same implementation of the evm...... :_
It's backed by the @ethereumjs/vm EVM implementation, the same one used by ganache, Remix and Ethereum Studio.
https://hardhat.org/hardhat-network/docs/overview

so i guess it will happen the same

EDIT: said nothing lol
Aug 9, 2022, 1:36 PM
what do you think about evm_mine

https://hardhat.org/hardhat-network/docs/reference

"If neither mining mode is enabled, no new blocks will be mined, but you can manually mine new blocks "

does it mean transactions going to be in "pending" till i mint it ?
Aug 9, 2022, 1:38 PM
yes
Aug 9, 2022, 1:38 PM
don't overcomplicate this just use local variable or Redis
Aug 9, 2022, 1:39 PM
so i can make "real pending" using some kind of terminal timer ?
Aug 9, 2022, 1:40 PM
I was doing 20-30 batched simultaneous txns this way
Aug 9, 2022, 1:41 PM
is it abt nonce?
redis better than "pending" ?
Aug 9, 2022, 1:43 PM
yes
there isn't any reason it won't work, unless you have multiple instances not sharing the same redis database
make sure to avoid the race conditions
Aug 9, 2022, 1:44 PM
what do you mean?
Aug 9, 2022, 1:45 PM
it could be a problem if one transaction failed to transact
Aug 9, 2022, 1:45 PM
if it's included in the block, not an issue
but somehow gets rejected by the node then it is
Aug 9, 2022, 1:46 PM
ROFL is that a useffect without a dependency array?
Aug 9, 2022, 1:52 PM
No idea what that means. I'm fairly noob 😂
Aug 9, 2022, 1:53 PM
how can I save the "state" of hardhat node
all transactions and contracts. stop the node and "load" it saved things back?
Aug 9, 2022, 1:56 PM
that's not currently supported
Aug 9, 2022, 2:02 PM
lol
then i need real virtual machine . and put evm inside
Aug 9, 2022, 2:15 PM
Actually.. Is there a way to let a function call another function?
So if you press one button, it'll request multiple functions
Aug 9, 2022, 2:15 PM
bud, u need to learn the basics first
Aug 9, 2022, 2:16 PM
Yeah I suck 😔, still trying on the way though
Aug 9, 2022, 2:17 PM
https://www.chainshot.com/learn/programming
solidity js ethers, u have 3 little tutorials there
Aug 9, 2022, 2:17 PM
Thank you!
Aug 9, 2022, 2:17 PM
and for js, the bible i always take a look at
https://javascript.info/
Aug 9, 2022, 2:18 PM
Do you have a short answer for this maybe? It'll fix my issue. I'll make sure to follow the tutorials afterwards
Aug 9, 2022, 2:18 PM
Ah you are making direct rpc calls
Aug 9, 2022, 2:20 PM
yes
is there other way?)
Aug 9, 2022, 2:20 PM
Writing bare code may not work as intended on a virtual evm like ganache
Import web3, call getTransactionCount method
Aug 9, 2022, 2:21 PM
i used that in case web3 has a bug
Aug 9, 2022, 2:21 PM
all rpcs don't share the same mempool
Aug 9, 2022, 2:22 PM
It doesn't. As a matter of fact I used the exact thing yesterday on Mumbai
Aug 9, 2022, 2:22 PM
so web3 does not do post request?
Aug 9, 2022, 2:22 PM
share code
Aug 9, 2022, 2:23 PM
that's not I said
Aug 9, 2022, 2:23 PM
so im moving to hardhat
Aug 9, 2022, 2:23 PM
@dennis_py could u re-share what are u trying to achieve?
Aug 9, 2022, 2:24 PM
Should I dm you?
Aug 9, 2022, 2:25 PM
But it worked on Mumbai for you didn't it?
Aug 9, 2022, 2:26 PM
yes. i want to do same thing on private chain
Aug 9, 2022, 2:29 PM
Ahh private chain. Good luck :)
Aug 9, 2022, 2:31 PM
here is a problem

https://t.me/dev_solidity/196364

for "mumbai" it was solved by
getTransactionCount(address,'pending')

i want to call in on local blockchain

ganache-cli -b 10

but it appeared "-b 10" just time delay. it does not produce "pending" blocks, so i gonna move to hardhat that does
it is easier to run tests
Aug 9, 2022, 2:35 PM
because thats what you need to understand to solve it
first line of the docs
js cant safely manage numbers as big as wei numbers
and parseEther is a wrapper over formatunits if im not wrong
https://docs.ethers.io/v5/api/utils/display-logic/, go to conversion
Aug 9, 2022, 2:48 PM
u can't be wrong
Aug 9, 2022, 2:49 PM
sure i can't, im a turtle
Aug 9, 2022, 2:49 PM
200 years of experience
Aug 9, 2022, 2:49 PM
In solidity? Lol
Aug 9, 2022, 2:50 PM
/job
Aug 9, 2022, 3:05 PM
/jobs
Aug 9, 2022, 3:05 PM
no jobs for steve, sorry /job
Aug 9, 2022, 3:10 PM
Steve creates jobs
Aug 9, 2022, 3:10 PM
Rose disagrees
Aug 9, 2022, 3:12 PM
hardhat can do real pending with this config, and I mint blocks manually by sending command for it

so. i dont need ganache
Aug 9, 2022, 4:30 PM
what is the command to mine the blocks?
Aug 9, 2022, 4:31 PM
w3.manager.request_blocking("evm_mine", [])

i did not found "normal" one. so it works for me
Aug 9, 2022, 4:32 PM
Would u support Justin Sun's (the father of shitcoins) Ethereum PoW?
Aug 9, 2022, 4:51 PM
😂
Aug 9, 2022, 4:54 PM
@dennis_py i think you are misunderstanding nonces
a failed transaction still uses a nonce
Aug 9, 2022, 5:51 PM
it is not failed. it was not deleivered
Aug 9, 2022, 5:52 PM
if you manage your nonces yourself, and you are 100% sure that nobody else is messing with your private key (you should!), you are ok
Aug 9, 2022, 5:52 PM
yes exactly
Aug 9, 2022, 5:52 PM
elaborate on that, please
delivered?
Aug 9, 2022, 5:52 PM
he's probably spamming the rpcs since they have a rate limit
Aug 9, 2022, 5:53 PM
internet problem
request lost somewhere
Aug 9, 2022, 5:54 PM
save the tx that you are about to send locally first
then send it
you need to handle some kind of journal if you want to recover from errors
prepare tx -> save it
send tx -> save its tx hash
wait for it to confim -> save that result
etc
and then you recover fro the latest checkpoint
Aug 9, 2022, 5:55 PM
why will be undepriced errors?
Aug 11, 2022, 10:48 PM

© 2024 Draquery.com All rights reserved.