Questions tagged [storage]

all questions regarding data and storage on the ethereum blockchain

1
vote
2answers
25 views

Where is the length of an array located in terms of memory layout?

For example, given the following cases: uint[3] memory arr; uint[] memory arr = new uint[](3); Suppose I try to access arr from within an assembly block (using mload, for example). Where (...
0
votes
2answers
13 views

returning the struct value in smart contract and experimental ABIEncoderV2

I am storing and returning the struct value by using mapping. pragma solidity >=0.5.0 <0.7.0; pragma experimental ABIEncoderV2; contract Manage{ struct Policy{ string PolicyID ; } ...
0
votes
2answers
28 views

Finding a better way to retrieve information about struct

I've run into a problem about getting information about the structs. The code is written below: pragma solidity ^0.4.23; contract Transport { address public manager; Batch[] public ...
2
votes
1answer
45 views

why a parameter must be “storage” or “memory”?

I am creating a token like this: pragma solidity ^0.5.0; import "../utils/math/SafeMath.sol"; contract ExampleDivisibleNFTs { using SafeMath for uint256; // Percentage of ownership over a ...
1
vote
1answer
23 views

How do programs on the 'Ethereum World Computer' compare to traditional programs or websites?

So this question has been bugging for me for a while and I can't seem to find the answer to it. Context I have been a web developer for many years. When I access a website, any frontend code is run ...
1
vote
1answer
15 views

Doubt regarding gas cost

Consider im having to deal with 3 uint8 values each of which are to be stored for each user. Is the gas cost the same if i use 3 different arrays or if i use a structure array which contains the 3 ...
0
votes
1answer
19 views

pass storage through interface to library

Here is what am i doing: There is a library, accept storage argument as parameter, then do some math and return the result. And there is a contract to call the function in the library, and an extra ...
0
votes
1answer
22 views

How to store and encrypt Keys?

I am developing chrome extension like metamask for the private Chain. I have generated the keys and using localStorage to store the Keys. But I am not sure whether I am going correct or not for ...
0
votes
1answer
19 views

Does ERC-20 balanceOf function cost no gas?

Given that this is a sample balanceOf function code: function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } and this function is view function,...
1
vote
2answers
28 views

Mapping primary key of each struct in array to them-self

pragma solidity ^0.4.17; contract Campaign{ struct Transaction { address Creditor; uint Amount; } Transaction[] public Transactionss; mapping(address => Transaction) ...
3
votes
1answer
37 views

How is The Graph a decentralised solution?

I understand that querying for data on Ethereum is a pain in the neck and that The Graph indexes events so that developers can more easily get their most precious blockchain data. However, I'm not ...
0
votes
0answers
10 views

What is the maximum storage size to store number of addresses in array? [duplicate]

I want to map multiple addresses using one address by doing this: mapping (address => arrayOfAddresses[]) mappingName; What is the maximum size of addresses I can store in that array?
0
votes
1answer
38 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
33 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
16 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
21 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
12 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
26 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 ...
1
vote
2answers
18 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
21 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
26 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
12 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
27 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
39 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
66 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
66 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
18 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
17 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
134 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
102 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
206 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
37 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
47 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
68 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
42 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
20 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
31 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
58 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
89 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
19 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
181 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
22 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 ...
3
votes
1answer
80 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
79 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
42 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
349 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
106 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
31 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
76 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
62 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 ...