I'm having an error while calling one of the function of the deployed contract from Next.js

Error: Parameter decoding error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.

I tried to search over the internet, somewhere I found the error occurs if you use the account address instead of the contract address, I crossed check if I'm using the correct address, and yes I'm using the correct deployed contract address which is


Please note, my contract is deployed to Sepolia Test Network... The contract ABI is correct so no issue on that too

Next.js code is very simple

import factory from "../../ethereum/factory";

const Home = async () => {
  const campaign = await factory.methods.getDeployedCampaigns().call();

  return (
      <div>Hello, World!</div>

export default Home;

I've imported the factory file from ethereum directory which just provide the Web3 instance of the deployed contract

import web3 from "./web3";
import compiledFactory from "./build/CampaignFactory.json";

const instance = new web3.eth.Contract(

export default instance;

Here I'm importing the web3 file which basically request for metamask

import Web3 from "web3";

let web3;

if (typeof window !== "undefined" && typeof window.ethereum !== "undefined") {
  window.ethereum.request({ method: "eth_requestAccounts" });
  web3 = new Web3(window.ethereum);
} else {
  const provider = new Web3.providers.HttpProvider(process.env.INFURA_LINK);
  web3 = new Web3(provider);

export default web3;

I noticed one thing, is that when I do

const campaign = await factory.methods;

it returns on the logs

  createCampaign: [Function (anonymous)],
  'createCampaign(uint256)': [Function (anonymous)],
  '0xa3303a75': [Function (anonymous)],
  deployedCampaigns: [Function (anonymous)],
  'deployedCampaigns(uint256)': [Function (anonymous)],
  '0x339d50a5': [Function (anonymous)],
  getDeployedCampaigns: [Function (anonymous)],
  'getDeployedCampaigns()': [Function (anonymous)],
  '0x4acb9d4f': [Function (anonymous)]

It seems, that getDeployedCampaigns is available to call, but I'm not sure why calling any of the function throws Out Of Gas issue

Somewhere on the internet I found out that this issue occurs because of the web3 version, trying to resolve it for long now, but no success yet. Would highly appreciate for the help!!!!

Below is the link to the repo Code Repo

  • Can you add the transaction hash for your failed transaction? I couldn't find it on the Sepolia etherscan page for your deployed contract: sepolia.etherscan.io/address/…
    – Rohan Nero
    Sep 13, 2023 at 2:18
  • I re-deployed the contract, and got this hash 0xD50946F99482ac5479F8A643C39985FD936Bd874 in response to result.options.address -------- https://sepolia.etherscan.io/address/0xD50946F99482ac5479F8A643C39985FD936Bd874
    – Mohsin
    Sep 13, 2023 at 21:25

1 Answer 1


Your contract isn't deployed correctly and hence has no code. If you run eth_getCode on Sepolia, it'll return 0x. That's why you fail to call functions of your deployed contract — there aren't any.

  • When I run the deploy script here it gives me the address with console.log(Contract deployed to ${result.options.address});, if it's a failed transaction or the contract has not been deployed then what's the mean of having the address?
    – Mohsin
    Sep 14, 2023 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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