Questions tagged [storage]

all questions regarding data and storage on the ethereum blockchain

Filter by
Sorted by
Tagged with
3
votes
2answers
95 views

Map or Array…?

I'm having a huge dilemma! I'm developping a smart contract that has, let's say Struct A and Struct B. Because I want to have a function retrieving all objects type A and B, I created a Struct All ...
1
vote
1answer
20 views

Whats the best way of translating this struct?

Let's say I must have this data structure: ├── Operations (struct) │ ├── date_begining (uint) │ └── date_end (uint) │ └── responsible (address) │ └── type **(?)** │ ├── Observation (...
0
votes
2answers
21 views

Costs of storing an empty dynamic array of length 2**256-1 vs length 4

If the array is completely empty, is it more expensive to store uint[] of length 2**256-1 vs of length 4?
0
votes
0answers
19 views

Where's a contract storage stored exactly and how does it interact with the blockchain? [duplicate]

From what I've understood a contract is a special account that gets initialized with a 256 bit array and this array is stored as the root hash of a merkle tree, is that correct? But where is this ...
0
votes
1answer
31 views

Is it possible to set a struct property as undefined or null?

In JavaScript we're able to have: Object { a: number; b?: string; c: number; d?: string; } b and d being optional, these can be left out during variable initialisation. Is this possible in ...
0
votes
1answer
24 views

Read and write products using solidity

I am new to Solidity, trying to store a product in the purchaser wallet and retrieve the information from the owner wallet. I have some ideas but didn't know which one will be best. To store an ...
0
votes
1answer
22 views

Fire transaction from contract

I have a contract holding a mapping like this: mapping (address => User) users. How can I get the contract to automatically fire a transaction/event when a certain condition is met? For example, ...
0
votes
1answer
30 views

How to properly initialize nested storage array/struct?

contract Contract { struct A { int a; } struct B { A[] as; } mapping(address => B[]) bs; function addB(B memory b) { bs[msg.sender].push(...???...); } } I have nested hell of arrays and ...
0
votes
1answer
16 views

How data is stored in Ethereum blockchain?

If I become a full node in Ethereum and retrieve the current state, how all this data is going to be stored in my physical drive?
0
votes
0answers
28 views

Efficient way to save and retrieve hash in blockchain

I am learning Ethereum using Geth. I have a private blockchain and I am saving hashes through a REST API (python web service). I have readed I can save hash values using maps (mapping data type) and ...
0
votes
1answer
21 views

Storing name values off-chain in events and web3.js

Somewhere I read the advice to store name (title, geographical name, people name, etc.) value off-chain in events. But if a value is stored in an event, is there an efficient way to retrieve its ...
1
vote
1answer
40 views

Storing multiple values in one key mapping (Solidity)

Can I store multiple values in one key mapping in solidity? like I can retrieve all of the values if I use that one mapping key? Is this possible?
0
votes
0answers
33 views

Safe usage of delegatecall

Hey guys I have a few questions about delegatecall. The setup: I have 2 contracts A and B. A has 2 uint state variables B has 4 uint state variables To ensure storage layout compatibility, B ...
0
votes
1answer
13 views

A smart contract's storage problem , further ERC ?

Er .. I have a question about smart contract , a single smart contract's storage capacity Follow the answer is this question: Is there a (theoretical) limit for amount of data that a contract can ...
0
votes
4answers
51 views

Mutating slot 0 of a storage array in Solidity assembly

Have been working on a function allow users to edit specific types of state using Solidity assembly, and ran into some unexpected behavior. According to the documentation, for a storage array arr ...
0
votes
1answer
13 views

arrays and structs for function arguments

