Deployed a contract using Remix IDE to Rinkeby testnet.

Etherscan contract address and code is here.

contract SimpleCounter {
    int counter;

    constructor() public {
        counter = 0;

    function getCounter() public view returns (int){
        return counter;

    function increment() public {
        counter += 1;

    function decrement() public {
        counter -= 1;

JavaScript client code:

    var contract;


    function initContract(){
        web3 = new Web3(web3.currentProvider);

        var address = "0xc6482382047fb50e8e7b4658425c9756b28f995c";
        var abi = [

        console.log('Create contract...');
        contract = new web3.eth.Contract(abi, address);

    } //initContract()

    function getCounterValue(){
        contract.methods.getCounter().call().then((result) => {


Create contract...

(index):86 o {_requestManager: e, givenProvider: MetamaskInpageProvider, providers: {…}, _provider: MetamaskInpageProvider, …}

(index):94 getCounter()...

(index):99 err...

Error: Returned values aren't valid, did it run Out of Gas?


This works fine in Remix IDE (chrome). I'm able to increment/decrement/getCounter... with compiler version:0.4.25+commit.59dbf8f1.Emscripten.clang .

Why does it fail, when accessing it using 'dist/web3.min.js' of Web3.js (Branch 1.0)?


I fixed the similar error by deleting .json files from build/contracts folder and then running truffle migrate in the terminal.

However, the error occurred in Visual Studio Code, not Remix IDE. It appeared after running truffle migrate --reset.

| improve this answer | |
  • 1
    @monkrus The issue I had reported was due to using 'account address', instead of 'contract address'!. Deleting .json wouldn't fix that. You might want to add 'exact problem' along with error - to differentiate 'your scenario' and related fix, for clarity. – RafiAlhamd Feb 6 '19 at 15:33
  • @Ismael Thanks for pointing it out. To add more clarity... the issue worked in Remix IDE, but not in custom JavaScript code. – RafiAlhamd Feb 6 '19 at 15:40

I got help from Veniamin.

I had error "Error: Couldn't decode from ABI: 0x." when call get request with wrong contract address

I made a mistake... I was using 'account address', instead of 'contract address'!

The code works, once correct 'contract address' was used.

| improve this answer | |
  • 1
    It is worthy of noting that the address of the contract is different than the address of the account that creates the contract and it is generated when the contract is created. – Ahmed Akhtar Jul 11 '19 at 7:56

Your code seems to be correct. I think your problem is due to a Web3js bug. Have a look at the issue reported in Github :


I recommand you to use web3.js 1.0.0-beta.35 instead.

| improve this answer | |
  • Switched to version web3.js 1.0.0-beta.35. But, this time the error is different: Error: Couldn't decode from ABI: 0x. – RafiAlhamd Oct 10 '18 at 13:44
  • 1
    Check your contract address – Badr Bellaj Oct 10 '18 at 20:27
  • Already fixed. Have added my answer below. Got help from GitHub. – RafiAlhamd Oct 11 '18 at 9:52

I had this error too. It got fixed after I changed my web3 version to 2.0.0-alpha which was 1.0.0-beta.55 before.

  1. So just uninstall your web3 using npm uninstall web3.
  2. Then do npm install web3@2.0.0-alpha.

Hopefully, this will fix it for you.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.