Stack Exchange Network

Stack Exchange network consists of 174 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 [memory]

Questions related to memory use in Solidity or by nodes

0
votes
1answer
22 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 ...
2
votes
2answers
204 views

convert bytes to uint8[8] using mstore()

I know how to convert bytes to uint8[8] using mload but mstore seemed like it could be more gas efficient. Is something like this possible? function bytesToUintArray(bytes input) returns (uint8[8])) ...
1
vote
1answer
2k views

GPU'S Failed cannot create DAG

Last night everything is fine and then this morning I check my mining its's closed I think it was restarted or close accidentally then when I open my pool I have this error. ETH: 5 pools are ...
1
vote
1answer
968 views

Memory usage and limits for go-ethereum

geth (and swarm) seem to require a lot of memory, and there are also reports that they tend to an all you can eat approach to system limits. 1) What are the actual memory requirements for geth? 2) ...
5
votes
3answers
165 views

Why memory arrays are unresizable?

I don't know the required length of my array before execution of the function.. why technically can't I resize my memory array? What is the common way to go around of this problem, if you are also ...
3
votes
1answer
64 views

Are balances of all accounts in memory or disk (storage)?

I simulated two contracts that sending balance to another and simply setting value of a variable(var a = 5;). In contrast my expectation, {var a = 5;} contract consumed more gas than the other. In my ...
0
votes
1answer
584 views

Is there a maximum size for arrays in Solidity?

In my solidity code I define 3 arrays with around 700 elements inside. However, when I try to deploy the contract using Geth I am having the following error message: Error: oversized data undefined ...
0
votes
2answers
28 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 { ...
1
vote
0answers
11 views

getLogs RPC makes filters?

I am stuggling with memory explosion issue of Parity on my EC2 instance. The memory usage of it keeps increasing gradually. I suspect that getLogs API call makes some garbage on the node. But I ...
18
votes
4answers
5k views

How to store IPFS hash using bytes?

Following Q/A (What datatype should I use for an IPFS address hash?) recommend us to use bytes to store IPFS hash. I was using following example(https://github.com/AdrianClv/ethereum-ipfs/blob/master/...
2
votes
1answer
29 views

memory keyword in function argument

What does the memory keyword in the argument of a function do? pragma solidity 0.4.24; pragma experimental "ABIEncoderV2"; contract Conditional { struct Condition { address to; bytes4 ...
1
vote
1answer
86 views

Creating a 2D in-memory array in Solidity

I'm trying to work with 2D in-memory arrays in Solidity, in which the size is not known at compile time. I've noticed that if I define the array size as a constant, then I can use this syntax, which ...
4
votes
2answers
1k views

How to fill dynamic in-memory array

For some reason solidity doesn't allow to push values into memory array Member "push" is not available in bytes32[] memory outside of storage. Here is sample contract code: pragma solidity ^0.4....
2
votes
1answer
151 views

Declaring a memory array of storage pointers in Solidity

I would like to declare a variable as a memory array of pointers to storage arrays of uint256. For example: pragma solidity ^0.4.24; contract A { uint256[] public array0; uint256[] public ...
1
vote
3answers
55 views

Should I use `storage` or `memory` when just reading the value and not changing state?

pragma solidity 0.4.24; contract Test { struct Book { uint id; } Book[] books; uint public status; constructor() public { books.push(Book(10)); } ...
0
votes
0answers
27 views

Problem creating struct inside a struct

Currently I am developing a game in solidity, I have 2 structs as follow: struct Team{ address owner; uint[] players; uint8[] moves; } struct Game{ Team challenger; Team ...
4
votes
1answer
443 views

Assigning an array creates a pointer or copies an array? (Solidity)

Here is the code: pragma solidity^0.4.16; contract Test { struct SomeData { address[] users; } address[] nullArray; mapping(uint => SomeData) SomeDataList; function ...
0
votes
0answers
35 views

How to use multidimensional memory array in solidity

I'm working with a project where I have requirement of multidimensional memory array. Here is basic structure of types and person(s) Id -Types -0 -Person1 -Person2 -1 -Person1 -...
1
vote
1answer
31 views

How can I get the content of storage and memory in my private chain?

I'm looking for some methods to know the content of storage and memory while the contract is running.Mayba some useful tools or abi ? By the way, the abi of geth, debug_writeMemProfile and ...
5
votes
1answer
282 views

How does dynamic array memory reallocating work?

Let's say I have a dynamic array of some length and I want to push a new element, but memory after last elem is already used. What would happen in such case? Compiler would find a new 'chunk' of ...
1
vote
1answer
227 views

Help with setting up Private POA(Clique) Ethereum Network

Geth Version : 1.8.12-stable-37685930 Testing on Amazon EC2 t2.large(8GB RAM) machine with Ubuntu 16.04 running. I am in need of setting up a multi node private POA(Clique) ethereum network. ...
4
votes
2answers
3k views

How to initialize an empty array inside a struct?

Is there a mistake in the way I initialize Bar b in the function foobar? contract Foo { struct Bar { address owner; uint[] x; } Bar[] public bars; function foobar(...
1
vote
2answers
460 views

Examples to clarify Storage vs Memory assignments / return parameters

Is there a mistake in funcB? I do not understand why/when to mention the variable name of the return parameter in the function signature. contract Foo { // State variables go to Storage uint[...
0
votes
1answer
50 views

Solidity state variable resets to default inside function

For this project, I am coding smart contracts for Ethereum using Solidity. In the following code, the variable numCertificates should initially be 1. Nonetheless, newCertificateId is 0 when assigned. ...
3
votes
2answers
90 views

How to pop from (decrease the length of) a memory array in Solidity

I have a function that gets an address array from another contract, conditionally deletes the msg.sender from the array, then saves the new array back to that contract. Because the array backerList ...
25
votes
1answer
12k views

What does the keyword “memory” do exactly?

I've been looking through the code of Etherdice and noticed that some variables are declared like ParserResult memory result; and I haven't found the keyword "memory" in any documentation. What I ...
1
vote
1answer
54 views

Compare memory pointers in Solidity

Is there a way to compare pointers in Solidity? I have two local variables: uint256[] memory a = new uint256[](256); uint256[] memory b = a; If I try a == b I get this compiler error: TypeError: ...
2
votes
1answer
104 views

Always use “memory” for variables created within functions. Bad practice?

Is it bad practice to systematically use the memory keyword for variables declared within a function (other than constructor)?
2
votes
1answer
1k views

The difference between contract address and wallet address

Disclaimer: this is a rather long question. To my understanding, contract address and wallet address are two profoundly different concepts, with the only thing in common being the fact that they are ...
0
votes
1answer
124 views

Why do arrays declared within functions reference storage point 0 by default?

According to the Solidity Documentation, for the following code, ". . . the compiler interprets x as a storage pointer and will make it point to the storage slot 0 by default. This has the effect ...
10
votes
2answers
953 views

error: Storage location can only be given for array or struct types

Getting the error "Storage location can only be given for array or struct types" in a setup function. The exact line is uint memory _total = 0; I'm confused by the error, because I'm not trying to ...
0
votes
1answer
55 views

how to replace an array in a mapping?

I'm learning solidity right now and making a dApp where users get paid to perform actions. Actions are paid based on certain criteria. Since I can't schedule a cron job on ethereum, I can only pay ...
1
vote
2answers
1k views

Why cryptokitties uses storage instead of memory?

There are a lot of explainations of storage and memory out there like this question or this question. But I'm wondering why cryptokitties for example uses storage instead of memory in many functions. ...
4
votes
2answers
782 views

Invalid array length, expected integer literal

I'm trying to declare an in-memory array with a fixed length: uint length = 10; uint[length] memory priorityList; However, it just displays this error message: Invalid array length, expected ...
0
votes
0answers
82 views

Solidity memory pointer

Is there any way I can use a local parameter within multiple functions? The idea is to save gas when calling functions. A parameter wouldn't have to be copied and be returned every time. Here's some ...
0
votes
0answers
22 views

How much storage does a smart contract use

I am trying to show the storage used by a deployed smart contract, I have a piece of code here that shows the first 10 indexes, let contractAddress = '0xf1f5896ace3a78c347eb7eab503450bc93bd0c3b' for (...
1
vote
2answers
58 views

value types(uint, bool, etc) as local variable is set to memory initially?

According to this answer, it says simpler variables like bool, uint, et cetera are not variable in length, and are therefore defaulted to memory, whereas this one mentions uint256 v; is default to ...
19
votes
2answers
7k views

Can I save structs in a Mapping?

Is it possible to store structs in a Mapping or any dynamic memory structure in my Solidity SmartContract?
1
vote
0answers
65 views

Quorum failure - Failed to decode message from payload

We use in our project -JP Morgan Quorum (Ethereum based) bloackchain - with istanbul voting mode. We have 4 nodes (3 of them are validators - hard coded, nonchangable) And from time to time (...
0
votes
0answers
20 views

how can I initialized bytes1 array? is there maximum size to do that?

I want to initialize bytes1 array as follows, function myData(bytes1[10] _inData) public pure { bytes1[100] memory myCData = [ bytes1(0x01), 0x02, ......so on.. till 100 ]; } But I got out of ...
1
vote
0answers
24 views

Solidity VM memory management

I'm trying to do an external function call in assembly. So I have to prepare a memory area that store the input args. But where's the address that I should start with mstore? I mean, there are some ...
0
votes
1answer
260 views

I got “ TypeError: Storage location can only ..”

Here is my sample contract code, but I got an error, TypeError: Storage location can only be given for array or struct types. I just wannted to define some element of a structure in a function, ...
2
votes
1answer
91 views

Can marking object as 'memory' before pushing in Array save gas?

We have a struct: struct structEx { uint num; } And an array: structEx[] arr; Have a look at this code snippet, which just instantiates the struct and push: function f() public { structEx s =...
2
votes
1answer
297 views

Delete an entry in a mapping

To my understanding, delete x merely sets the value of x to the default value defined for the type of x (which is typically 0 in one way or another). For example: uint x = 1; delete x; // sets x = 0 ...
0
votes
0answers
22 views

Do I need to specify memory on the array variables?

Refer to the code below: function query() public returns (uint32[] memory) { uint32[] memory Bla; ... bla.... bla... bla... return Bla; } Do I really need to specify the memory keyword ...
1
vote
0answers
21 views

How load out data from blockchain when it occupies too much space?

If the blockchain working long enough it fills the memory of the mining device, how to load out the data and then rerun the system? and why does my mining device has different miner address every time ...
0
votes
0answers
34 views

Where this data is stored where i deploy a contract? [duplicate]

I am very curious where are stored the data like (on Blockchain in smart contract) : -sender -caller Storage or memory ?
2
votes
1answer
51 views

Examples of functions limitations?

I coded different functions and didn't find a standard that define crystal clear how many variables you can use (fields, local or as parameters of modifiers inside this function? Do you know a ...
2
votes
1answer
2k views

Restrict CPU/memory usage of geth while syncing

I'm trying to run a geth node and a bitcoin core node on one server. I started with a DigitalOcean droplet with 2 CPU and 2GB memory, but both the geth and bitcoin node would run out of memory. I ...
1
vote
1answer
3k views

Type error: memory is not implicitly convertible to expected type

I have a function that returns a list of BetProposition smart contracts: function getBetsForMatchup(uint matchupIdentifier) public returns (BetProposition[]) { return bets[matchupIdentifier]; ...