Questions tagged [state-variable]

The tag has no usage guidance.

21 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
1answer
456 views

What are 'payable' state variables?

https://solidity.readthedocs.io/en/latest/solidity-by-example.html#simple-open-auction pragma solidity ^0.4.22; contract SimpleAuction { address payable public beneficiary; What exactly does ...
2
votes
2answers
126 views

Is Solidity creating an implicit getter for a nested contract that is created?

Is Solidity creating an implicit getter or not for a nested contract that is created? Example: contract Foo { .... } contract Bar { Foo public foo; Bar() { foo = new Foo(); } ...
1
vote
0answers
22 views

Read smart contract data from blockchain itself

I'm trying to figure out if it's possible to read smart contract data from the blockchain itself. I know in ordinary circumstances, smart contracts sit on top of the chain in the ledger. I'd like to ...
1
vote
1answer
62 views

Receiving error while getting state variable value after using selfdestruct method "Error: Returned values aren't valid, did it run Out of Gas?"

I am using selfdestruct method and passing the payable address to it but receiving the following error when trying to get the value of a state variable : "Error: Returned values aren't valid, did it ...
1
vote
0answers
40 views

Retrieving a State_object value on go-ethereum

I have a deployed contract address and I need to query a contract storage value, a token account balance that is stored on a mapping variable: mapping (address => uint256) balances; From go-...
1
vote
1answer
91 views

Accessing the Ethereum State Variables using web3js (Java Script)

I'm trying to run the below code to get the state variables using the getIdBytes method of the Smart Contract, and assign it to a java script array variable, but it doesn't seem to work. All I can ...
1
vote
0answers
32 views

Best way to restore historical storage state

What is the best way to get historical storage state, given db with current world state and blockchain data? Do I need to reverse assemby code or can I do this using receipt logs?
1
vote
0answers
77 views

Layout of State Variables in Storage -> specifically NON Statically-sized variables e.g. Mapping

The following page provides information on how to access a contract's state variables, regardless of who the owner is or what methods are exposed. http://solidity.readthedocs.io/en/latest/...
0
votes
1answer
23 views

ERC20 token, override functions but state variable do not update as expected

I am trying to implement and test an ERC20 token by inheriting from ERC20.sol from OpenZeppelin. I want most of the functions to be by default from OpenZeppelin but I also want to overrride some of ...
0
votes
0answers
19 views

can I change loop logic to an alternative logic in this staking contract?

I built a staking contract that allows users to enroll in auto compounding through a function that is basically adding the user address to an array UserList Now for auto compounding I have these ...
0
votes
0answers
23 views

State (Dynamic) Array Returning Null (using Web.js)

I am trying to return a dynamic state array full of hashes, using Web.js. Currently the function on the Web3.js side is returning null in the console.log. Here's my Contract: pragma solidity >=0.4....
0
votes
0answers
15 views

Race condition when trying to read state after transaction

I am using web3.js library to interact with a smart contract, and am having issues with a race condition and not sure how to fix it. I am sending a transaction to the chain, and then waiting for the ...
0
votes
1answer
17 views

Does it matter if state variables are assigned value in line or in the constructor?

For example, is there a difference between these two snippets of code, or is there a best practice? From my experimentation, it doesn't seem like it makes a difference. Thanks. contract A { uint ...
0
votes
0answers
12 views

Burn a token relatively to another's contract variable

I have a contract deployed with a variable that increases everytime a new transaction is made. I would like to create a token with some burn depending on the variable value. For example I would like ...
0
votes
0answers
68 views

The data type of the return value of the solidity function has changed

As you can see, I have designed a struct in the solidity.There is a function in the solidity with the return value type User mapping(address => User) public _userInfoMap; struct User{ uint ...
0
votes
0answers
34 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
0answers
53 views

if "address public x = tx.origin", why does "require (tx.origin == x") work and "require (tx.origin==tx.origin) not

Below is a contract that i have commented on, hoping to understand the logic of the arguments. Below in bold is the question in question. The .sol currently works fine. pragma solidity ^0.5.11; ...
0
votes
0answers
59 views

Can we issue a token with specific local state?

Will it be possible to create an ERC20-Token, that will be "minted" with specific local state on a per token-basis while this state can change over time through the execution of a method in the smart ...
0
votes
0answers
232 views

How to interact with a smart contract to change a variable state

How do I change a variable in a smartcontract (bool) As requested, a new followup question from the above^ about ethereum smart contracts (solidity) If I have, early in the contract: bool public ...
0
votes
1answer
68 views

Unable to change the length of a global 2D storage array

I am facing difficulties changing the length of a global 2D storage array. It seems to be working correctly on Remix IDE, but when I try to test it on ganache-cli (formerly known as testrpc) - either ...
0
votes
0answers
634 views

totalSupply in ERC20Basic contract is not initialized to zero. Does that matter?

I copied code from TenX, which copied code from OpenZeppelin. TenX and OpenZeppelin has this code for contract ERC20Basic: contract ERC20Basic { uint256 public totalSupply; function balanceOf(...