无效帐户:网络#0:ropsten-私钥太短,预期32字节
require("@nomiclabs/hardhat-waffle");
// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
/**
* @type import('hardhat/config').HardhatUserConfig
*/
const INFURA_PROJECT_ID = "3dxxxx";
const ROPSTEN_PRIVATE_KEY = "e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
module.exports = {
networks: {
ropsten: {
url: `https://ropsten.infura.io/v3/${INFURA_PROJECT_ID}`,
accounts: [`0x${ROPSTEN_PRIVATE_KEY}`]
}
}
};
我根据网站上的示例部署了合同来ropsten,但错误是报告。私钥大于32位
require("@nomiclabs/hardhat-waffle");
// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
/**
* @type import('hardhat/config').HardhatUserConfig
*/
const INFURA_PROJECT_ID = "3dxxxx";
const ROPSTEN_PRIVATE_KEY = "e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
module.exports = {
networks: {
ropsten: {
url: `https://ropsten.infura.io/v3/${INFURA_PROJECT_ID}`,
accounts: [`0x${ROPSTEN_PRIVATE_KEY}`]
}
}
};
I deployed the contract to ropsten according to the example on the website, but an error was reported. The private key is greater than 32 bits
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
之所以发生,是因为您将“ 0x”放在私钥之前。我也有类似的错误。另外,如果需要,您可以使用炼金术。其他所有内容看起来都不错。
It's happening because you put "0x" before your private key. I had a similar error. Also, you can use Alchemy if you want. Everything else looks good in your config.
我遇到了相同的错误,并使用一个env文件存储了常数。
因此,就我而言,通过删除半隆来解决错误。
I had the same error and used an env file to store the constants.
So in my case, the error was solved by removing the semicolon.
一些可能的修复程序:
string
,toString()
和字符串Interpolation$ 0x {process.env.private_key}
,但解决了问题的原因是:
在
hardhat.config.js
文件的顶部Some possible fixes:
String
,toString()
, and string interpolation$0x{process.env.PRIVATE_KEY}
But what fixed the issue was importing:
at the top of the
hardhat.config.js
file