首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UnhandledPromiseRejectionWarning:错误: CustomProvider不支持订阅

UnhandledPromiseRejectionWarning:错误: CustomProvider不支持订阅
EN

Ethereum用户
提问于 2019-03-09 18:08:04
回答 1查看 994关注 0票数 1

试图将新创建的合同部署到rinkeby测试网络中,但遇到了以下错误。请查看下面的代码、错误信息和package.json详细信息。

代码语言:javascript
复制
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const {interface, bytecode} = require('./compile');
const provider = new HDWalletProvider(
'frog almost employ roast protect host citizen festival rural alone document misery',
'https://rinkeby.infura.io/v3/560e70f3ebfc4f628a53f4143b9460fd'
);
const web3= new Web3(provider);
const deploy = async () => {
    const accounts =  await web3.eth.getAccounts();
    try {
        const contractDeployment = await new web3.eth.Contract(JSON.parse(interface))
        .deploy({ data: '0x'+ bytecode, arguments: ['Hi there! I am inside Rinkeby'] })
        .send({from: accounts[0] });
console.log(contractDeployment.options.address);

    } catch (error) {
        console.log(error);
    }

};
deploy();
======================================================================
Error:
(node:58876) UnhandledPromiseRejectionWarning: Error: Subscriptions are not supported with the CustomProvider.
    at CustomProvider.subscribe (C:\BlockChain\node_modules\web3-providers\dist\web3-providers.cjs.js:1139:13)
    at NewHeadsSubscription.subscribe (C:\BlockChain\node_modules\web3-core-subscriptions\dist\web3-core-subscriptions.cjs.js:52:43)
    at NewHeadsWatcher.watch (C:\BlockChain\node_modules\web3-core-method\dist\web3-core-method.cjs.js:180:110)
    at C:\BlockChain\node_modules\web3-core-method\dist\web3-core-method.cjs.js:50:31
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:58876) 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:58876) [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.
Error: Invalid JSON RPC response: ""
=======================================================================
Package.Json
  "dependencies": {
    "ganache-cli": "^6.2.3",
    "mocha": "^5.2.0",
    "solc": "^0.4.25",
    "truffle-hdwallet-provider": "0.0.6",
    "web3": "^1.0.0-beta.37"
EN

回答 1

Ethereum用户

发布于 2019-03-09 19:03:49

这听起来像beta.48:https://github.com/ethereum/web3.js/issues/2462中已知的问题

也许尝试将web3.js降级到beta.37,这似乎是目前最稳定的选择。

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

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

复制
相关文章

相似问题

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