Questions tagged [local-variables]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
10 views

Remix does not show openzeppelin counter variable in Debugger

My local x variable is appearing in the debugger, why is the game_id variable not showing up?
user avatar
  • 146
0 votes
0 answers
13 views

Understanding local variables named as same in diffrent functions and modifiers

I'm confused while understanding the local variable _txId is used in several functions and modifiers, do they all have the same value or are they independent for each call. I read that local variables ...
user avatar
  • 24
0 votes
0 answers
16 views

How can I check the previous values of smart contract variables?

If I have a variable uint public data = 42; and in the next invocation of a smart contract's function, this is now data=43. Can I somehow check and find the previous value (i.e., data=42) ??? Where ...
user avatar
  • 15
1 vote
1 answer
19 views

Memory to memory assignment doesn't point to the same reference

Hey I am trying to understand data location more it is stated in the docs that "Assignments from memory to memory only create references. This means that changes to one memory variable are also ...
user avatar
0 votes
0 answers
87 views

Brownie compile error when using import statement

I'm using brownie version 1.17.2. When I do brownie compile, I got this: Here you can see the contract that gives me an error How can I know why is failing? EDIT 1: I already added openzeppeling ...
user avatar
1 vote
1 answer
139 views

What is the most gas efficient way to initialise a struct?

Say I define a struct named MyStruct and a local variable called myStruct, what is the most gas efficient way to assign/update 1 or more fields/members of myStruct? If I wanted to assign a new value ...
user avatar
  • 240
1 vote
1 answer
232 views

Is it more gas efficient to declare variable inside or outside of a for or while loop?

In solidity does declaring a variable inside a while or for loop result in that variable being redeclared during each loop iteration? And if so does that make it less gas efficient than say declaring ...
user avatar
  • 240
1 vote
0 answers
44 views

Dapptools Fork Impersonation?

In hardhat, theres a way to 'impersonateSigner' and fake a signature from an address you dont own on a forked mainnet; is there a way to do the same with seth? Naively setting the sender doesnt let me ...
user avatar
0 votes
1 answer
22 views

variable in WGAME woolf.sol confuses me

Okay, so I was looking over the wolf contract(https://etherscan.io/address/0xeb834ae72b30866af20a6ce5440fa598bfad3a42#code), to understand how they fixed it and what happened... and one thing just ...
user avatar
0 votes
0 answers
25 views

Stack too deep, try removing local variables when using remix [duplicate]

while compiling in remix i get the above error: CompilerError: Stack too deep, try removing local variables. --> work/youkie.sol:1015:80: | 1015 | (uint256 rAmount, uint256 ...
user avatar
  • 21
1 vote
1 answer
40 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 ...
user avatar
0 votes
0 answers
107 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 ...
user avatar
6 votes
1 answer
280 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 ...
user avatar
1 vote
0 answers
26 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 ...
user avatar
0 votes
1 answer
24 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 ...
user avatar
4 votes
1 answer
403 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 ...
user avatar
1 vote
3 answers
809 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 ...
user avatar
6 votes
1 answer
509 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 (...
user avatar
  • 626
2 votes
1 answer
363 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; ...
user avatar
  • 145
2 votes
1 answer
104 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 ...
user avatar
5 votes
2 answers
942 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 ...
user avatar
  • 2,286
0 votes
0 answers
624 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 ...
user avatar
2 votes
1 answer
695 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 ...
user avatar
  • 285
13 votes
2 answers
12k 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 ...
user avatar
  • 175
4 votes
2 answers
1k 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 ...
user avatar
  • 234