PHPackages                             jeyroik/toncenter-php-sdk - 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. jeyroik/toncenter-php-sdk

ActiveLibrary[API Development](/categories/api)

jeyroik/toncenter-php-sdk
=========================

PHP SDK for toncenter.com

0.1.2(3y ago)1317PHP

Since May 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/jeyroik/toncenter-php-sdk)[ Packagist](https://packagist.org/packages/jeyroik/toncenter-php-sdk)[ RSS](/packages/jeyroik-toncenter-php-sdk/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (3)Dependencies (3)Versions (5)Used By (0)

toncenter-php-sdk
=================

[](#toncenter-php-sdk)

PHP SDK for toncenter

SDK allow to work with

[![tests](https://github.com/jeyroik/toncenter-php-sdk/workflows/PHP%20Composer/badge.svg?branch=master&event=push)](https://github.com/jeyroik/toncenter-php-sdk/workflows/PHP%20Composer/badge.svg?branch=master&event=push)[![codecov.io](https://camo.githubusercontent.com/028c395387cb67343a3f2dcbfd60f98f1d345dd8cf1c680fa7dc85bd693fa588/68747470733a2f2f636f6465636f762e696f2f67682f6a6579726f696b2f746f6e63656e7465722d7068702d73646b2f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/028c395387cb67343a3f2dcbfd60f98f1d345dd8cf1c680fa7dc85bd693fa588/68747470733a2f2f636f6465636f762e696f2f67682f6a6579726f696b2f746f6e63656e7465722d7068702d73646b2f636f7665726167652e7376673f6272616e63683d6d6173746572)[![PHPStan Enabled](https://camo.githubusercontent.com/441b5874ce4df0a2defc892979c96c46889b69cb32119d04f0b48626349f8bc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/phpstan/phpstan)[![](https://camo.githubusercontent.com/6011e48e885078f30c14daa301427ab5f00758216ea529fce8a37db68e9e962c/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f65633335373863356134346466353064333331372f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/jeyroik/toncenter-php-sdk/maintainability)[![Latest Stable Version](https://camo.githubusercontent.com/d1661623790bcc990ce5c455a7b8b6eec9f89b942e21c272dc42de088f0b35ae/68747470733a2f2f706f7365722e707567782e6f72672f6a6579726f696b2f746f6e63656e7465722d7068702d73646b2f76)](//packagist.org/packages/jeyroik/toncenter-php-sdk)[![Total Downloads](https://camo.githubusercontent.com/972798673e36c04472b41fe65c3164ad9e469187c40db89d76a6b9ae6bf08ffc/68747470733a2f2f706f7365722e707567782e6f72672f6a6579726f696b2f746f6e63656e7465722d7068702d73646b2f646f776e6c6f616473)](//packagist.org/packages/jeyroik/toncenter-php-sdk)[![Dependents](https://camo.githubusercontent.com/b03f632a01d7562c8b91867f491d6265dff5c7f6bd9eeffc3d3190a85481b98e/68747470733a2f2f706f7365722e707567782e6f72672f6a6579726f696b2f746f6e63656e7465722d7068702d73646b2f646570656e64656e7473)](//packagist.org/packages/jeyroik/toncenter-php-sdk)

usage
=====

[](#usage)

Set your token (there is rps limit 1 without token)

```
toncenter-php-sdk$ export TONC__TOKEN=
```

You can get your token in the [@tonapibot](https://t.me/tonapibot) to get access with higher limits.

Working with address
--------------------

[](#working-with-address)

```
$address = new Address([Address::FIELD__HASH => 'EQA6VbfxOrYGXvQw-VEpqeFKD1YDtX7JkQmENXOTV93Am0Yr']);
$address->loadInformation();

echo $address->getBalance(); // 15684203405
echo $address->getBalanceAsToncoins(); // 15,684203405

echo $address->getLastTransation()->getHash();
```

Working with transactions
-------------------------

[](#working-with-transactions)

```
$repo = new TransactionRepository();
$transaction = $repo->one(
    'EQA6VbfxOrYGXvQw-VEpqeFKD1YDtX7JkQmENXOTV93Am0yr', // by which address need to search transactions
    [
        ITransaction::FIELD__IN_MESSAGE => [
            ITransactionInMessage::FIELD__SOURCE => ['=', 'EQCtiv7PrMJImWiF2L5oJCgPnzp-VML2CAt5cbn1VsKAxLiE'],
            ITransactionInMessage::FIELD__VALUE => ['>', '9600000000'], //9.6 toncoins
            ITransactionInMessage::FIELD__MESSAGE_DATA => [
                ITransactionMessageData::FIELD__TEXT => ['like', 'ZWZ']
            ]
        ],
        ITransaction::FIELD__FEE => ['in', [1192940]]
    ]
);

echo $transaction->getId()->getHash() . PHP_EOL;

$transactions = $repo->all(
    'EQA6VbfxOrYGXvQw-VEpqeFKD1YDtX7JkQmENXOTV93Am0yr',
    [
        ITransaction::FIELD__IN_MESSAGE => [
            ITransactionInMessage::FIELD__SOURCE => ['=', 'EQCtiv7PrMJImWiF2L5oJCgPnzp-VML2CAt5cbn1VsKAxLiE'],
        ]
    ]
);

foreach($transactions as $transaction) {
    echo $transaction->getId()->getHash() . PHP_EOL;
}
```

### Enabled conditions

[](#enabled-conditions)

- `=` equal
- `!=` not equal
- `>` greater
- `>=` greater or equal
- `
