从密钥库解密帐户会产生错误-无法读取未定义的属性'kdf'

时间:2018-11-21 17:20:02

标签: ethereum web3 web3js

我需要签署交易并使用密钥库发送给infura。调用解密函数时遇到以下错误。

if (json.crypto.kdf === 'scrypt') {
                ^
TypeError: Cannot read property 'kdf' of undefined
at Accounts.decrypt

我正在使用web3 v1.0.0-beta.36

这是我的代码,感谢您的帮助

const Web3 = require('web3');
const Tx = require('ethereumjs-tx')
const web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/v3/f..."));
var fs = require('fs');

const contractAddress = "0x...";
const sendingAccount = "0x...";
const password = "...";

var abiArray = JSON.parse(getAbi());
var contract = new web3.eth.Contract(abiArray,contractAddress);

const keystore = fs.readFileSync("UTC--...", 'utf8');
const decryptedAccount = 
web3.eth.accounts.decrypt(JSON.parse(keystore), password);

0 个答案:

没有答案