Questions tagged [storage]

all questions regarding data and storage on the ethereum blockchain

Filter by
Sorted by
Tagged with
1
vote
0answers
21 views

How to initialize storage for smart contracts in the genesis block

I have a simple smart contract that will be added as part of genesis block. Need to initialize the field "message" with default value as constructor is not executed as part of genesis block ...
0
votes
1answer
34 views

Do parts of decentralised apps take advantage of centralisation?

So, obviously MetaMask interacts with public, distributed ledgers in order to show my balances, however, from a technical perspective, do certain parts of the application use centralised databases? ...
0
votes
0answers
21 views

How store memory array in storage

In this code, I want to send an array of bytes32 and store them in the struct but I get the error which is TypeError: Type string memory[8] memory is not implicitly convertible to expected type ...
0
votes
0answers
24 views

Does delegatecall() use only the calling function?

Let me explain with the code: contract A { function f() public { [...] g(); } function g() private { [...] } } contract B { A a; function delegateA() public { (bool success, ) = address(...
0
votes
2answers
27 views

Ethereum Smart Contract Storage

I'm currently creating my first dApp, and have some trouble understanding the storage of data of smart contract on the Ethereum blockchain. I've altered the react basic code by adding a constructor. ...
2
votes
0answers
28 views

How to store array parameter of a function to contract state?

I am trying to save an invoice to contract storage (see function addNewInvoice(..)) but I seem to be tripping over the data locations. // SPDX-License-Identifier: private pragma solidity >=0.7.0; ...
2
votes
1answer
47 views

Gas cost of setting a state-variable to the same value

According to this spec, setting a state-variable to the same value consumes 200 gas. However, I conducted a test over ganache-core v2.10.2, and the result was closer to 800 gas: Solidity Contract: ...
0
votes
0answers
30 views

Solidity Encoding Function Call With A Reference Parameter

I'm deploying an external library. This library will have a function that modifies a state variable of the calling contract. I am accessing this library through a proxy contract that stores state. So, ...
0
votes
0answers
16 views

Storage vs Memory in the context of Gas Cost

I have two snippets -- one using memory, the other referencing storage: function winnerName() public view returns (string memory winnerName_) { string memory winnerName_ = ...
1
vote
1answer
55 views

Storage Address of Smart Contract Variables

I need to know storage address of solidity smart contract variables before its deployment. how can I get this?
0
votes
1answer
40 views

Clarification on how Calldata persists on the blockchain and how Optimistic Rollups use it

So I see that a lot of optimistic rollup solutions say that they store the chain's transaction data on Ethereum via "calldata" which is way cheaper in gas costs than contract storage (I ...
0
votes
0answers
18 views

Storing Struct inside an array. Help Please

I am designing an EHR System that will store patient records (with a unique ID) and separated by the date and Hospital entered. I am able to enter data in Hospital struct mapping to the Record struct, ...
0
votes
0answers
21 views

Making sure a string (input/output) is less then 64 characters

I'm working though some basic solidity tutorials using remix. I'm having trouble with the concept that there is no way to edit a string built into the language. In other programing languages I would ...
0
votes
1answer
91 views

How to get data location for string > 31 length

The documentation says: bytes and string are encoded identically. For byte arrays that store data which is 32 or more bytes long, the main slot stores length * 2 + 1 and the data is stored as usual ...
0
votes
0answers
15 views

Performance of Dapps when millions of records to be fetched

I am thinking of Dapp with react js and ethereum. Using IPFS for data storage. Let's assume that blockchain holds millions of hash addresses from IPFS. I need to show those millions of records and ...
0
votes
0answers
69 views

Type struct Mycontract.User memory is not implicitly convertible to expected type struct Mycontract.User storage pointer

pragma solidity >=0.5.0 <0.7.0; contract Mycontract{ uint256 a; struct User { string name; } User[] users; function foo() public{ **User storage user=User("hey&...
0
votes
1answer
29 views

The below code gets compiled but when foo is called invalid opcode error is thrown

pragma solidity >=0.5.0 <0.7.0; contract Mycontract{ uint256 a; struct User { string name; } User[] users; function foo() public{ User storage user=users[0]; ...
0
votes
1answer
42 views

Ethereum Smartcontracts with YottaChain

I am very much curious about this new storage system YottaChain. Can someone point me good articles/videos/sources as a reference to go through and understand its implementation with ethereum smart-...
0
votes
1answer
25 views

why x(function setArr) is not being returned?

pragma solidity >=0.5.0 <0.7.0; contract Example{ uint256[3] x; function setArr(uint256[3] memory y) public returns(uint256[3] memory){ x=y; return getArr(x); } ...
0
votes
1answer
20 views

Understanding data location

pragma solidity ^0.5.16; contract mycontract{ uint256 public a; function foo(string calldata _name) external { string memory names; names = _name; getname(names); ...
0
votes
1answer
27 views

DeclarationError: Uninitialized storage pointer. Struct error when running truffle tests

I've seen other similar questions but they don't explain why this error happens and/or they are case specific questions. So, I have this code: pragma solidity >=0.4.22 <0.7.0; contract ...
1
vote
1answer
81 views

DApp Development- how to update dapp and keep existing data

Compare to web application that separate the application and database, we can update the application and keep the existing data. Could you suggest me how to update dapp and keep the existing data?
0
votes
1answer
45 views

Issue with dynamic matrices in solidity

I have a matrix in solidity like that string x[][] I'm trying to write functions to return rows and colums The following code works well: // SPDX-License-Identifier: unlicensed pragma solidity ^0.6.0; ...
0
votes
1answer
22 views

When using mapping, why use an address over bytes32?

From an end user standpoint, they will never want to use the address for searching for mapped data when they could just submit a username for function parameters, so is there any specific reason why ...
0
votes
0answers
13 views

Data storage : mapping vs sub contract deployment

I read over few website, tutorials and answered question here on SE. There is a huge warning about deploying new contract just to store datas. i.e. : bad uint256 public amount; bool public isAdmin;...
0
votes
1answer
29 views

Passing storage of one library to another library

I have two libraries: A and B as well as contract C using them. Library B, in one of its functions, needs to call a couple of functions defined for A.Storage. The code below compiles, tests are ...
0
votes
0answers
59 views

Storing data directly on chain

Im trying to store data directly on the blockchain, not on a smartcountract as they have a limit of what they can handle and it would slow down the chain to go above the limit. My initial plan is to ...
0
votes
1answer
39 views

Mapping didn't storing unique values

I wrote this piece of code with the goal to store unique documents hash. Used mapping to accomplished that. pragma solidity ^0.5.16; contract DocumentHash{ string public documentHash; ...
0
votes
1answer
50 views

How does Smart-contract's storage works?

I keep hearing that for each contract there is a storage as contiguous array (to have constant O(1) lookup) with 2^256 slots, 32 byte each, available. But it cannot physically be true. How is it ...
0
votes
1answer
65 views

How can I make an off-chain call to get the data stored at a specific storage slot on-chain? [duplicate]

I want to get data from on-chain that is not explicitly available through a getter. For example, if I know that there is data at position ...
0
votes
1answer
243 views

Nested Structs with Mappings Inside

I have the following code: // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.7.0; pragma experimental ABIEncoderV2; contract VenueRegistry{ struct Queue{ uint head; ...
0
votes
0answers
44 views

ERC20 balance Storage Address key - how to tell which key belongs to which wallet address

I am trying to derive changes of account storage by mapping accounts (here, the accounts represent the key address in the ERC20 balances mapping mapping(address => uint256)) to their corresponding ...
0
votes
1answer
18 views

Is data copied or referenced from local storage to global storage?

For example, when a struct is initialised to storage in a function, then assigned to a global state variable such as an array or mapping type, does the local struct get copied to the global state ...
0
votes
1answer
80 views

When and where do I set ERC721 tokens' data?

I am currently working on a smart contract to sell ERC721 tokens. I understand that my code should have a function that allows me (the owner) to mint a token and add it to a list which stores all the ...
1
vote
1answer
25 views

Is transaction history available as a part of the blockchain implementation, or do I have to implement saving token history myself

I am implementing a CryptoKitties style of ERC721 tokens, to be deployed on Ethereum. But I am not clear how to implement the transaction history of the individual token? For example all the ...
0
votes
0answers
25 views

Smart Contact to store data from XLS/CSV file

Is there any existing code/work on how to store data written in an XLS file into Ethereum (geth) using a smart contract? I am trying to publish data that is written in an XLS file onto the Ethereum ...
1
vote
0answers
15 views

How to save/read mappings within struct?

I am trying to create a mapping inside struct and then create a mapping of the struct. Take a look at below example: // ------------------------------------------------------------------------ ...
1
vote
1answer
35 views

Is it cheaper overall to store a keccak hash or to store a ripemd(keccak) hash?

As titled. I'm learning to build a DApp and I'm wondering if it's worth it to add the extra RIPEMD layer over keccak for a shorter hash to reduce storage costs.
3
votes
2answers
33 views

Set and delete storage variable in same tx

I did some poking around and didn't see an answer... and I figure someone knows this off the top of their head. Question: what is the gas cost associated with setting and deleting a storage variable ...
0
votes
0answers
23 views

How do I determine the data storage structure that corresponds to a specific storage address?

My goal is to understand the details of the 1st bZx exploit. I am using the State Changes section of Etherscan to help me accomplish this. Some state changes affect the storage of certain data ...
1
vote
0answers
27 views

Why Does Ethereum Not Support A Native (Non Smart Contract) Form Of Multi-Sig? [duplicate]

After becoming a victim of exchange fraud and witnessing how it negatively impacted the lives of hundreds of others, I'm currently undergoing a study of all the past cryptocurrency exchange hack/fraud ...
1
vote
3answers
164 views

Can the mapping storage change after contract deployment?

I am beginner in mapping.I work on Truffle and Ganache. I deploy the following contract: pragma solidity ^0.5.12; contract customerFinder{ mapping(uint256 => address payable) public ...
0
votes
1answer
184 views

Searching for a value in a dynamic array

I understand that for loops on dynamic arrays are a big no no in Solidity, so I am trying to find an alternative to this problem. Goal: From a dynamic array of numbers, I am trying to extract the ...
3
votes
2answers
116 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 ...
2
votes
1answer
34 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
129 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
53 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
112 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 ...
1
vote
1answer
36 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, ...

1
2 3 4 5
9