问题描述
我正在使用这种方法,但遇到了 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 版本
解决方法
首先你应该初始化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();
Where 方法 instance.f() - 你的智能合约方法示例 getName()
使用命令 node index.js