0

我正在使用这种方法,但遇到 503 statusCode 并且也无法从我的应用程序中看到任何查询((

const tronWeb = new TronWeb({
    fullHost: 'https://api.trongrid.io/',
    headers: { "TRON-PRO-API-KEY": 'your api key' },
    privateKey: 'your private key'
})

更新。有趣地弄清楚如何解决。将我的 tronWeb 更新到 3.2.6 版本

4

1 回答 1

0

首先,您应该初始化 tronweb,例如 index.js

const TronWeb = require("tronweb");

const tronWeb = new TronWeb({
    fullHost: 'https://api.trongrid.io/',
    headers: { "TRON-PRO-API-KEY": 'Here is api key' },
    privateKey: 'here is pk'
});

然后你应该使用合约方法:

async function f() {
    let instance = await tronWeb.contract.at('here is contract address');
    let result = await instance.f().call();
    console.log(result);
}
f();

其中方法 instance.f() - 您的智能合约示例getName() 使用命令的方法node index.js

于 2021-03-28T11:19:18.470 回答