Fenguoz/tron-php

请问正式环境如何设定API KEY

fbiceo opened this issue · 2 comments

大大,
我使用 https://api.trongrid.io 正式环境上线测试
我没有设定trongrid申请的API KEY,因为我不知道要去哪里设定
但是我尝试发送几笔交易都可以正常且在tronscan.io查询到交易内容
现在我很纳闷为什么我没有设定trongrid的API KEY却可以正常进行交易(TRX币)
请问是每天有免费额度可以发送吗? 还是我要如何设定API KEY? 麻烦有空指导,谢谢

我也有此疑问

Oh actually its pretty simple.. based on code from manual it would be something like this:

use GuzzleHttp\Client;

$uri = 'https://api.trongrid.io';// mainnet
// $uri = 'https://api.shasta.trongrid.io';// shasta testnet
$api = new \Tron\Api(new Client(['base_uri' => $uri,'headers'=>['TRON-PRO-API-KEY'=>'YOUR API KEY']));

$trxWallet = new \Tron\TRX($api);
$addressData = $trxWallet->generateAddress();
// $addressData->privateKey
// $addressData->address

$config = [
    'contract_address' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',// USDT TRC20
    'decimals' => 6,
];
$trc20Wallet = new \Tron\TRC20($api, $this->config);
$addressData = $trc20Wallet->generateAddress();