How to get the current state of a smart contract?

0 votes

I am writing a Smart Contract using Solidity. I am using two contract methods as getResult - to get state of contract - and setNumber(uint num)- to update current value of state.But every time I call getResult method after setNumber(10) it returns original value, not the updated one.

Jul 31, 2018 in Blockchain by sabby
• 4,350 points
49 views

1 answer to this question.

0 votes

Hey, you gotta provide the contract code, and also supply the client side (JavaScript, I guess?) code used to set and get the values.

Anyway, as much as I can understand from your question, your problem could be that you are calling setNumber(10) on your smart contract i.e. myContract.setNumber.call(10). Doing this wont actually update the state of the contract as .call() simply looks up the current state of the chain rather than altering it.

answered Aug 1, 2018 by Perry
• 17,020 points

Related Questions In Blockchain

+1 vote
1 answer

How does a miner get to know that a transaction is verified by all the nodes?

Contrary to the popular belief, it is ...READ MORE

answered Mar 26, 2018 in Blockchain by Johnathon
• 9,080 points
79 views
+1 vote
4 answers

How to estimate the cost for deploying smart contract on mainnet?

Since you have already deployed the contract ...READ MORE

answered Apr 9, 2018 in Blockchain by Shashank
• 10,350 points
1,481 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
157 views
0 votes
1 answer
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 67,600 points
88 views
0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 17,020 points
418 views
0 votes
1 answer

How is a request sent from an app to a smart contract?

Yes, the contract is distributed by every node ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 17,020 points
57 views