Не удается подключиться к узлу Infura с помощью трюфеля и мнемоники моих счетов - PullRequest
0 голосов
/ 14 июня 2019

Я пытаюсь подключиться, чтобы развернуть контракт в сети Rinkeby, используя трюфельные HDWalletProvider и Infura для генерации провайдера, но контракт, похоже, не развертывается.

Я получаю эту ошибку:

(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();
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...