Linked Questions

1
vote
0answers
57 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 ...
39
votes
1answer
18k views

What does the keyword “memory” do exactly?

I've been looking through the code of Etherdice and noticed that some variables are declared like ParserResult memory result; and I haven't found the keyword "memory" in any documentation. What I ...
20
votes
3answers
3k 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 ...
16
votes
1answer
5k 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 ...
11
votes
3answers
5k 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?
17
votes
2answers
2k 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 ...
8
votes
1answer
723 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 ...
2
votes
1answer
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 ...
1
vote
2answers
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. ...
4
votes
1answer
266 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 ...
3
votes
3answers
112 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 != ...
3
votes
1answer
387 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 ...
2
votes
1answer
471 views

How to initialise 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?
1
vote
1answer
196 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 ...
2
votes
1answer
119 views

Why is the cost of memory non-linear, while the cost of storage is linear?

Why is the cost of memory non-linear, while the cost of storage is linear? I wonder why the cost function of memory vs. storage differ? While storage is associated with a constant cost, this is not ...

15 30 50 per page