12

State Variables From the solidity docs here, State variables are values which are permanently stored in contract storage. and can be declared in a contract as follow, contract SimpleStorage { uint storedData; // State variable // ... } Local variables Carries the usual meaning, that their context is within a function and cannot be accessed ...


3

You are declaring y as a storage but you left unitialized so y points to the same slot than a. The first 32 bytes of an array in storage is the array length, and after that follows the data. So the first a = _a will set the array length. And then y.push(2900) will append a new value to the array incrementing its length.


3

So my temp variable assignments were causing the problem. It works if limiting to 8 assignments at a time: This fails (9 variable assignments): (temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6], temp[7], temp[8]) = (1, 2, 3, 4, 5, 6, 7, 8, 9); But this works (8 assignments at a time): (temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], ...


2

Maybe you've tried this but some debugging in Remix with empty getter() and someOperation() functions that just return values shows the max stack depth reaches 12 items when I use the first method but only 9 for the second. I'm yet to fully understand the differences but consider using remix and checking the debug screen to help if you haven't already.


2

I believe this was a bug before which is fixed now. Current version i'm using is: $ truffle version Truffle v5.0.20 (core: 5.0.20) Solidity v0.5.0 (solc-js) Node v10.15.3 Web3.js v1.0.0-beta.37 Simple smart contract to reproduce the issue pragma solidity ^0.5.6; contract TruffleDebug { function Deposit (uint256 timeout, bytes32 hash, address ...


2

In the latter example “value” is an empty pointer. You do not initialize it. Assign to it the proper value and all works flawlessly. The easiest way is to have a constructor passing the address of the other contract: constructor (address _DeployedContract) public { value = Value(_DeployedContract); }


1

KittyInterface kittyContract = KittyInterface(ckAddress); ckAddress is not being passed as a parameter to anything. This is a cast (like uint256(5) or address(0)). The line is saying "ckAddress is an address of a contract implementing the KittyInterface interface. I would like to reference that contract using the variable kittyContract."


1

It is confusing indeed. The docs state that by default: Parameters (also return) of functions: memory. All other local variables: storage But variables defined in the scope of a function are not persistent (they are not accessible after the function is executed). In terms of gas (using the code below) executing f will have a transaction cost of about ...


1

I'm not aware of any cheat sheet and the problem is that Solidity checks for local stack size in several different places during a function call but emits the same error message, so depending on how you combine function arguments, variables declared inside the function block and return values, the error message "Stack to deep, try removing local variables" ...


1

in simple terms: is all about the scopes we consider as states all variables defined outside the scope of the defined functions (we can consider them as global variables) whereas local variables are the rest: function arguments and variables declared within functions scope. as you know Each method has its own entirely new scope. Per design, states as ...


Only top voted, non community-wiki answers of a minimum length are eligible