Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: could not decode result data (value="0x", info={ "method": "pyth", "signature": "pyth()" }, code=BAD_DATA, version=6.10.0) #4827

Closed
henrygagnier opened this issue Feb 6, 2024 · 4 comments
Assignees
Labels
status:needs-more-info There's not enough information to start working on this issue

Comments

@henrygagnier
Copy link

henrygagnier commented Feb 6, 2024

Version of Hardhat

2.19.5

What happened?

I am trying to test a contract. It works on hardhat network but I need to be on a testnet because I am using a price oracle in my contract. When I use console.log(pyth); in the tests it logs the correct address but I am still getting the error Error: could not decode result data (value="0x", info={ "method": "pyth", "signature": "pyth()" }, code=BAD_DATA, version=6.10.0) and a failed test. I don't know what is happening. Thank you, please do not hestitate to ask for more details 🙏🏻

Minimal reproduction steps

My contract (partial)

contract AnchorUSD is ERC20, Ownable(msg.sender) {
    //Pyth Network contract address for chain
    IPyth public pyth;
    constructor(address pythContract) ERC20("Anchor USD", "AUSD") {
        pyth = IPyth(pythContract);
    }
//...
}

The tests

import { expect } from "chai";
import { ethers } from "hardhat";
import { EvmPriceServiceConnection } from "@pythnetwork/pyth-evm-js";
import IPyth from "@pythnetwork/pyth-sdk-solidity/abis/IPyth.json";

const pyth = "0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb";

describe("AnchorUSD", function () {
  it("Should set the right unlockTime", async function () {

    // deploy a lock contract where funds can be withdrawn
    // one year in the future
    const lock = await ethers.deployContract("AnchorUSD", [pyth], {
      value: 0,
    });

    // assert that the value is correct
    console.log(pyth);
    expect(await lock.pyth()).to.equal(pyth);
  });
});

The config

import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

const accounts = [
 (...edited)
]

const config: HardhatUserConfig = {
  defaultNetwork: "fantomTestnet",
  networks: {
    fantomTestnet: {
      url: "https://rpc.ankr.com/fantom_testnet",
      accounts: accounts.map(account => account.privateKey),
    }
  },
  solidity: {
    version: "0.8.20",
    settings: {
      optimizer: {
        enabled: true,
        runs: 999999
      }
    }
  }
};

export default config;

Search terms

Error: could not decode result data, tests

@yunxi-zhang
Copy link

yunxi-zhang commented Feb 13, 2024

I've hit the same issue by using the hardhat and my local Hyperledger Besu networks with the same hardhat version raised by the author, basically, deploying my smart contract works, but when I tried to call one function of my contract to retrieve the value, I've got the issue.

@yunxi-zhang
Copy link

yunxi-zhang commented Feb 13, 2024

@henrygagnier, after doing some digging of the issue, I think the issue you and I got here is because we're using ethers 6.* instead of 5.. Could you check your package.json file and see if the version for your "ethers" is 6.? If so, the reason you've hit your issue is because the functions used in ethers 6.* have been updated. E.g. ethers.deployContract is no longer supported. See the latest API doc for ethers: https://docs.ethers.org/v6/api/contract/. Instead, you should use code in this link: https://hardhat.org/hardhat-runner/docs/guides/deploying. It works for me.

@schaable
Copy link
Member

@yunxi-zhang, thanks for the update! @henrygagnier, can you confirm that the solution proposed is working for you as well?

@schaable schaable added status:needs-more-info There's not enough information to start working on this issue and removed status:triaging labels Feb 15, 2024
@schaable
Copy link
Member

schaable commented Mar 1, 2024

I'll assume this can be closed, but feel free to reopen if the above solution didn't fix your issue.

@schaable schaable closed this as not planned Won't fix, can't repro, duplicate, stale Mar 1, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in Hardhat Mar 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:needs-more-info There's not enough information to start working on this issue
Projects
Archived in project
Development

No branches or pull requests

3 participants