首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UnhandledPromiseRejectionWarning:错误:无效的json请求

UnhandledPromiseRejectionWarning:错误:无效的json请求
EN

Ethereum用户
提问于 2019-03-05 09:05:58
回答 1查看 503关注 0票数 -1

我的deploy.js脚本返回此错误:

代码语言:javascript
复制
"(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文件是:

代码语言:javascript
复制
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();

有什么帮助吗?

EN

回答 1

Ethereum用户

发布于 2019-03-05 19:26:46

我也面临着同样的问题。这是web3中已知的一个错误,它已经在1.0.0-beta.48版本中得到了修复。您可以在这里查看更多详细信息,github链接

解决方案:将web3 npm依赖项更新为1.0.0-beta.48

票数 1
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/67943

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档