0

I am currently creating my first Ethereum smartcontract. In my smart contract I created a uint16 array, which I can dynamically resize:

Why is that so, and what can be done about that?

user79384
  • 1
  • 1
  • It's generally a bad practice to use for loops in Solidity. There is a possibility that there wouldn't be enough gas in an entire block to pay for a tx that contains a for-loop. Which means that the smart contract would hit a dead end with no way to progress its state. – Ahmed Ihsan Tawfeeq Aug 18 '21 at 10:02
  • is there then a possibility to create an array with size of 1000 or 10000? – user79384 Aug 18 '21 at 10:14
  • Only way to make sure is to test that in practice, but this is still heavily discouraged even for layer-2 solutions. Instead, you might want to have the for loop in a js script and then just batch all those tx calls into one tx using web3 batch requests. More about that here: https://ethereum.stackexchange.com/questions/47918/how-to-make-batch-transaction-in-ethereum – Ahmed Ihsan Tawfeeq Aug 18 '21 at 11:06

0 Answers0