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位
3条答案
按热度按时间vzgqcmou1#
这是因为你把“0x”放在你的私钥前面。我也有过类似的错误。另外,如果你想的话,你可以使用炼金术。在你的配置中,其他一切看起来都很好。
ruarlubt2#
我也遇到了同样的错误,使用了一个env文件来存储常量。所以在我的例子中,错误是通过删除分号来解决的。
7vux5j2d3#
一些可能的修复方法:
String
、toString()
和字符串插值$0x{process.env.PRIVATE_KEY}
将私钥从.env文件转换或强制转换为字符串但解决这个问题的方法是导入:
在
hardhat.config.js
文件的顶部