PHPackages                             dsdcr/tron - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. dsdcr/tron

ActiveLibrary[API Development](/categories/api)

dsdcr/tron
==========

一个用于与Tron（Trx）区块链交互的PHP API，支持Laravel集成——基于iexbase/tron-api

v2.2.0(4mo ago)03MITPHPPHP &gt;=8.1

Since Jan 9Pushed 4mo agoCompare

[ Source](https://github.com/dsdcr/tron)[ Packagist](https://packagist.org/packages/dsdcr/tron)[ Docs](https://github.com/dsdcr/tron)[ RSS](/packages/dsdcr-tron/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (4)Used By (0)

TRON API 中文文档
=============

[](#tron-api-中文文档)

一个用于与TRON协议交互的PHP API

**基于 [iexbase/tron-api](https://github.com/iexbase/tron-api)**

[![最新稳定版本](https://camo.githubusercontent.com/a8d933ddf65b71a2c650db893f684ba7361722f3494832bfd08e7ff9faa6761a/68747470733a2f2f706f7365722e707567782e6f72672f64736463722f74726f6e2f76657273696f6e)](https://packagist.org/packages/dsdcr/tron)[![软件许可](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

安装
--

[](#安装)

```
composer require dsdcr/tron
```

要求
--

[](#要求)

支持的PHP版本：

- PHP 7.4+

配置
--

[](#配置)

本包支持新的、更直观的配置结构：

### 新配置结构

[](#新配置结构)

```
'network' => 'mainnet',        // 网络名称: mainnet, testnet, nile
'use_solidity' => false,       // 布尔值: true表示使用Solidity节点，false表示使用Full节点
'networks' => [
    'mainnet' => [
        'host' => 'https://api.trongrid.io',
        'explorer' => 'https://tronscan.org'
    ],
    'testnet' => [
        'host' => 'https://api.shasta.trongrid.io',
        'explorer' => 'https://shasta.tronscan.org'
    ],
    'nile' => [
        'host' => 'https://nile.trongrid.io',
        'explorer' => 'https://nile.tronscan.org'
    ]
]
```

使用
--

[](#使用)

### Laravel 使用方式

[](#laravel-使用方式)

#### 1. 在Laravel中安装

[](#1-在laravel中安装)

```
composer require dsdcr/tron
```

#### 2. 发布配置

[](#2-发布配置)

```
php artisan vendor:publish --provider="Dsdcr\Tron\TronServiceProvider"
```

#### 3. 环境配置

[](#3-环境配置)

在.env文件中添加：

```
TRON_NETWORK=mainnet
TRON_USE_SOLIDITY=false
TRON_API_KEY=您的TronGrid API密钥
TRON_PRIVATE_KEY=您的私钥
TRON_ADDRESS=您的地址
TRON_TIMEOUT=30000
```

#### 4. Laravel使用示例

[](#4-laravel使用示例)

**使用依赖注入：**

```
