Questions tagged [storage]
all questions regarding data and storage on the ethereum blockchain
419
questions
2
votes
1answer
26 views
Issues with extreme large solidity mapping
Is there any scalability problem if the number of items of a solidity mapping increase too much? For example, any problem when adding, changing or removing some item in the dataset? Or any other ...
0
votes
1answer
37 views
If I pass an enum as a parameter does it get stored in the blockchain?
I'm developing a Rock/Paper/Scissors Smart Contract (with a Commit-Reveal scheme).
I have this enum: enum Move {rock, paper, scissors}
I want to pass it to a function, without storing it to the ...
0
votes
0answers
12 views
Why do you always have to declare the “memory” keyword for strings inside a function? [duplicate]
Example:
function myfunc (string memory words) public returns (string memory) {
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
}
Why is it compulsory to declare the "memory" keyword?
Would the ...
0
votes
0answers
16 views
In Solidity, Modifiers & Mapping variable are stored where - storage or memory?
In Solidity, Modifiers & Mapping variable are stored where - storage or memory ?
0
votes
1answer
29 views
Is there any way to find out what exchange a ETH wallet was created?
I added a ETH wallet address to Genesis Mining back in 2017 for a 2 year contract. After the contract was finished it still took them a year to add the ETH to said Wallet. (long story but I did not ...
0
votes
0answers
19 views
How many key-value entries can be stored in Solidity Mapping data structure?
mapping(uint => uint) public myMap;
function store(uint key, uint val) public {
myMap[key]=val;
}
function retrieve(uint key) public view returns (uint){
return myMap[key];
}
Considering ...
0
votes
1answer
19 views
Where is the data of a transaction saved?
To introduce my question I would like to give an example.
Suppose a customer wants to join a gym. A transaction is sent and contains:
customer id
name and surname
start date
end date
The smart ...
1
vote
0answers
23 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
36 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
23 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
26 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
29 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
52 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
52 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
17 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
62 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
53 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
22 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
94 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
18 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
111 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
21 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
28 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
141 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
76 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
32 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
66 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
53 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
77 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
324 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
47 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 ...
1
vote
1answer
108 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
26 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
29 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 ...
0
votes
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
40 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
34 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
24 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
28 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
181 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
226 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 ...