'Failing transaction when calling a funciton from geth console

I am discovering the blockchain world step by step, but I am facing a problem that I can't solve.

I am using this simple smart contract from the Solidity documentation:

pragma solidity >=0.4.0 <0.7.0;

contract SimpleStorage {
    uint storedData;

    function set(uint x) public {
        storedData = x;
    }

    function get() public view returns (uint) {
        return storedData;
    }
}

I compile the code with Remix, and when I deploy it on JavascriptVM, everything works fine, I can change the stored value.

However, when I deploy it on a private geth node (using web3deploy), the contract is successfully mined but when I try to use the set() function storage.set(4,{from:eth.accounts[0]}) it always returns "gas required exceeds allowance or always failing transaction", even if the account has sufficient funds.

I feel that I am missing something important but I can't figure it out. Someone help would be appreciated! thks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source