Questions tagged [local-variables]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
11
votes
2answers
9k views

Local variable and state variable, and the difference between them

I am new to solidity. When I read the solidity documentation, it says local variable and state variable. But I can't find the definition of the two terms. Can anyone explain the meaning of local ...
6
votes
1answer
176 views

Public variable getter shows as transaction in Remix

As of Solidity 0.6.0+ compiler, my remix shows getter functions, built by public variables, as transactions and, therefore, do not return the value. I searched the solidity 0.6.0 breaking changes but ...
6
votes
1answer
377 views

Truffle debug on function call show null variables

With a truffle version of 4.1.0, using truffle debug on a call of my contract function below: function Deposit (uint256 timeout, bytes32 hash, address recipient) public payable returns (...
5
votes
2answers
710 views

Stack too deep | Use memory array to store many “local” variables?

I have a contract that's doing a fairly complex calculation with some intermediate calculations, and I'm running into the "stack too deep" problem. I've tried to use a memory array within the ...
4
votes
2answers
646 views

Local storage variable

I am reading the solidity docs here and I seem to be struggling to understand the following. Data locations are important because they change how assignments behave: assignments between ...
2
votes
1answer
338 views

local var inside a function modifies another state variable

I have this very simple contract: pragma solidity ^0.4.18; contract C{ uint public a = 9; uint[] public data; function f(uint _a) public{ a = _a; uint[] y; ...
2
votes
1answer
169 views

Pointing to other contracts in solidity?

I'm doing the CryptoZombies tutorial to get a better handle on solidity and in one of the chapters it contains the following code pragma solidity ^0.4.19; import "./zombiefactory.sol"; contract ...
2
votes
1answer
97 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
469 views

State Variable Storage in Contracts

I'm learning Solidity. According to the docs, variables are permanently stored in contract storage. From my understanding (I may be wrong), the details are on the blockchain. My question is, how do I ...
1
vote
1answer
25 views

Total Supply manipulation after moving to a new standard with _mint function

How can I access totalSupply after refactoring to using a _mint function instead of local state? I will need this to make transfers from the owner to another address. Does this example show that this ...
1
vote
3answers
498 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 ...
1
vote
0answers
24 views

What's the best way to send many strings in only one call?

So I have to write on-chain about 15 string key-value pairs in one call. Of course, I took the naive approach first by putting all those strings as arguments of my contract, but then I run onto the 16 ...
0
votes
1answer
20 views

Error accesing variables from other solidity file

I get a error when I call to the getVal function inside testToken file. The EVM return me the following: call to testCoin.getVal errored: VM error: revert. revert The transaction has been reverted ...
0
votes
0answers
85 views

Unable to change/read local variable in a smart contract on a local private geth blockchain

I trying to create and test an ERC-20 Token on a local geth blockchain. I tried compiling and testing my contract on Remix's Javascript VM environment and it works fine. Then, I wanted to try ...
0
votes
0answers
547 views

Truffle: errors when I try to access variables of a ERC20 token contract

I got a few errors when I try to access variables of a ERC20 token contract. The contract is the "Sample fixed supply token contract" from https://theethereum.wiki/w/index.php/ERC20_Token_Standard ...