Questions tagged [storage]

all questions regarding data and storage on the ethereum blockchain

Filter by
Sorted by
Tagged with
0
votes
1answer
11 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
37 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
0answers
29 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
72 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
21 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
20 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
9 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
26 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
24 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
18 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
32 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
62 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 (...
2
votes
2answers
34 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
36 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
49 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
24 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
22 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
26 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
21 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
36 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
38 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
58 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
41 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
20 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
25 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
17 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
31 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
20 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
23 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
32 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
14 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
43 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
41 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
82 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
92 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
20 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
25 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
207 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
125 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
262 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
38 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
72 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
84 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
53 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
34 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
65 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) ...
0
votes
1answer
133 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 ...