ddv88/tron-api-v2
Composer 安装命令:
composer require ddv88/tron-api-v2
包简介
A PHP API for interacting with Tron (Trx) v2
README 文档
README
Реинкарнация заброшенного репозитория https://github.com/iexbase/tron-api
Install
> composer require ddv88/tron-api-v2 --ignore-platform-reqs
Пример создания контракта USDT
try {
$tron = new \IEXBase\TronAPI\Tron(
new HttpProvider("https://api.trongrid.io"),
new HttpProvider("https://api.trongrid.io"),
new HttpProvider("https://api.trongrid.io")
);
$tron->setPrivateKey($private_key_from);
$tron->setAddress($address_from);
$amount = 1.0; //USDT
$transaction = $tron->getTransactionBuilder()->triggerSmartContract(
$abi,
$tron->toHex($this->contract), // Адрес контракта
"transfer",
[
$tron->toHex($address_to), // Получатель
$amount * 1000000, // Сумма в SUN
],
1 * 1000000, // Лимит комиссии
$tron->toHex($address_from), // Отправитель
0
);
$signedTransaction = $tron->signTransaction($transaction);
$response = $tron->sendRawTransaction($signedTransaction);
return $response;
} catch (\IEXBase\TronAPI\Exception\TronException $e) {
exit($e->getMessage());
}
Testing
$ vendor/bin/phpunit
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-10