Replies: 9 comments 15 replies
-
|
I got the same error I tried fundme.priceFeed without the |
Beta Was this translation helpful? Give feedback.
-
|
@alymurtazamemon, it would be good if you can leave us a short answer when you have free time to resolve these issues |
Beta Was this translation helpful? Give feedback.
-
|
It's so great, I solved this problem when I use ethers v6, of course, switching to v5 is the simplest solution. The following is my code using ethers v6. const { assert } = require("chai")
const { deployments, ethers, getNamedAccounts } = require("hardhat")
describe("FundMe", async () => {
let FundMe
let signer
let MockV3Aggregator
beforeEach(async () => {
// don't use (await getNamedAccounts()).deployer, as a parameter to the getContractAt function, it will report an error !!!
const accounts = await ethers.getSigners()
signer = accounts[0]
await deployments.fixture(["all"])
// there is no getContract function in ethers, so using getContractAt
const FundMeDeployment = await deployments.get("FundMe")
FundMe = await ethers.getContractAt(
FundMeDeployment.abi,
FundMeDeployment.address,
signer,
)
const MockV3AggregatorDeployment = await deployments.get(
"MockV3Aggregator",
)
MockV3Aggregator = await ethers.getContractAt(
MockV3AggregatorDeployment.abi,
MockV3AggregatorDeployment.address,
signer,
)
})
describe("constructor", async () => {
it("sets the aggregator address correctly", async () => {
const response = await FundMe.priceFeed()
assert.equal(response, MockV3Aggregator.target) // get address using target instead of address property
})
})
}) |
Beta Was this translation helpful? Give feedback.
-
|
maybe this code can solve your problem. beforeEach(async function(){
deployer = (await getNamedAccounts()).deployer;
await deployments.fixture(["all"]);
const fundMeDeployment = await deployments.get("FundMe");
fundMe = await ethers.getContractAt(fundMeDeployment.abi, fundMeDeployment.address);
const mockV3AggregatorDeployment = await deployments.get("MockV3Aggregator");
mockV3Aggregator = await ethers.getContractAt(mockV3AggregatorDeployment.abi, mockV3AggregatorDeployment.address);
}) |
Beta Was this translation helpful? Give feedback.
-
|
hello. I also encountered this problem today. Now I have solved this problem. describe("constructor", async function () {
it("sets the aggregator addresses correctly", async function () {
// AggregatorV3Interface = priceFeed
const response = await fundMe.priceFeed
assert.equal(response.address, mockV3Aggregator.address)
})
}) |
Beta Was this translation helpful? Give feedback.
-
|
这是来自QQ邮箱的假期自动回复邮件。您好,您的邮件我已经收到,我会尽快回复,谢谢。
|
Beta Was this translation helpful? Give feedback.
-
|
这是来自QQ邮箱的假期自动回复邮件。您好,您的邮件我已经收到,我会尽快回复,谢谢。
|
Beta Was this translation helpful? Give feedback.
-
|
这是来自QQ邮箱的假期自动回复邮件。您好,您的邮件我已经收到,我会尽快回复,谢谢。
|
Beta Was this translation helpful? Give feedback.
-
|
I have the same problem like you guys,my solution code is as follows const { deployments, ethers } = require("hardhat");
const { assert, expect } = require("chai");
describe("FundMe", async function () {
let FundMe;
let signer;
let MockV3Aggregator;
beforeEach(async function () {
const accounts = await ethers.getSigners();
signer = accounts[0];
await deployments.fixture(["all"]); //Run deploying scripts whose tags include 'all'
const allDeployments = await deployments.all();
console.log("All deployments:", Object.keys(allDeployments));
const FundMeDeployment = await deployments.get("FundMe");
FundMe = await ethers.getContractAt(
FundMeDeployment.abi,
FundMeDeployment.address,
signer
);
console.log("FundMe contract address:", FundMe.address);
const MockV3AggregatorDeployment = await deployments.get(
"MockV3Aggregator"
);
MockV3Aggregator = await ethers.getContractAt(
MockV3AggregatorDeployment.abi,
MockV3AggregatorDeployment.address,
signer
);
console.log(MockV3Aggregator);
});
describe("constructor", async function () {
it("sets the aggregator addresses correctly", async function () {
const response = await FundMe.priceFeed();
assert.equal(response, await MockV3Aggregator.getAddress());
});
});
}); Notice that |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Above is my
FundMe.test.ts. I have tried solutions from issue #5749 but I still get the following error:Error: could not decode result data (value="0x", info={ "method": "priceFeed", "signature": "priceFeed()" }, code=BAD_DATA, version=6.6.4)Here is
package.json:{ "name": "hardhat-fund-me", "version": "1.0.0", "license": "MIT", "devDependencies": { "@chainlink/contracts": "^0.6.1", "@nomicfoundation/hardhat-chai-matchers": "^2.0.0", "@nomicfoundation/hardhat-ethers": "^3.0.0", "@nomicfoundation/hardhat-network-helpers": "^1.0.0", "@nomicfoundation/hardhat-toolbox": "^3.0.0", "@nomicfoundation/hardhat-verify": "^1.0.0", "@nomiclabs/hardhat-ethers": "^2.2.3", "@typechain/ethers-v6": "^0.4.0", "@typechain/hardhat": "^8.0.0", "@types/chai": "^4.2.0", "@types/mocha": ">=9.1.0", "@types/node": ">=12.0.0", "chai": "^4.2.0", "dotenv": "^16.3.1", "ethers": "^6.6.1", "hardhat": "^2.16.0", "hardhat-deploy": "^0.11.34", "hardhat-deploy-ethers": "^0.3.0-beta.13", "hardhat-gas-reporter": "^1.0.8", "prettier": "^2.8.8", "prettier-plugin-solidity": "^1.1.3", "solhint": "^3.4.1", "solidity-coverage": "^0.8.0", "ts-node": ">=8.0.0", "typechain": "^8.1.0", "typescript": ">=4.5.0" } }Beta Was this translation helpful? Give feedback.
All reactions