New answers tagged

0

Variable in contract by default are of storage, i.e. they are state variables. And new struct default allocation within function is memory. Hence the compiler warning.


0

Each storage slot has a size of 256 bits (or 32 bytes). If several elementary types can be packed into 32 bytes they will use the same slot. Let's see what we have here : address a : 20 bytes. It is stored on slot 0 and web3.eth.getStorageAt(address, 0) returns the value of a (0 in your case as it was not instantiated). address b : 20 bytes Since slot 0 ...


1

In a web2 setting, when storing data, you have to consider your storage capacity(SDD or HDD) as well as the computational ability(processor power) of your system. DDOS attack occur in a centralized network because storage is cheap. However, in a web3 setting like ethereum network, storage is expensive while computation also require large amount of power(...


1

Deep down, an array is a mapping with range-bound keys. The most expensive aspect is the SSTORE operations and SLOAD operations which are the same in both cases. An array has additional steps (operations, so gas) to check that row is not out of range. A dynamic array is significantly more expensive because each push overwrites the length and range checks ...


Top 50 recent answers are included