解决:Error: progressCb should be function

const _ethers = require("ethers");
const fs = require("fs-extra")
require("dotenv").config();

async function main() {
    const wallet = new _ethers.Wallet(process.env.Private_Key);
    const encryptedJsonKey = await wallet.encrypt(
        process.env.Private_Passwd,
        process.env.Private_Key
    );
    console.log(encryptedJsonKey);
}

main()
    .then(() => process.exit(0))
    .catch((error) => {
        console.error(error)
        process.exit(1)
    })

 运行时报错

Error: progressCb should be function
    at scryptInit (/home/devcontainers/hh-fcc/node_modules/@noble/hashes/scrypt.js:110:15)
    at scryptAsync (/home/devcontainers/hh-fcc/node_modules/@noble/hashes/scrypt.js:199:84)
    at _scryptAsync (/home/devcontainers/hh-fcc/node_modules/ethers/lib.commonjs/crypto/scrypt.js:8:43)
    at scrypt (/home/devcontainers/hh-fcc/node_modules/ethers/lib.commonjs/crypto/scrypt.js:55:42)
    at encryptKeystoreJson (/home/devcontainers/hh-fcc/node_modules/ethers/lib.commonjs/wallet/json-keystore.js:291:45)
    at Wallet.encrypt (/home/devcontainers/hh-fcc/node_modules/ethers/lib.commonjs/wallet/wallet.js:48:65)
    at main (/home/devcontainers/hh-fcc/hello.js:6:43)
    at Object.<anonymous> (/home/devcontainers/hh-fcc/hello.js:13:1)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
devcontainers@LAPTOP-9BK8E3RN:~/hh-fcc$ node hello.js

因为跟着chainlink视频课学习,版本有所不同

const encryptedJsonKey = await wallet.encrypt(
        process.env.Private_Passwd,
        process.env.Private_Key
    );

// 将其改为

const encryptedJsonKey = await wallet.encrypt(
        process.env.Private_Passwd,
    );

//即可

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值