我的deploy.js脚本返回此错误:
"(node:6636) UnhandledPromiseRejectionWarning: Error: invalid json request
at D:\kickstart\node_modules\truffle-hdwallet-provider\dist\index.js:15:620862
at e.i.onreadystatechange (D:\kickstart\node_modules\truffle-hdwallet-provider\dist\index.js:15:775522)
at e.t.dispatchEvent (D:\kickstart\node_modules\truffle-hdwallet-provider\dist\index.js:1:152983)
at e._setReadyState (D:\kickstart\node_modules\truffle-hdwallet-provider\dist\index.js:15:780284)
at e._onHttpResponseEnd (D:\kickstart\node_modules\truffle-hdwallet-provider\dist\index.js:15:783369)
at IncomingMessage.<anonymous> (D:\kickstart\node_modules\truffle-hdwallet-provider\dist\index.js:15:782627)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1094:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:6636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code."我的deploy.js文件是:
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const compiledFactory = require('./build/CompaignFactory.json')
const provider = new HDWalletProvider(
'hat stick simple coyote xxxx only yyyy crush cook zzzzz coconut patient', //Type your memonic
'https://rinkeby.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxx'
);
const web3 = new Web3(provider);
const deploy = async () => {
const accounts = await web3.eth.getAccounts();
console.log('Attempting to deploy from account', accounts[0]);
const result = await new web3.eth.Contract(JSON.parse(compiledFactory.interface))
.deploy({ data: compiledFactory.bytecode })
.send({ gas: '1000000', from: accounts[0] });
};
deploy();有什么帮助吗?
发布于 2019-03-05 19:26:46
我也面临着同样的问题。这是web3中已知的一个错误,它已经在1.0.0-beta.48版本中得到了修复。您可以在这里查看更多详细信息,github链接
https://ethereum.stackexchange.com/questions/67943
复制相似问题