每当我运行“松露测试”时,我都会收到以下错误:
Error: Mnemonic invalid or undefined
at checkBIP39Mnemonic (C:\Users\Jackc\node_modules\@truffle\hdwallet-provider\src\index.ts:75:15)
at new HDWalletProvider (C:\Users\Jackc\node_modules\@truffle\hdwallet-provider\src\index.ts:105:23)
at Object.<anonymous> (C:\Users\Jackc\truffle-config.js:17:16)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Function.load (C:\Users\Jackc\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\config\dist\index.js:152:1)
at Function.detect (C:\Users\Jackc\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\config\dist\index.js:144:1)
at Object.module.exports [as run] (C:\Users\Jackc\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\test\run.js:27:1)
at runCommand (C:\Users\Jackc\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\command-utils.js:297:1)
Truffle v5.11.5 (core: 5.11.5)
Node v20.10.0
https://github.com/aave/flashloan-box
我的 .env 中有所有正确的信息,但我不确定是否需要将助记键添加到我的 .env 文件中,因为它在 Github 页面上没有提及?它在 .env 中使用的所有内容是:
INFURA_API_KEY = DEPLOYMENT_ACCOUNT_KEY =
我还在我的 truffle-config.js 文件中使用 require("dotenv").config() 。
这是 truffle-config.js
// const path = require("path");
const HDWalletProvider = require("@truffle/hdwallet-provider")
require("dotenv").config()
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration> to customize your Truffle configuration!
// contracts_build_directory: path.join(__dirname, "client/src/contracts"),
networks: {
development: {
host: "127.0.0.1",
port: 8545,
// gas: 20000000,
network_id: "*",
skipDryRun: true
},
ropsten: {
provider: new HDWalletProvider(process.env.DEPLOYMENT_ACCOUNT_KEY, "https://ropsten.infura.io/v3/" + process.env.INFURA_API_KEY),
network_id: 3,
gas: 5000000,
gasPrice: 5000000000, // 5 Gwei
skipDryRun: true
},
kovan: {
provider: new HDWalletProvider(process.env.DEPLOYMENT_ACCOUNT_KEY, "https://kovan.infura.io/v3/" + process.env.INFURA_API_KEY),
network_id: 42,
gas: 5000000,
gasPrice: 5000000000, // 5 Gwei
skipDryRun: true
},
mainnet: {
provider: new HDWalletProvider(process.env.DEPLOYMENT_ACCOUNT_KEY, "https://mainnet.infura.io/v3/" + process.env.INFURA_API_KEY),
network_id: 1,
gas: 5000000,
gasPrice: 5000000000 // 5 Gwei
}
},
compilers: {
solc: {
version: "^0.6.6",
},
},
}
开始认为这可能是我的 package.json 中的依赖问题,但我现在只是猜测。
任何帮助将不胜感激!!!
Truffle 已贬值,如果问题仍然存在,请切换到 Foundry 或 Hardhat(旧代码无论来自 github 还是课程都没有用)