Tron智能合约Web API不适用于Docker快速入门网络

时间:2018-12-02 13:37:10

标签: node.js docker blockchain

我从tron tron官方页面上的Quickstart with TRON Docker开始建立本地测试网。

  • 启动tron docker快速启动成功
  • 使用Tron-Studio成功部署智能合约
  • 与Tron-Studio的合同成功使用

使用本教程中的代码,我可以获得合同,但是当我使用合同的功能时,承诺就会超时。

dockerstate.js:

const TronWeb = require('tronweb');
const HttpProvider = TronWeb.providers.HttpProvider;
const fullNode = new HttpProvider('http://127.0.0.1:8090');    //Your local TVM URL  
const solidityNode = new HttpProvider('http://127.0.0.1:8091');
const eventServer = 'http://127.0.0.1:8092';
const privateKey = 'da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0';

const tronWeb = new TronWeb(
    fullNode,
    solidityNode,
    eventServer,
    privateKey
);

async function changestate(){

  let contractAddress = 'TAA6PHMkrQs5bZp7cBYcfdWES9EMb5BZaK';   //Your address
  let contract = await tronWeb.contract().at(contractAddress);
  let resultPost = await contract.postMessage("TRON to the Future").send();
  let resultGet = await contract.getMessage().call();
  console.log('resultGet: ', resultGet);
}

changestate()

控制台输出:

$ node dockerstate.js
(node:9616) UnhandledPromiseRejectionWarning: Error: timeout of 30000ms exceeded
at createError (C:\Users\Daniel Specht\Documents\repos\docker-tron-quickstart\app\node_modules\axios\lib\core\createError.js:16:15)
at Timeout.handleRequestTimeout [as _onTimeout] (C:\Users\Daniel Specht\Documents\repos\docker-tron-quickstart\app\node_modules\axios\lib\adapters\http.js:216:16)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:9616) 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: 2)
(node:9616) [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.

在docker控制台上的输出:

FULL-NODE /wallet/getcontract
[Output {"bytecode":"608060405234801561001057600080fd5b5061036b806100206000396000f30060806040526004361061004b5763ffffffff7c010000000000000000000000000000000000000000000000000000
...  46ac33f208574882cc1a01b78855381ea6bf9978caab7bee73880029","consume_user_resource_percent":100,"name":"HelloWorld","origin_address":"410e93d739dbb8874f599a8bc29c7faefbf8eeab0f","a
bi":{"entrys":[{"outputs":[{"type":"string"}],"inputs":[{"name":"value","type":"string"}],"name":"postMessage","stateMutability":"Nonpayable","type":"Function"},{"outputs":[{"type":"string"}],"constant":true,"name":"getMessage","stateMutability":"View","type":"Function"},{"inputs":[{"name":"res","type":"uint256"}],"name":"test","type":"Event"}]},"contract_address":"41a6e9867de6f1674a2cadbfbbedd60e0ad63700c8"}
GET 200 2362 - 3.690 ms
POST   -  ms

似乎智能合约无法使用Web API正常工作。 有什么建议可以解决问题,以及如何解决或调试它?

0 个答案:

没有答案