无法使用松露和我的帐户助记符连接到Infura节点

时间:2019-06-14 19:18:39

标签: javascript ethereum truffle

我正在尝试使用松露的HDWalletProvider和Infura连接生成Rinkeby网络的合同,以生成提供程序,但是该合同似乎没有部署。

我收到此错误:

(node:14124) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined
    at deploy (C:\Users\user\Desktop\ethereum\lottery\deploy.js:16:62)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:14124) 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:14124) [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.

这是我的部署脚本:

const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3')
const { interface, bytecode } = require('./compile');

const provider = new HDWalletProvider(
    ACCOUNT_MNEMONIC,
    'https://rinkeby.infura.io/v3/' + INFURA_RINKEBY_TOKEN
);

const web3 = new Web3(provider);

const deploy = async () => {

    const acccounts = await web3.eth.getAccounts();

    console.log('Attempting to deploy from account'. accounts[0]);

    const result = await new web3.eth.Contract(JSON.parse(interface))
        .deploy({ data: bytecode})
        .send({ from: acccounts[0], gas: '1000000' });

    console.log(interface);
    console.log('Contract deployed to', result.options.address);

};

deploy();

0 个答案:

没有答案