'New to solidity, why is it not returning my integer?
I recently started learning solidity, and have written a very basic contract, but it is not returning my integer and I am not sure why:
pragma solidity ^0.6.0;
contract SimpleStorage {
uint256 favouriteNumber; //This will get initialised as 0, as it is not specified
function store(uint256 _favouriteNumber) public {
favouriteNumber = _favouriteNumber;
}
function retrieve() public view returns(uint256) {
return favouriteNumber;
}
}
Solution 1:[1]
When you set the number on the textbox, you must to click over the orange button called store and after this operation you can click on the retrieve button.
Solution 2:[2]
When you add your value in store, there will be downward arrow, I think you are not clicking the transact button. I have tested your smart contract and it is perfectly fine. check the transact button.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kerry99 |
| Solution 2 | Nerdy19 |
