Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [storage]

all questions regarding data and storage on the ethereum blockchain

0
votes
1answer
25 views

How to set multiple unit64 values in a uint256 variable

I have followed following answer for: Having trouble storing multiple values in a uint256. For example, I want to pass four uint64 variables merged together as a single argument into smart contract ...
1
vote
1answer
18 views

Struct member access in web3 requires additional dummy field

If a struct contains a single field, then that field is inaccessible from web3. In the below example, field uint b must also be present in order to access field uint c from web3. Of course, it's not ...
1
vote
1answer
13 views

Can anyone with part of the chain (e.g. a light node) read unencrypted transaction data?

I need clarification on the fact that "the blockchain is public and anyone can read it". Given a node which is storing only, say, 1 block from the blockchain, can that node read the transaction data ...
1
vote
1answer
20 views

is there a list type in solidity?

I know there are dynamically sized arrays, but I need a data structure that can remove elements from the middle cheaply. Using pop() with a dynamically sized array should require a shift of every ...
0
votes
1answer
8 views

Unstructured storage proxies. Variables not being overwritten?

When using delegate call I was under the impression that storage slots declared in the proxy will be overwritten by the implementation. Unstructured storage implementations declare bytes32 variables ...
0
votes
1answer
22 views

map multikey how-to?

I'm trying to create a map whose key is composed of two bytes32 keys. I've tried with tuples-keys and struct-keys but both are rejected by the compiler. I'm also thinking about "hashing" both keys ...
0
votes
2answers
16 views

Std set in solidity?

Is there any way or library to have a set in solidity that can be iterated like C++'s std::set? library Set { // We define a new struct datatype that will be used to // hold its data in the ...
0
votes
1answer
19 views

Does increasing the size of array guarantees that new elements are initialized to default value?

I get an error when trying to initialize array inside a struct of an array and I find this post: https://github.com/ethereum/solidity/issues/4115 . It seems that I have to work around by increasing ...
1
vote
1answer
14 views

Return each struct value from a key inside a mapping, where the key is also a value from array inside another mapping

I have a project that I'm working on and I'm trying to figure out a way to do as the title says. I'm looking for the easiest and/or cheapest way(gas wise) and since I'm stuck I'm open to better ways ...
2
votes
0answers
11 views

Most efficient way to get all non-zero storage locations for a smart contract?

I'm looking at a mainnet smart contract and want to figure out all storage positions/slots where the storage has a non-zero value. Is there a way to do this other than replaying and tracing all ...
0
votes
2answers
19 views

how does Storing and Fetching data works in Smart contracts [closed]

Please help me out with these questions. 1)Where does the contract stores the data? 2)when we access the value of a variable form of a contract, how does it retrieve the latest value? 3)how is the ...
0
votes
1answer
33 views

Costs/efficiency of locating stored data on Ethereum

Based on the answer to this question, storing IPFS hashes on Ethereum could be done in 3 ways: Store it as a string Store it as a struct Store it in event log Ordered from most expensive to least ...
0
votes
1answer
25 views

error: data location must be storage or memory for parameter in funtion but none was given solidity [duplicate]

pragma solidity ^0.5.0; contract Election{ //model a candidates struct candidate { uint id; string name; uint votecount; } //store candidates //fetch candidate mapping(uint =...
1
vote
2answers
46 views

Reset all values in a mapping

I am trying to figure out how to have the balance of all players reset to (amount) when a certain condition happens. This is the function that will update a specific player balance. How do I make it ...
0
votes
1answer
17 views

How to push new struct to storage?

I get an error when trying to push the newRound struct to storage. How can it be fixed? Error: UnimplementedFeatureError: Copying of type struct Lottery.Ticket memory[] memory to storage not yet ...
0
votes
1answer
15 views

Cannot retrieve data from smartcontract during tests

I am writing truffle tests for my smart contract solidity version 0.4.24. The tests are emitting events to write data to memory through smart contract. But I am unable to retrieve data from functions. ...
0
votes
2answers
57 views

Default getter and setter for mapping in solidity

In my smart contract I've public mapping as mapping (uint=>User) public users where User is a Struct, so is there any way to get the values of this mapping using default getter. For Example : If ...
0
votes
1answer
56 views

Invalid type for argument in function call. Invalid implicit conversion from mapping

I have defined struct for saving data to ethereum blockchain. I am using uint to map the data stored with a unique ID. I am using truffle framework to write smart contracts with solidity version: 0.4....
1
vote
3answers
125 views

how do I loop through a mapping of address [duplicate]

I have a mapping of list of struct (mapping (address => struct[])) I'm having a trouble in how to display all them together in the front end (i'm using React js). Thnx.
1
vote
3answers
35 views

What mechanism to use to pay for viewing another users data on blockchain

I am new to blockchain development and following some tutorials I have created a DApp that allows a user to save and view information. Now, i want to let another user view that saved information but ...
0
votes
1answer
35 views

How Ethereum blocks are stored?

Is each block on Ethereum blockchain stored as lots of files, a separate file per each block? Or a database? How does one can run Etherenum node shared over several servers?
2
votes
1answer
50 views

Where is string stored in solidity storage?

I'm trying to check where is stored a string in storage in Solidity. For testing this I'm using this code: pragma solidity 0.5.4; contract AssemblyString { string s; // slot 0 function set(...
1
vote
1answer
27 views

Can abstract contracts in solidity have state variables?

I want to have one deployed contract with my data structure and all data and another separate contract with functions that calls the deployed contract. If i've understood things correctly, one should ...
1
vote
1answer
18 views

Costs in gas of changing the value of a variable

Maybe a little bit weird question, but can the amount of gas, when: SSTORE is used(for changing an existing variable), be lesser than 5000 gas? If no, are there discussions in community to reduce ...
0
votes
1answer
26 views

Pushing constructor result to contract member array

I'm trying to do the following operation in Solidity: BetCampaign memory newCampaign = BetCampaign(id, new Bet[](0), betEndTime, false); betCampaigns.push(newCampaign); With the following member ...
0
votes
1answer
43 views

Transaction pending

If I call this function the transaction get pending and never finish. Any idea? pragma solidity ^0.4.24; contract test { uint[] values = [1,2,3,4,5,6]; function removeValueFromArray(uint _num) ...
-1
votes
1answer
55 views

Identity Verification [closed]

I am trying to build a certificate DAPP, where the universities will upload certificates/degrees of students to the blockchain. But How can I verify that the university is genuine and its the ...
0
votes
1answer
18 views

Read storage struct from a modifier

If i read a struct(storage) Human storage human = humans[2]; in my modifier is there a possibility that the function that uses this modifier can use the "human"? Otherwise i have to scope the storage ...
2
votes
2answers
147 views

Why are transaction tries in Ethereum not plain Merkle Tries?

I understand the Ethereum block header contains a Merkle Patricia Trie (MPT) root for the global state, one for receipts (which I don't understand but am not focussed on for now), and one for all the ...
0
votes
1answer
21 views

Can I just change just 1 bit of data in a smart contract?

Can I just change 1 bit of data in a smart contract? More specifically would this allow me to make a smart contract where it is really cheap just to flip specific bits. This would be like setting ...
4
votes
1answer
53 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 ...
0
votes
1answer
46 views

Storing User data on blockchain

I am currently using the structure and mapping to store the user data in the blockchain. In the mapping I am using user's address (msg.sender) for mapping it with structure so every user can only ...
0
votes
1answer
32 views

Index 0 in empty address array reverts

I have a struct that has an array of addresses. When the address array is empty and I try to get index 0 I would expect it to return address(0), but instead it reverts. Any way around this? struct ...
1
vote
1answer
183 views

Remix - Contract creation initialization returns data with length of more than 24576 bytes. The deployment will likely fails). What can be done?

I get the following error when deploying my contract in Remix: Contract creation initialization returns data with length of more than 24576 bytes. The deployment will likely fails. More info: eip-...
1
vote
1answer
67 views

How to search through blockchain?

I m doing project for document verification using blockchain in which we don't have to carry documents everywhere, hash key of block will fetch data of doc from blockchain.I m not getting how to ...
0
votes
1answer
22 views

Associate event struct to user addresses

I have two contracts. One called User and other called Event pragma solidity ^0.4.24; contract User { mapping(uint=>address) addresses; uint addressRegistryCount; } pragma solidity ^...
1
vote
0answers
53 views

What filesystem should I use for geth and leveldb?

I used old LGA775 machine for running geth node. Its mobo has older sata 3gb/s (benchmark showed that ssd bottlenecked there) and only 4gb of DDR2, with windows installed. So syncing is a real pain ...
1
vote
2answers
51 views

How could Solidity 0.5.0 dynamic sized parameters be declared as storage?

As I understand it 'memory' in the EVM is a byte array and cannot be dynamically resized, whereas 'storage' is able to be resized. What is happening when a parameter is declared as storage. Where is ...
1
vote
1answer
29 views

Does a storage array have a unique address on the block-chain?

The question in the title is a little vague, so I will try to explain here. Suppose I have a contract with a storage array: pragma solidity 0.4.24; contract MyContract { uint256[10] public ...
0
votes
1answer
44 views

Is it possible to have 15 variables in a struct in solidity?

I have a struct with two variables bool, nine bytes 32 and three uint. The problems I want to add another bytes32 but I get this error "InternalCompilerError: Stack too deep, try removing local ...
1
vote
1answer
36 views

How to understand the storage process in solidity?

What is the meaning of : require(newKittenId == uint256(uint32(newKittenId))); Edit: Complete relevant code: uint256 newKittenId = kitties.push(_kitty) - 1; // It's probably never going to happen, ...
0
votes
2answers
29 views

The cost of using Ethereum as a reference database

As stated in the documentation there are 3 types of storage in the Ethereum VM (EVM) The storage, the memory, and the stack Each account has a data area called storage, which is persistent ...
3
votes
2answers
69 views

Why is the Eternal Storage approach still used if it hugely increases gas usage compared to storing data in structs?

I was wondering why is the eternal storage approach (first code snippet) still used? I know it's meant to make contracts upgradable but it seems too expensive to me. contract Storage { mapping(...
1
vote
0answers
26 views

Why is an address changing when I add it to an array?

I'm encountering a memory / storage issue (I think) w/ an array of addresses where I want to swap out one address with another. Here's how I've initialized the array: address[] public maintainers; ...
2
votes
2answers
134 views

How do I read an array inside of a struct?

as part of learning solidity and smart-contract development, I am developing a simple part management/tracking system. I have a struct and a mapping for a list of parts as such: struct Part { uint ...
0
votes
3answers
51 views

Is There any way to check if the entered key is having a corresponding value in a mapping or not?

Suppose In a banking system many people are enrolled (managed through mapping ) mapping (address => bool) enrolled; And only those can deposit who are enrolled in the bank. Can I check if ...
1
vote
1answer
28 views

How the data management is done in Ethereum blockchain?

Anyone who have a good idea about ethereum blockchain storage can send me some docs to get a good idea for myself? i am in a full confused state.
6
votes
1answer
6k views

TypeError: Data location must be “storage” or “memory” for parameter in function, but none was given

/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param ...
2
votes
3answers
194 views

How to handle dynamic size string array in solidity?

I have a shop owner and a shop owner can have multiple products. I want to keep the products id in an array. Also, A public method can return all the product id list of a shop owner. I tried the ...
1
vote
2answers
61 views

Where are local variables of Primitive (Elementary) data types stored in Solidity

Though in the latest solidity compiler versions, it has been made clear that for reference variables local to a function, one needs to now explicitly mention its location modifier (memory, storage), ...