TypeError: обратный вызов не является функцией, разверните контракт в тестовой сети ethereum - PullRequest
0 голосов
/ 01 марта 2020

Я написал ethereum сценарий развертывания контракта в javascript. это код:

//deploy script

//import tools
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
const fs = require('fs-extra');
const path = require('path');

//get the bytecode
const filePath = path.resolve(__dirname, '../compiled/Car.json');
const {interface, bytecode} = require(filePath);

//deploy
(async () => {
    //get the accounts address
    let accounts = await web3.eth.getAccounts();
    console.log('deploy contract account: ', accounts[0]);
    //create the instance of contract and deploy
    console.time('deploy contract time');
    let result = await new web3.eth.Contract(JSON.parse(interface))
                .deploy({data: bytecode, arguments:['AUDI']})
                .send({from:accounts[0], gas:'1000000'});
    console.timeEnd('deploy contract time');
    console.log('success: ', result.options.address);
})();

Я успешно скомпилировал контракт, но результат отладки показывает ошибку TypeError: обратный вызов не является функцией. Ошибка также направляет меня к этому файлу web3: node_modules / web3 / lib / web3 / property. js: 119: 13, подробности этого файла:

Property.prototype.buildAsyncGet = function () {
    var property = this;
    var get = function (callback) {
        property.requestManager.sendAsync({
            method: property.getter
        }, function (err, result) {
            callback(err, property.formatOutput(result));
        });
    };
    get.request = this.request.bind(this);
    return get;
};

Как я могу решить эту проблему? Спасибо!

...