承接 ddv88/tron-api-v2 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Stable Version Software License Total Downloads

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-10