Эфириум Внимание! Ошибка при выполнении контракта [неверная инструкция] или ошибка в txn. Плохая инструкция - PullRequest
0 голосов
/ 25 июня 2019
  1. Машинописный код:

    var openKey = appConfig.issuerAddr;
    var privateKey = appConfig.privateKey;
    
    const account = this._web3.eth.accounts.privateKeyToAccount(privateKey);
    
    this._web3.eth.accounts.wallet.add(account);
    this._web3.eth.defaultAccount = account.address;
    
    var contract = new this._web3.eth.Contract(dapp);
    this._web3.eth.getBalance("0xaFd40Ed54483A7F9E53a634312Fe8F24f344895D").then(response => console.log(response)).catch(err => console.log(err));
    
    contract.deploy({
        data: this.web3.utils.asciiToHex('dapp'),
        arguments: []
    }).estimateGas(function() {
    }).then(function(estimatedGas:any) {
            console.log(estimatedGas);
            let web3 = new Web3(appConfig.testnetAddr);
            contract.deploy({
                data: web3.utils.asciiToHex('dapp'),
                arguments: []
            }).send({
                from: openKey,
                gas: 10*estimatedGas,
                gasPrice: "3000000000"
            }, function (error:any, transactionHash:any) {
                console.log(error, transactionHash);
            }).on('error', function (error:any) {
                console.log('error', error);
            }).on('false', function(error:any) {
                console.log(error);
            }).on('transactionHash', function (transactionHash:any) {
                console.log('transactionHash', transactionHash);
            }).on('receipt', function (receipt:any) {
                console.log('receipt', receipt.contractAddress);
            }).on('confirmation', function (confirmationNumber:any, receipt:any) {
                console.log('confirmation', confirmationNumber);
            }).catch(err => console.log(err, 'test'));
    
    }).catch(function(err) {
        console.log(err)
    });
    
  2. ABI:

    export const dapp = [ { «константа»: правда, «входы»: [], "имя": "получить", «выводы»: [ { "название": "", "тип": "адрес" } ], «к оплате»: ложно, «stateMutability»: «представление», "тип": "функция" }, { «входы»: [], «к оплате»: ложно, "stateMutability": "неоплачиваемый", "тип": "конструктор" } ];

  3. Контракт (sol):

    Прагма солидность ^ 0,5,1;

    контракт дапп { владелец адреса;

    constructor () public { владелец = msg.sender; }

    функция get () публичное представление возвращает (адрес) { вернуть владельца; } }

...