PHPackages                             arnezt/binancephpsdk - 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. arnezt/binancephpsdk

ActiveLibrary

arnezt/binancephpsdk
====================

This repository contains the PHP-SDK to interact with Binance DEX. It's supported by mostly pure PHP code.

v1.0(5y ago)3315[1 issues](https://github.com/arnezt/binancephpsdk/issues)MITPHPPHP &gt;=7.0

Since Dec 27Pushed 5y ago1 watchersCompare

[ Source](https://github.com/arnezt/binancephpsdk)[ Packagist](https://packagist.org/packages/arnezt/binancephpsdk)[ Docs](http://arnezt.github.io/binancephpsdk)[ RSS](/packages/arnezt-binancephpsdk/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

binance-php-sdk
===============

[](#binance-php-sdk)

(Fork from `hammadtq/binance-php-sdk` Porting to composer) This repository contains the PHP-SDK to interact with [Binance DEX](http://binance.org). It's supported by mostly pure PHP code. The documentation for Binance DEX supported methods is [here](http://docs.binance.org).

Installation
------------

[](#installation)

At the moment, you will have to clone the repo and include it in your project. In the future, it will be available through composer. (Added: Available via composer):

`composer require arnezt/binancephpsdk`

The SDK relies on [secp256k1-php](https://github.com/Bit-Wasp/secp256k1-php). There is currently no easy method to install secp256k1-php extension, you will need compile it yourself.

### To Install:

[](#to-install)

(First check (Ubuntu/Debian) if `phpize` has available: `sudo apt install php7.x-dev`)

libsecp256k1:

```
git clone git@github.com:bitcoin-core/secp256k1 && \
cd secp256k1 &&                                    \
./autogen.sh &&                                    \
./configure --enable-experimental --enable-module-{ecdh,recovery} && \
 make &&                                           \
 sudo make install &&                              \
 cd ../

```

secp256k1-php:

```
git clone git@github.com:Bit-Wasp/secp256k1-php && \
cd secp256k1-php/secp256k1 &&                      \
phpize &&                                          \
./configure --with-secp256k1 &&                    \
make && sudo make install &&                       \
cd ../../

```

(Optional) - Enable extension by default!
-----------------------------------------

[](#optional---enable-extension-by-default)

If you're a heavy user, you can add this line to your php.ini files for php-cli, apache2, or php-fpm.

> extension=secp256k1.so

(Added: Check php conf (php7.x-fpm if using fpm) change x with your php version):

`$ sudo nano /etc/php/7.x/mods-available/secp256k1.ini`

add: `extension=secp256k1.so`

`$ sudo ln -s /etc/php/7.x/mods-available/secp256k1.ini /etc/php/7.x/fpm/conf.d/20-secp256k1.ini` (for fpm)

`$ sudo ln -s /etc/php/7.x/mods-available/secp256k1.ini /etc/php/7.x/cli/conf.d/20-secp256k1.ini` (for cli)

The repository was made on Mac OSX using PHP version `7.15.3`. You will also need a version above 7. It is advised to go with native PHP installation instead of going with XAMPP or WAMPP so to take advantage of secp256k1-php natively. Also, you may need `gmp` extension.

To handle big numbers, the SDK makes use of [brick/math](https://github.com/brick/math) precision library. Please consider using this or another `bcmath` or `gmp` based solutions while dealing with blockchain based numbers.

Examples
--------

[](#examples)

**Note:** Please see [Issue Tracker](https://github.com/hammadtq/binance-php-sdk/blob/master/issuetracker.md) to understand what methods are currently available in the sdk.

You can find full [example](https://github.com/hammadtq/binance-php-sdk/tree/master/src/Examples) scripts in the src folder.

Few examples to interact with SDK are below:

### Keystore reload and getting private key

[](#keystore-reload-and-getting-private-key)

```
$keystoreData = '{paste keystore data here or read from a file}';
$keystore= new Keystore();
$keystore->RestoreKeyStore($keystoreData, "{keystore-password}", "tbnb");
$privateKey = $keystore->getPrivateKey();
```

Similary, if you want to see the hex of private key, simply use this method:

`$keystore->getPrivateKey()->getHex();`

### A typical transfer request will look something like this:

[](#a-typical-transfer-request-will-look-something-like-this)

```
$bncClient = new BncClient('https://data-seed-pre-2-s1.binance.org');
$bncClient->initChain();
$bncClient->chooseNetwork("testnet"); // or this can be "mainnet"
$bncClient->setPrivateKey($privateKey);
$response = $bncClient->transfer("tbnb1yqyppmev2m4z96r4svwtjq8eqp653pt6elq33r", "tbnb1hgm0p7khfk85zpz5v0j8wnej3a90w709zzlffd", 0.001, "BNB", "3423423");
```

### Placing an order

[](#placing-an-order)

```
$response = $bncClient->NewOrder("BNB_USDT.B-B7C", 1, 0.001, 1, 0, 1); //Symbol, side, price, quantity, sequence, timeinfore
```

Amino Encoding
--------------

[](#amino-encoding)

The SDK uses Google [proto3](https://developers.google.com/protocol-buffers/docs/proto3) generator to support Binance's aminor encoding/decoding. If you ever include new messages to the [proto file](https://github.com/hammadtq/binance-php-sdk/tree/master/proto), run following command to run the generator from the root:

`protoc --proto_path=proto --php_out=./gen proto/dex.proto`

Key Generation
--------------

[](#key-generation)

Key generation is supported via secp256k1-php library as well.

Once you generate an address, make sure to send an amount on it as the Binance DEX will not make an account unless a transaction is received on an address.

```
$keystore = new Keystore();
$privateKey = Byte::init($keystore->createPrivateKey());
$publicKey = $keystore->createPublicKey($privateKey);
$address = $keystore->publicKeyToAddress($publicKey, 'tbnb');
```

Supported Methods
-----------------

[](#supported-methods)

- Keypair generation
- Keypair generation with mnemonic
- Keystore reload
- Fetching JSON-RPC functions
- Fetch API functions
- Transactions: Transfer, NewOrder, CancelOrder, TokenFreeze, TokenUnFreeze, Issue, Mint, Burn, HTLT, DepositHTLT, ClaimHTLT, RefundHTLT, TimeLock, TimeRelock, TimeUnlock

Many thanks to  has provided the original source code.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1959d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/72c972a673212f5cb21d8f0ee7d327e776bc75a5ed218ae773e67edda1db9e01?d=identicon)[arnezt](/maintainers/arnezt)

---

Top Contributors

[![arnezt](https://avatars.githubusercontent.com/u/3238574?v=4)](https://github.com/arnezt "arnezt (9 commits)")

---

Tags

Binance Chain PHP SDK

### Embed Badge

![Health badge](/badges/arnezt-binancephpsdk/health.svg)

```
[![Health](https://phpackages.com/badges/arnezt-binancephpsdk/health.svg)](https://phpackages.com/packages/arnezt-binancephpsdk)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M16.9k](/packages/laravel-framework)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[google/cloud

Google Cloud Client Library

1.2k16.2M53](/packages/google-cloud)[google/gax

Google API Core for PHP

263103.1M452](/packages/google-gax)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[torchlight/torchlight-laravel

A Laravel Client for Torchlight, the syntax highlighting API.

120452.8k11](/packages/torchlight-torchlight-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
