olifanton/ton 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

olifanton/ton

最新稳定版本:1.5.5

Composer 安装命令:

composer require olifanton/ton

包简介

PHP library for The Open Network blockchain

README 文档

README

Tests Latest Stable Version Total Downloads Based on TON Donation

???? En chat | ???? Ру чат

Prerequisites

  • Minimum PHP 8.1;
  • ext-hash;
  • ext-sodium required as default cryptographic implementation;
  • any httplug-compatible HTTP client (php-http/client-common), see Documentation;
  • ext-bcmath not required, but strongly recommended for performance reasons.

Installation

composer require olifanton/ton

Examples

See examples directory.

Running examples

  1. Clone repository and install with development dependencies;
  2. Get own testnet API key for Toncenter from Telegram bot;
  3. Copy .env.dist to .env;
  4. Put API key and seed phrase variables to .env file;
  5. Run examples in console.

Documentation

Toncenter transport initialization

To use the SDK via Toncenter API, an HTTP client implementation is required. For the example, Guzzle will be used. If you are using another HTTP client supplied by your framework, refer to your framework's documentation and the httplug documentation for additional information.

  1. Install http components via Composer:
composer require guzzlehttp/guzzle http-interop/http-factory-guzzle php-http/guzzle7-adapter
  1. Setup Toncenter transport:
<?php

use Http\Client\Common\HttpMethodsClient;
use Http\Discovery\Psr18ClientDiscovery;
use Http\Discovery\Psr17FactoryDiscovery;
use Olifanton\Ton\Transports\Toncenter\ToncenterHttpV2Client;
use Olifanton\Ton\Transports\Toncenter\ClientOptions;
use Olifanton\Ton\Transports\Toncenter\ToncenterTransport;

$isMainnet = false;
$toncenterApiKey = "..."; // Request API key from https://t.me/tontestnetapibot or https://t.me/tonapibot

// HTTP client initialization
$httpClient = new HttpMethodsClient(
    Psr18ClientDiscovery::find(),
    Psr17FactoryDiscovery::findRequestFactory(),
    Psr17FactoryDiscovery::findStreamFactory(),
);

// Toncenter API client initialization
$toncenter = new ToncenterHttpV2Client(
    $httpClient,
    new ClientOptions(
        $isMainnet ? "https://toncenter.com/api/v2" : "https://testnet.toncenter.com/api/v2",
        $toncenterApiKey,
    ),
);

// Transport initialization
$toncenterTransport = new ToncenterTransport($toncenter);

// ...

// Now you can use Toncenter transport as access point to blockchain
$toncenterTransport->send($someBoc);

See examples/common.php for complex Toncenter example.

SDK components

Primitives

To read description of primitives (Address, Cell, Slice, Builder, Hashmap), refer to documentation in the olifanton/interop repository.

Performance tips

  • First of all, use the latest version of PHP, despite the fact that the minimum version is 8.1
  • Install the bcmath extension for PHP. This dramatically speeds up the work with large integers, which is necessary for interacting with TVM
  • Disable xdebug (or other debuggers) in your production. BoC serialisation/deserialisation speedup can be up to 5 times with XDEBUG_MODE=off

Contributing

Please make sure to read the Olifanton contribution guide before making a pull request.

Tests

composer run test:unit

License

MIT

统计信息

  • 总下载量: 41.82k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 91
  • 点击次数: 3
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 89
  • Watchers: 3
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固