I am trying to deploy a test contract on Binance Smart Chain network. I am using metamask, and truffle to create and test the contract. My folder structure looks like this
const HDWalletProvider = require('truffle-hdwallet-provider-privkey');
const privateKeys = process.env.PRIVATE_KEYS || ""
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*"
},
binancetestnet: {
provider: function() {
return new HDWalletProvider(
privateKeys.split(','), // Array of account private keys
`https://data-seed-prebsc-1-s1.binance.org:8545/${process.env.INFURA_API_KEY}`// Url to an Ethereum Node
)
},
gas: 5000000,
gasPrice: 25000000000,
network_id: 97
}
},
// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},
// Configure your compilers
compilers: {
solc: {
version: "0.7.3", // Fetch exact version from solc-bin (default: truffle's version)
// docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
// settings: { // See the solidity docs for advice about optimization and evmVersion
// optimizer: {
// enabled: false,
// runs: 200
// },
// evmVersion: "byzantium"
// }
}
}
};
Macbook-Air Oracle % truffle migrate --reset --network binancetestnet
Error: Cannot find module 'truffle-hdwallet-provider-privkey'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/Users/macbbok/Desktop/Oracle/truffle-config.js:1:26)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at Object.require (internal/modules/cjs/helpers.js:25:18)
at Function.load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/config/dist/index.js:161:1)
at Function.detect (/usr/local/lib/node_modules/truffle/build/webpack:/packages/config/dist/index.js:150:1)
at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:199:1)
at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:136:1)
at Object.module.exports (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/cli.js:56:1)
at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/webpack:/webpack/bootstrap:19:1)
at /usr/local/lib/node_modules/truffle/build/webpack:/webpack/bootstrap:83:1
at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:89:10)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Truffle v5.1.54 (core: 5.1.54)
Node v10.16.3
I have attached all the code with errors I am facing. Can anyone help me with it? I have also Installed the HD Wallet provider as well. Truffle compile worked successfully.
truffle-hdwallet-provider-privkey
, verify you have the files in the correct directory – Nuliknpm install @truffle/hdwallet-provider
It installed Successfully. But I encountered a new problem while deploying – Bsc Talk