Skip to main content

Questions tagged [storage]

all questions regarding data and storage on the ethereum blockchain

125 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
1 answer
201 views

Need help to understand storage costs

I have tried to implement a simple cellular automaton logic using two different ways to track the final state: Track every iteration in a multi-dimensional array. Store only the last two iterations. ...
spacemonkey's user avatar
4 votes
2 answers
3k views

Declaring a memory array of storage pointers in Solidity

I would like to declare a variable as a memory array of pointers to storage arrays of uint256. For example: pragma solidity ^0.4.24; contract A { uint256[] public array0; uint256[] public ...
Jesbus's user avatar
  • 10.5k
3 votes
3 answers
866 views

How to view the amount of storage a contract uses?

Is it possible to view the amount of storage a smart contract uses from an existing tool? Or if not is it possible to determine it by making json rpc calls? There are a few similar questions such as ...
MShakeG's user avatar
  • 1,825
3 votes
0 answers
48 views

Why does a STORAGEADD op (SSTORE) add 80 bytes to state rather than 32?

According to this spreadsheet that Vitalik has referenced before, stating that it's what they used to determine gas fees for each opcode, a STORAGEADD opcode (presumably renamed to SSTORE) is ...
Paul DeLucia's user avatar
3 votes
2 answers
295 views

Set and delete storage variable in same tx

I did some poking around and didn't see an answer... and I figure someone knows this off the top of their head. Question: what is the gas cost associated with setting and deleting a storage variable ...
kronosapiens's user avatar
3 votes
0 answers
628 views

Getting complete storage of a contract using geth client

I found at here, that it is possible for a client to get the value from storage of a contract at a particular index using eth.getStorageAt(contract_address, index) interface. I wanted to ask Is it ...
sourav's user avatar
  • 357
3 votes
1 answer
88 views

CALL always throws exception on SSTORE

this.call(bytes4(keccak256("setGBA(uint32)")), 12); How to call function by string name? I can't modify store in function. How to do this?
Vladimir Kovalchuk's user avatar
3 votes
1 answer
772 views

Regarding external file storage

Let's say you have a private blockchain, a DApp with an workflow to store and retrieve data from that blockchain. Now there is a need to store binary files and access it in a permissible way. One way ...
Susmit's user avatar
  • 1,804
2 votes
1 answer
45 views

Has Solidity Introduced Storage Optimization for Smaller Integer Types in Structs?

I am working on a project where storage efficiency is of utmost importance. Specifically, I have a scenario where I want to store an ID of type uint16 and a code of type uint8. The current plan is to ...
MShakeG's user avatar
  • 1,825
2 votes
0 answers
14 views

How can my users store data using Ethereum-Wrapped Filecoin?

I'm building a data marketplace and want to have my users store their data (encrypted video, mostly) at their own expense. I can assume that they will have Ethereum available via Metamask, but not ...
Boris K's user avatar
  • 197
2 votes
0 answers
46 views

What's the benefit of encapsulating storage slots as structs?

Often times you'll see the following pattern for reading and writing to storage slots: struct Slot { address value; } ... function getSlot(bytes32 slot) returns (Slot storage s) { assembly { s....
Leeren's user avatar
  • 269
2 votes
0 answers
80 views

Upgradable contracts - proxy storage allocation

So in general, for fixed size fields, storage is allocated (reserved) at time of contract deployment - as per my undestanding. Now, we deploy a Proxy contract, and separately a couple versions of ...
almondandapricot's user avatar
2 votes
0 answers
68 views

I don't understand this part of the Ethereum Documentation (storageRoot)

This is from the account part of the Ethereum Docs, 4 fields of an account were described of which i am unable to understand this one. (storageRoot)
ameymeow's user avatar
  • 115
2 votes
1 answer
108 views

Decentralized Storage for sensitive data

As the title says, is there any decentralized storage technology for storing sensitive data like the personal information of users? Concretely, I am developing a Dapp on blockchain, where users have ...
Hoang Nguyen's user avatar
2 votes
0 answers
147 views

Solidity array has no SLOAD optimization

Suppose a function writes to storage, and then reads from the same storage location before it has been overwritten. In solidity 0.8.11 in these cases the SLOAD gets optimized away (there is 1 SSTORE ...
Jesbus's user avatar
  • 10.5k
2 votes
0 answers
187 views

Why is the EVM designed to have "private variables"?

In EVM, one contract is able to read code and balance of any addresses. However, storage and nonce of other addresses is not accessible. Since all states are public on the blockchain, why is EVM ...
zzh1996's user avatar
  • 141
2 votes
0 answers
246 views

Converting static variable to memory

I have the following code snippet in my contract, trying to call flashLoan from Aave. address private constant LINK = 0x...; function myFlashLoanCall(uint256 _amount, bytes memory _params) public {...
mtheorylord's user avatar
2 votes
0 answers
966 views

Running Geth full node + archiving on tiered storage possible?

I'm trying to run a geth full node with archiving for development\learning and custom analytics. I have a physical Windows server running HyperV where I carved out the following VM specs: 24 vCPUs ...
The Unique Paul Smith's user avatar
2 votes
0 answers
45 views

Why `array[array.length] = elem;` fails for appending to a dynamic storage array in Solidity?

Consider the following contract: pragma solidity ^0.8.0; // SPDX-License-Identifier: WTFPL contract Demo { uint256[] public numbers; function append(uint256 num) public { ...
Ahmed Ihsan Tawfeeq's user avatar
2 votes
0 answers
254 views

How to initialize storage for smart contracts in the genesis block

I have a simple smart contract that will be added as part of genesis block. Need to initialize the field "message" with default value as constructor is not executed as part of genesis block ...
Prashanth Babu T's user avatar
2 votes
0 answers
428 views

How to store array parameter of a function to contract state?

I am trying to save an invoice to contract storage (see function addNewInvoice(..)) but I seem to be tripping over the data locations. // SPDX-License-Identifier: private pragma solidity >=0.7.0; ...
chspr's user avatar
  • 21
2 votes
0 answers
113 views

Can we use Ethereum Swarm to store normal data other than blockchain or dapp data.

I want some basic data to be stored like name and city phone no etc.So just want to ask can I use ethereum swarm just to store file and make several node to create decentralized storage.
Talha Shan's user avatar
2 votes
0 answers
264 views

Gas cost of adding an item to a class-level (storage) array

I would like to make sure that the gas cost of adding an item to a (storage) array is constant, i.e., not dependent on the length of the array. To my understanding, the relevant EVM operation is ...
goodvibration's user avatar
2 votes
0 answers
94 views

Plasma: how were the UTXO bitmaps conceptualised and how will they be stored?

From the white paper, page 5: We construct an interactive game whereby the exiting party attests to a bitmap of participants’ ledger outputs arranged in an UTXO model which requests a ...
Paul Razvan Berg's user avatar
2 votes
0 answers
181 views

What is a cheap way to store mnemonic generator list of 1024 words in smart contract?

What is the cheapest way to store a list of 1024 words for a mnemonic generator, and why? These ideas had a gas cost of 165720 GAS for a string array, and 42300 GAS for storing all the words in a ...
nim's user avatar
  • 21
2 votes
0 answers
259 views

Decentralized File Storage on Ethereum white paper

I am reading white paper of Ethereum, and I am confused by this example of the Section. Decentralized File Storage, which is part of the Section. Applications: The key underpinning piece of such a ...
fluency03's user avatar
  • 201
2 votes
0 answers
48 views

Share private data and prevent data forwarding

Let's say A has some private medical records of patients and B is a pharmaceutical company who wants to view medical records from A to find out the effect of a particular drug on the patients (run a ...
Rajrup Ghosh's user avatar
2 votes
1 answer
122 views

Decentralized Data Storage for IoT using Sia

For my Master research I want to make a proof-of-concept of decentralized data storage for an IoT scenario. My idea is to receive measurement values from a raspberry pi and to store them using sia. I ...
Mindful's user avatar
  • 393
2 votes
0 answers
135 views

Is it possible for a mapping to run out of space?

Can storage mappings in a contract run out of space? Say that mapping was keyed to an address and the value as the following struct: User bytes32 name uint8 age Theoretically, if there was a ...
The Nomad's user avatar
  • 399
2 votes
0 answers
166 views

Extremely slow sync after moving to external drive (macOS; thunderbolt)

I was getting low on disk space so I decided to move the blockchain to an external drive with thunderbolt. I did it using Method 2 from this answer: In Mist browser how can I move the data (blockchain)...
user avatar
2 votes
0 answers
185 views

Global storage array - setting length on declaration vs inside a function

I have a global storage array of 64 entries, which I declare as follows: uint256[64] globalArr; However, its length really depends on a constant variable in my code: uint8 constant MAX_VAL = 63; ...
goodvibration's user avatar
2 votes
0 answers
205 views

In a private blockchain network, can we delete the first N blocks and reassign the N+1th block as the genesis block?

I am aware of the data loss caused by deleting the first N blocks. But I am curious to know whether such a task is possible or not. If so, how to practically implement it? ( I am using go-ethereum. ...
spharish's user avatar
  • 297
1 vote
1 answer
16 views

getting invalid opcode

this is my Solidity code // SPDX-License-Identifier: MIT pragma solidity ^0.8.7; // pragma solidity ^0.8.0; // pragma solidity >=0.8.0 <0.9.0; contract SimpleStorage { uint256 ...
Shlok Bhargude's user avatar
1 vote
1 answer
475 views

Automatically getting implementation contract for eip 1967 proxy

Let's say I wanted to write code which looks at a smart contract, detects whether it is an upgradeable proxy, and then fetches the contract address. Something like so: const functionNames = abi.map((...
Abraham P's user avatar
  • 103
1 vote
0 answers
24 views

Struct string not saving to storage from mapping

Good morning guys, I would like to get some help with some declaration that I am doing in my solidity contract, basically I want to have some data on my registry from a user, such as if it is admin, ...
Marxian's user avatar
  • 66
1 vote
0 answers
147 views

Foundry : cast storage command storage slot argument posing length issue

When I try to get the private variable stored at storage slot 0 of the contract storage using the cast storage command, cast storage <my-contract-address> 0 --rpc-url <my-rpc-url> I get ...
h4mster's user avatar
  • 11
1 vote
1 answer
56 views

Null keys when using `debug_storageRangeAt`

I'm currently trying to use the debug_storageRangeAt on a Hyperledger Besu RPC to extract the contract storage. For some contracts I get the expected response which is a list of keys and values: "...
Valentín Fernández's user avatar
1 vote
1 answer
31 views

i have an upgradable smart contract with 3 mappings, i set only the first two in the initialize function

i have an upgradable smart contract with 3 mappings, i set only the first two in the initialize function . pragma solidity ^0.8.0; contract ContractA { mapping(uint256 => address) public ...
noro meb's user avatar
  • 368
1 vote
0 answers
40 views

"How to limit the function call for all users except those who have a special token with the address 'X'?"

hi i'm continuing to explore solidity. I wrote a contract which contains 4 functions: addAuthorizedAddress, removeAuthorizedAddress, storeData, retrieveData. The last two: storeData and retrieveData ...
Lll Cilician's user avatar
1 vote
0 answers
94 views

Gas Optimisation of updating/reading struct in mapping

I'm trying to shave off a few thousand GAS from a transaction. I have the following struct in a mapping: struct Data{ uint8[4] a uint8[4] b bytes5 z; } mapping(uint => Data) public ...
AnAllergyToAnalogy's user avatar
1 vote
0 answers
92 views

Which contract's storage does SLOAD/SSTORE use?

A given SSTORE and SLOAD instruction uses storage from a certain smart contract. How can we know which contract that is, and do we need any additional data than the raw struct/opcode traces to find ...
Vegard Stikbakke's user avatar
1 vote
1 answer
40 views

Replace storage with the use of events. Considerations, risks?

I'm testing to not use state variables and relay on events and an external service to know the latest state and history of, in the simple example above, a Document. You can think about Document as a ...
mtabasco's user avatar
1 vote
1 answer
68 views

Unable to reach storage struct via mapping

Gm, I've got a smart contract for 2D board game purposes. There is a struct Unit struct Unit { UnitType unitType; uint16 x; uint16 y; int8 hp; int8 dmg; ...
Ghinter's user avatar
  • 31
1 vote
0 answers
510 views

Retrieve Storage Variable Name given Storage Location and Contract Source

Is there any easy way to get the storage variable names provided you have the source code and the storage locations of the variables for a contract? For example, for the following contract I can use ...
Travis Carpenter's user avatar
1 vote
1 answer
71 views

Why does Ethereum state storage cost more than history storage?

According to this spreadsheet that Vitalik has referenced before, stating that it's what they used to determine gas fees for each opcode, state storage costs around 190 gas per byte while history ...
Paul DeLucia's user avatar
1 vote
1 answer
67 views

Max storage a mapping can hold

If I have a mapping that lets users store strings in a mapping ( by index). How many strings could the contract hold? Not worried about gas this will be on an L2
degendeveloper's user avatar
1 vote
2 answers
439 views

Why does this function not update my storage array?

Since reference types such as arrays are passed by reference by in Solidity, they pass a reference (pointer) to the value. Any change to that value will reflect on original value. If this is the case, ...
Emrah's user avatar
  • 1,682
1 vote
0 answers
29 views

Is it wrong to read or trust historical information from logs in client side?

I noticed one thing while learning Events/Logs from some sources. If I understand these sources correctly nodes can remove logs for effective memory usage. If my client tries to read logs that do not ...
Murad Sofi's user avatar
1 vote
0 answers
15 views

Is storage being passed to this newly created contract?

I'm looking at uniswapv3 code and noticed something peculiar. When uniswap creates a pool, it lays out parameters in storage and then immediately deletes them after the contract is created. Is this ...
user1099123's user avatar
1 vote
0 answers
12 views

Concept Check: Data Server Nodes, Fetch Nodes

I had this idea for a way to make it possible to run a MUCH MUCH smaller node but still mine on a chain. I don't know if there is anything useful in it, but decided I would post it here for feedback ...
Saveer Jain's user avatar