A lot of contracts and libraries with functions that use arrays and structs for arguments. Structs can themselves include arrays, structs and mappings. For example: function doSomething(MyStruct ...
0
votes
1answer
8 views

Can you have an array of mappings? The mappings have an address key and a struct value

Can you have an array of mappings? I want to have mappings with addresses as keys and structs as the value. I want to store these addresses in an array and iterate through them. so far it looks like ...
5
votes
4answers
121 views

Efficient Solidity storage pattern for a directional weighted graph

I would like my graph's nodes to each have a struct of data and 0 or more pointers to other nodes. It needs to be efficient for insertions of new nodes in between two existing nodes. Should I use ...
0
votes
1answer
30 views

Ethereum Petabyte Storage Problem

As the need of blockchain systems grows so will be the storage issues and the cost of handling such large amounts of data. Is ethereum capable of handling petabyte storage or is it upto an ...
2
votes
2answers
34 views

loop though all the members of a map

I need to loop though all of the members of a map and change their property (which is a struct). the way i'm doing this is when adding a member to the map object also save it's address inside an ...
0
votes
1answer
25 views

Data storage and replication in a private blockchain

What type of data is Ethereum storing (file? data row in DB)? Where does it put it (theoreticaly it is stored in peers, does this mean every node must have a local db)? How the peers of the p2p ...
1
vote
1answer
40 views

Add Number to Item in all Struct Members

I have a struct where I want to increment an item across all struct members. For example, say there is a struct 'Contract', and new customers get their own bytes32 ID, which points to their own struct:...
0
votes
1answer
15 views

Modify the state using returned variable (Array.push)

In my contact I want to have one place where I find an existing object(struct) and then use it in multiple places to read and modify it - but seems like it's not possible? contract A { struct ...
0
votes
2answers
20 views

Set contract storage directly at deployment

Is there a way to pre-define a contracts storage when deploying it? Say I want a mapping to be filled with 1000 entries but want to avoid having to pay gas for adding every entry on its own. Since ...
1
vote
1answer
40 views

How to download the blockchain of a single ethereum contract’s address?

The blockchain required to run ethereum is several Terabytes large. This means more than 9 years would be required to download it with my connection speed. In my case, I just want to know if the ...
0
votes
1answer
13 views

Does packing bools alongside addresses reduce storage costs?

Say I have a struct like this: struct MyStruct { bool foo; uint256 bar; uint256 baz; address qux; } If I rewrite it like this: struct MyStruct { bool foo; address qux; ...
0
votes
0answers
12 views

How to find which transaction cleared a specific address into a specific contract?

I have a contract with contains the following solidity code mapping (address => mapping (bytes32)) public sealedBids; But I failed to find in the solidity code which part can clear it. As result,...
0
votes
1answer
78 views

How to save data using multiple structures and arrays in solidity?

How can i use multiple arrays please? e.g: I have this contract: pragma solidity >=0.4.21 <0.6.0; contract SessionManagement { struct ChargeProfileSegment{ uint startDateTimeSeg;...
0
votes
2answers
89 views

Decentralized database for ethereum?

I'm looking for a way to store data in a decentralized way such that I can access any record from within the smart contract, probably through oracles I guess? I've been looking into gundb but not ...
0
votes
2answers
71 views

Why is storing via sstore more expensive than via events mechanism?

I just do not understand why emit Event(...) is cheaper than a = b. The only difference I noted between events and storage variables is that event logs is not accessible from Solidity. But both of ...
0
votes
1answer
484 views

Is it possible to insert some custom data in the DATA field of an Ethereum Transaction?

i am working on trying to get some data encoded/inserted into an ethereum transaction. Let me describe my environment first, i am using Web3py, Ganache and Remix IDE. I am able to successfully ...
-1
votes
2answers
107 views

Truffle uint test script not updating storage variable, and strange behaviour

while testing I got a strange behavior of truffle, please see the subject smart contract code first uint256 public burningRatePercent = 50; function onlyOwnerSetBurningRate(uint256 ...
0
votes
1answer
29 views

Mappings inside functions to filter query

I have a struct and several boolean mappings that are used to keep track of struct's properties struct Animal { string species; bytes32 ID; } mapping (bytes32 => Animal) public Animals; ...
0
votes
1answer
66 views

Return an array of structs using events?

I wan’t my function to spit out an array of structs. I know this is not straightforwardly possible. What is the best way for me to proceed? Should I loop through my array in my function and trigger ...
1
vote
0answers
10 views

What are the rules on persisting old transactions?

If a new node joins the network and attempts a full sync, it requires all transaction information from genesis to build up its chain state. To do this the transactions it receives must be the ...
1
vote
1answer
27 views

What is the benefit of leaving data in the stroage area instead of the log?

I did not write English well and used a translator. sorry :3 I would like to know the benefit of leaving data in the storage area rather than using the event log. I know gas consumption has less log....
0
votes
1answer
38 views

CRUD storage pattern Infinite gas error when trying to implement in Remix

I'm trying to implement @robhitchens CRUD storage pattern in solidity, and I'm getting infinate gas costs when I import the library. Not sure where to go from here. one of them: Gas requirement of ...
0
votes
1answer
19 views

can't get struct in return

I am trying to execute unit tests for a solidity smart contract: I have: mapping (bytes16=>Device) public Device_Table struct Device { bytes16 UUID; bytes16 hardware_UUID; string ...
0
votes
1answer
37 views

Multiple Inheritance at particular contract address

I'm attempting to have 4 different contracts sharing the same data fields. The reasoning behind having 4 instead of 1, is that the different functionality can be broken down so that it is cleaner, ...
2
votes
2answers
111 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 (...
3
votes
2answers
108 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
53 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
60 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
29 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
35 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
41 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
60 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
74 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
40 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 ...

1 2 3 4 5 8