web3.js Ошибка: не удалось декодировать uint8 из ABI: 0x - PullRequest
0 голосов
/ 04 мая 2018

env: mac node web3

Я пытаюсь использовать экземпляр смарт-контракта для развернутого контракта в node.js. Я получаю сообщение об ошибке ниже и не знаю, как ее решить.

Код: app.js

web3.eth.getBlock(0, function (error, result) {
    if (!error) {
        web3.eth.personal.newAccount("test", function (error, result) {
            if (!error) {
                console.log("new account:", result);
                //init contract
                var smartToken = new web3.eth.Contract(config.smartTokenAbi, config.smartTokenAddr, {
                    from: result,
                    gasPrice: '20000000000'
                });

                var privateSale = new web3.eth.Contract(config.privateSaleAbi, config.privateSaleAddr, {
                    from: result,
                    gasPrice: '20000000000'
                });


                privateSale.methods.state().call({}, function (error, result) {

                    console.log("------", error, result);
                });
            } else {
                console.log(error)
            }
        });


        console.log("Connect to " + config.host + ' success');
    } else {
        console.log("Can't connect to " + config.host);
        throw error;
    }
});

выход:

new account: 0x7051ebDe6A252858A3E5b06Dc7608677B18EC093
------ Error: Couldn't decode uint8 from ABI: 0x
    at SolidityTypeUInt.formatOutputUInt [as _outputFormatter] (/Volumes/Seagate/cqyh/ABC/node_modules/_web3-eth-abi@1.0.0-beta.34@web3-eth-abi/src/formatters.js:174:15)
    at SolidityTypeUInt.SolidityType.decode (/Volumes/Seagate/cqyh/ABC/node_modules/_web3-eth-abi@1.0.0-beta.34@web3-eth-abi/src/type.js:252:17)
    at /Volumes/Seagate/cqyh/ABC/node_modules/_web3-eth-abi@1.0.0-beta.34@web3-eth-abi/src/index.js:327:49
    at Array.forEach (<anonymous>)
    at ABICoder.decodeParameters (/Volumes/Seagate/cqyh/ABC/node_modules/_web3-eth-abi@1.0.0-beta.34@web3-eth-abi/src/index.js:326:13)
    at Contract._decodeMethodReturn (/Volumes/Seagate/cqyh/ABC/node_modules/_web3-eth-contract@1.0.0-beta.34@web3-eth-contract/src/index.js:459:22)
    at Method.outputFormatter (/Volumes/Seagate/cqyh/ABC/node_modules/_web3-eth-contract@1.0.0-beta.34@web3-eth-contract/src/index.js:812:46)
    at Method.formatOutput (/Volumes/Seagate/cqyh/ABC/node_modules/_web3-core-method@1.0.0-beta.34@web3-core-method/src/index.js:163:54)
    at sendTxCallback (/Volumes/Seagate/cqyh/ABC/node_modules/_web3-core-method@1.0.0-beta.34@web3-core-method/src/index.js:475:33)
    at /Volumes/Seagate/cqyh/ABC/node_modules/_web3-core-requestmanager@1.0.0-beta.34@web3-core-requestmanager/src/index.js:147:9
    at XMLHttpRequest.request.onreadystatechange (/Volumes/Seagate/cqyh/ABC/node_modules/_web3-providers-http@1.0.0-beta.34@web3-providers-http/src/index.js:77:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/Volumes/Seagate/cqyh/ABC/node_modules/_xhr2@0.1.4@xhr2/lib/xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (/Volumes/Seagate/cqyh/ABC/node_modules/_xhr2@0.1.4@xhr2/lib/xhr2.js:354:12)
    at XMLHttpRequest._onHttpResponseEnd (/Volumes/Seagate/cqyh/ABC/node_modules/_xhr2@0.1.4@xhr2/lib/xhr2.js:509:12)
    at IncomingMessage.<anonymous> (/Volumes/Seagate/cqyh/ABC/node_modules/_xhr2@0.1.4@xhr2/lib/xhr2.js:469:24)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9) undefined
...