Linked Questions

1 vote
0 answers
68 views

Data Storage in Ethereum [duplicate]

How does data storage work in Ethereum? Do variables of a Smart Contract map to columns of a table? And an update to those variables creates a new record with their latest values? So if 100 employees ...
Ashish Sinha's user avatar
29 votes
3 answers
12k views

How do gas refunds work?

Gas refunds are provided when clearing storage or calling SELFDESTRUCT on contracts. The Yellow Paper mentions that refunds are "being capped up to a maximum of half...". What exactly is ...
eth's user avatar
  • 85.7k
19 votes
1 answer
8k views

Usage of memory, storage and stack areas in EVM

In solidity contracts, I can understand that based on variable usage and expensiveness, I can determine that which one should use (memory, storage or stack). But I faced some situations where only ...
Abhishek's user avatar
  • 800
16 votes
3 answers
16k views

What does web3.eth.getStorageAt() return?

I want to know how this works: web3.eth.getStorageAt(addressHexString, position [, defaultBlock] [, callback]) What data we can store at any address and how? And what will this eth API return?
BlockA's user avatar
  • 857
24 votes
2 answers
4k views

Why are local variables allocated to storage instead of memory?

Local variables (i.e. variables declared inside functions) are held in persistent storage by default instead of non-persistent memory (source). The value of a local variable can not persist in ...
Harry Wright's user avatar
  • 1,171
11 votes
1 answer
2k views

Is the cost of updating storage different than the cost of adding to storage?

Do these have a separate cost? sstore(1, 10) # first time adding a value to storage with this key sstore(1, 20) # changing the value in storage. I looked for a list of gas costs / opcodes, and the ...
Broseph's user avatar
  • 695
5 votes
3 answers
2k views

Does an SSTORE where the new value is the same as the existing value cost gas?

For example (in Vyper): @external def foo(bar: uint256): self.baz = bar foo(3) foo(3) # Is the gas cost here still 5000? Is it better to do this instead? def foo(bar: uint256): if self.baz != ...
Dylan Kerler's user avatar
3 votes
1 answer
3k views

SLOAD costs 800 gas - how is it possible?

I've got a very simple contract. It narrows down and measures cost of loading a storage variable: pragma solidity ^0.7.6; contract Bench { uint256 public data; function increment() ...
CodeSandwich's user avatar
4 votes
1 answer
3k views

Switching from 'storage' to 'memory' increases the gas-cost

I've read several related answers and blog posts, all of them suggesting that for the sake of reading complex state variables (i.e., arrays and structures), one should always prefer declaring the ...
goodvibration's user avatar
5 votes
2 answers
3k views

How to initialize a mapping of a struct inside a function?

Mappings are normally declared in the top part of the contract, however is there any way to instantiate a mapping - which belongs to a struct - while in a function?
Paul Razvan Berg's user avatar
2 votes
1 answer
3k views

Error encountered during contract execution [Bad jump destination]

When calling to start() function in a Smart Contract, transaction fails with this message: Warning! Error encountered during contract execution [Bad jump destination] According to Error During ...
Juan Ignacio Pérez Sacristán's user avatar
1 vote
2 answers
1k views

Why cryptokitties uses storage instead of memory?

There are a lot of explainations of storage and memory out there like this question or this question. But I'm wondering why cryptokitties for example uses storage instead of memory in many functions. ...
MarcS82's user avatar
  • 323
4 votes
1 answer
284 views

How does a client interact with a contract already in the blockchain?

I am looking for someone to help clarify the 'stacktrace' of interactions that occur when a client interacts with a smart contract. Clearly, one has to submit a transaction to a miner, who then has ...
billett's user avatar
  • 1,255
0 votes
1 answer
732 views

How does EVM search in the storage?

I am reading this article to understand the storage in Solidity/EVM. It says that each smart contract has an (independent?) storage and "This storage can be thought of as a very large array, ...
Anh Dũng Lê's user avatar
1 vote
1 answer
239 views

Where can I find the block that contains most recent state of contract's memory/storage?

I am considering trying to use or implementing some form of light Ethereum node that only needs access the most recent version of data stored in smart contract storage on the blockchain and trying to ...
Cameron's user avatar
  • 11

15 30 50 per page