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.

Aug 1, 2018 in Blockchain by sabby
• 4,390 points
884 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,100 points

Related Questions In Blockchain

0 votes
0 answers
+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 27, 2018 in Blockchain by Johnathon
• 9,090 points
2,487 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
1,655 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,211 views
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
• 69,210 points
1,229 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,100 points
3,338 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,100 points
552 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP