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

1
vote
0answers
14 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
15 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
11 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
20 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
25 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
30 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
15 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
116 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 ...
3
votes
1answer
46 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
29 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
22 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
56 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
34 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
16 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
31 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
31 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
40 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
34 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 ...
2
votes
2answers
61 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
65 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
27 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 ...
0
votes
1answer
24 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
4k 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 ...
1
vote
2answers
50 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), ...
3
votes
1answer
17 views

In Solidity, how does the slot assignation work for storage variables when there's inheritance?

In a simple solidity contract, without inheritance, storage variables get assigned sequentially starting from slot 0. But in case of inheritance, the inherited variables appear before or afterwards?
1
vote
1answer
59 views

IPFS Versioning for dynamic content

is it possible to keep versioning in IPFS? Like im saving one row of record like pid:1, mid:3, status: started --> v1 pid:1, mid:3 status;completed --> v1.1 is there any way to implement ...
0
votes
1answer
32 views

Finding the memory position of mapping(address => uint) using JavaScript

I am wanting to read data from internal mappings with the following structures: mapping (uint256 => uint256) internal nums; mapping (address => uint256) internal addrToInt; Finding the memory ...
1
vote
1answer
66 views

Are constant state variables cached in the EVM?

From the docs: constant for state variables: Disallows assignment (except initialisation), does not occupy storage slot. Does this mean that the EVM caches constants across all contracts using ...
1
vote
1answer
25 views

Gas cost difference between uint[] and mapping(uint => uint)

When mapping for example a large integer to some integer, uint[] index; index.length = 1000000; index[600001] = 4; is it cheaper to use mapping(uint => uint) index; index[600001] = 4; ? one ...
0
votes
1answer
20 views

Membership in a set of strings

I'm looking solidity help in storing a set of strings and checking for membership in that set. I have a concrete and an abstract question on that: Concrete What is the data structure in solidity ...
0
votes
3answers
75 views

What are my blockchain options when I have terabytes of data to access?

I have several terabytes of relatively simple data, not much more complicated than the ledger storing ids, timestamps, simple metadata. I understand ETH storage costs are rather expensive. What are ...
1
vote
0answers
27 views

Finding the memory position of a mapping [duplicate]

I want to read data from an internal mapping variable using getStorageAt(), but this requires knowledge of the index where that variable is stored in memory. The documentation says: Due to their ...
1
vote
2answers
84 views

How To store data in ethereum network using truffle framework ?How to achieve the database layer in dapps?

I am creating a dapp which has to be a login authentication system and some datas has to be store in database. So I really cant' store all the datas in Solidity's variable or class object, it has to ...
0
votes
1answer
30 views

Can storage be referenced without being copied?

With for example struct Foo { mapping(address => uint) b; } Foo[] foo; if a function only deals with foo[4], can it reference it from storage without copying it? is that what function c() { ...
0
votes
1answer
19 views

Read List of Posts using struct

I tried to read a list of posts using the code below struct posts { bytes32 postTag; string post; address[] acceptedBy; uint8[] voteCount; } mapping(address => posts) totaluserPosts; ...
2
votes
0answers
49 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.
0
votes
2answers
58 views

What is the proper pattern to use a temporary variable and ensure it gets stored?

A contract has a state variable, which is complex. For the example, lets say it is a mapping of structs. Inside a method, I want to access that and store the changes. Like so: contract FooManager { ...
0
votes
1answer
40 views

crypto-signing in a smart contract -> verify the identity of a smart contract

my Question in short is: -> is it possible to digitally sign some data by a smart contract (e.g. with a secret key of the contract) and thus confirm that it was exactly this smart contract, who ...
0
votes
2answers
136 views

How to check if element of struct array has been deleted?

So let's say that I have struct A and an array A[] of struct A's I then fill 3 first indexes of A[] with some A's. I then delete second index of A[] and and want to test if it has been deleted. In ...
0
votes
2answers
66 views

How can I store and read data from Etherum blockchain? [closed]

I'm doing a project and I want to store some basic information on Etherum, for example: Name, ID, Height, Weight. How can I store this on the blockchain and after that be availble to read it. I read ...
1
vote
0answers
23 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 ...
1
vote
1answer
172 views

Does Ethereum Swarm work?

I need to upload 8Tb data to Swarm. I read docs but I can't understand: does public swarm work?
2
votes
1answer
32 views

Data Search Complexity in Ethereum

I am new to Ethereum and wish to know that how is data for a smart contract fetched in Ethereum Blockchain. When we store the value of a variable in a smart contract, say simple storage (https://...
0
votes
1answer
19 views

Delete function affects my array in my struct

I am using the function mentioned below to delete a user (i added delete entityList[rowToDelete] to the function )My main issue is that the function deletes the user but somehow I lose the data in ...
1
vote
1answer
49 views

How can we calculate swarm storage cost?

I am trying to integrate ethereum to another fin-tech app, the basic idea is to store the transaction details on swarm and then pass the hash on ethereum network. I haven't used swarm earlier and I am ...
0
votes
1answer
45 views

Creating an automatically ordered pledge list. Can I do better in terms of gas?

Inspired by What's the best way to return top X values in a mapping? and Are there well-solved and simple storage patterns for Solidity?, I've created a data structure that automatically orders ...