anyone know of an easy way to verify multifile contracts on poly ?

Jun 2, 2021, 5:35 PM
in solidity how many iterations is okay to make in a loop, is 10-20K okay ? it writes to the blockchain, sets a bool value for each iteration
Jun 2, 2021, 7:06 PM
Each iteration do something on blockcgain? Taje care of gas
Jun 2, 2021, 7:15 PM
it loops user balance of another token, and evaluate if they have more or less than last time, sets a bool to true if they have less
Jun 2, 2021, 7:17 PM
but you can do this out of solidity
Jun 2, 2021, 7:18 PM
would had been better to set a flag in the token, but that is too late
Jun 2, 2021, 7:18 PM
and then call a solidity smart contractsthat wirte
write
Jun 2, 2021, 7:18 PM
but the contract need the data to work
Jun 2, 2021, 7:19 PM
you can take the data running a node
local or from quicknode, etc..
Jun 2, 2021, 7:20 PM
how do i get it into the contract then ?
Jun 2, 2021, 7:21 PM
do the validations offchain and call the contract only when you need to write
Jun 2, 2021, 7:22 PM
Nope. Would run out of gas around 4k iterations for a loop with only one simple condition check (tested myself)
Jun 2, 2021, 7:23 PM
Try not to use loops
Unless its a real simple operation
Jun 2, 2021, 7:27 PM
it checks user balance of an existing token, and set it to true if it was less than before
not that complicated of an operation
Jun 2, 2021, 7:29 PM
Just do the operation when the user needs the update, only for that user
So you dont use loops
Try it tho, it might be a lot less gas
Jun 2, 2021, 7:30 PM
i do that too.. this is a purge function, so people can't cheat the system
Jun 2, 2021, 7:30 PM
But id recommend that
Do the purge when the update is called
For that user
Thats what id do
Jun 2, 2021, 7:31 PM
I'd do that when the user makes a transaction instead of batch update
Jun 2, 2021, 7:33 PM
Loops are too expensive for the blockchain, but id try to check the gas price vs the testnet before choosing
Jun 2, 2021, 7:33 PM
i do the purge when user interact with the contract, only for the user itself. The problem is they can cheat the system, that's why i wanted to loop all of them, just once in a while
Jun 2, 2021, 7:33 PM
^this
Maybe the cure is better than prevention in this case🙃
But for real, avoid loops whenever possible
Jun 2, 2021, 7:35 PM
Id rethink the solution without using loops
Almost everything can be done without loops, you just have to tackle the problem correctly
If you post some code i might help, dm me
Jun 2, 2021, 7:36 PM
ill try 😊
Jun 2, 2021, 7:46 PM

© 2024 Draquery.com All rights reserved.