我想连接到ganache,但收到一个错误,我不知道如何解决它。这是我的deploy.js代码,它是脚本node.js
const ethers = require("ethers")
// const solc = require("solc")
const fs = require("fs-extra")
async function main(){
// const provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:7545");
// const wallet = new ethers.Wallet(
// "1ef159aa4f7ee5116a0f22652da709ccd8d35827b12a03eb24f22dd023591987",
// provider
// )
let provider = new ethers.providers.JsonRpcProvider("http://0.0.0.0:7545")
let wallet = new ethers.Wallet("34db8b76c03356b47da8e1dcf427a35f9c013ce95a671ce23fe96d86fe2ba44b", provider)
const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8");
const binary = fs.readFileSync(
"./SimpleStorage_sol_SimpleStorage.bin",
"utf8"
)
const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
console.log("Deploying, please wait..");
const contract = await contractFactory.deploy(); // Stop here! …Run Code Online (Sandbox Code Playgroud) 我想测试我的合约FundMe.sol但它如何脱离FundMe.test.js会弹出一个错误
\n我的控制台
\nFundMe\n constructor\nDevelopment network detected! Deploying mocks...\n \xe2\x9c\x93 Should set the aggregator addresses correctly\n fund\n\n 1) Should fail if you don't send enough ETH\n\n\n 1 passing (977ms)\n 1 failing\n\n 1) FundMe\n fund\n Should fail if you don't send enough ETH:\n Error: Invalid Chai property: revertedWith\n at Object.proxyGetter [as get] (node_modules/chai/lib/chai/utils/proxify.js:78:17)\n at Context.<anonymous> (test/unit/FundMe.test.js:29:46)\nRun Code Online (Sandbox Code Playgroud)\n将测试写入文件FundMe.sol 的文件
\nFundMe.test.js
\nconst { deployments, ethers, getNamedAccounts } = require("hardhat")\nconst { assert, expect, revertedWith } …Run Code Online (Sandbox Code Playgroud)