PHPackages                             fenguoz/bsc-php - 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. fenguoz/bsc-php

ActiveLibrary[API Development](/categories/api)

fenguoz/bsc-php
===============

Support Binance's BNB and BEP20, which include functions such as address creation, balance query, transaction transfer, query the latest blockchain, query information based on the blockchain, and query information based on the transaction hash

2.3.0(1y ago)4531.0k↓14.1%47[14 issues](https://github.com/Fenguoz/bsc-php/issues)MITPHPPHP &gt;=8.0

Since Jan 7Pushed 1y ago3 watchersCompare

[ Source](https://github.com/Fenguoz/bsc-php)[ Packagist](https://packagist.org/packages/fenguoz/bsc-php)[ Docs](https://github.com/Fenguoz/bsc-php)[ RSS](/packages/fenguoz-bsc-php/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (10)Versions (15)Used By (0)

English | [中文](./README-CN.md)

BSC-PHP
=======

[](#bsc-php)

 [![Stable Version](https://camo.githubusercontent.com/cc4ef677c5cda2b15e47b640176e0c6f512afc3558debf43960eb619afbada37/68747470733a2f2f706f7365722e707567782e6f72672f46656e67756f7a2f6273632d7068702f762f737461626c65)](https://github.com/Fenguoz/bsc-php/releases) [![Php Version](https://camo.githubusercontent.com/b89e839d5d52995202e3f77713d3272afdfffacf314e3562e9a20a1d070b6ff7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2533453d372e322d627269676874677265656e2e7376673f6d61784167653d32353932303030)](https://www.php.net) [![bsc-php License](https://camo.githubusercontent.com/754d2c2a0b5ec014701647c1caa10b0a5b0700a731858ba891beb11c35ad4fce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f66656e67756f7a2f6273632d7068702e7376673f6d61784167653d32353932303030)](https://github.com/Fenguoz/bsc-php/blob/master/LICENSE) [![Total Downloads](https://camo.githubusercontent.com/738a9458534cb83e38c58474571b47bf8fae22d6fdde5e6b2b909857269227a2/68747470733a2f2f706f7365722e707567782e6f72672f46656e67756f7a2f6273632d7068702f646f776e6c6f616473)](https://packagist.org/packages/Fenguoz/bsc-php)

Introduction
------------

[](#introduction)

Support Binance's BNB and BEP20, which include functions such as address creation, balance query, transaction transfer, query the latest blockchain, query information based on the blockchain, and query information based on the transaction hash.

Advantage
---------

[](#advantage)

1. One set of scripts is compatible with all BNB currencies and BEP20 certifications in the BSC network
2. Interface methods can be added or subtracted flexibly

Support Method
--------------

[](#support-method)

### wallet

[](#wallet)

- \*Generate a private key to create an account `newAccountByPrivateKey()`
- \*Generate mnemonic and create an account `newAccountByMnemonic()`
- Restore account using mnemonic `revertAccountByMnemonic(string $mnemonic)`
- Get the address according to the private key `revertAccountByPrivateKey(string $privateKey)`

### Bnb &amp; BEP20

[](#bnb--bep20)

- \*Check balances(BNB) `bnbBalance(string $address)`
- \*Check balances(BEP20) `balance(string $address)`
- Transaction transfer (offline signature) `transfer(string $from, string $to, float $amount)`
- Query the latest block `blockNumber()`
- Query information according to the blockchain `getBlockByNumber(int $blockID)`
- Returns the receipt of a transaction by transaction hash `getTransactionReceipt(string $txHash)`
- \*Returns the information about a transaction requested by transaction hash `getTransactionByHash(string $txHash)`
- \*Query transaction status based on transaction hash `receiptStatus(string $txHash)`

Quick Start
-----------

[](#quick-start)

### Install

[](#install)

PHP8

```
composer require fenguoz/bsc-php
```

or PHP7

```
composer require fenguoz/bsc-php ~1.0
```

### Interface

[](#interface)

#### Wallet

[](#wallet-1)

[example.php](./example.php#L4)

```
$wallet = new \Binance\Wallet();

// Generate a private key to create an account
$wallet->newAccountByPrivateKey();

// Generate mnemonic and create an account
$wallet->newAccountByMnemonic();

// Restore account using mnemonic
$mnemonic = 'elite link code extra....';
$wallet->revertAccountByMnemonic($mnemonic);

// Get the address according to the private key
$privateKey = '5e9340935f4c02****f56563b8dffab368';
$wallet->revertAccountByPrivateKey($privateKey);
```

#### Bnb &amp; BEP20

[](#bnb--bep20-1)

[example.php](./example.php#L23)

```
## Method 1 : BSC RPC Nodes
$uri = 'https://bsc-dataseed1.binance.org';// Mainnet
$api = new \Binance\NodeApi($uri);
// $uri = 'https://data-seed-prebsc-1-s1.binance.org:8545/';// Testnet
// $api = new \Binance\NodeApi($uri, null, null, 'testnet');

## Method 2 : Bscscan Api
$apiKey = 'QVG2GK41A****RQ4XUQZCX';
$api = new \Binance\BscscanApi($apiKey);

$bnb = new \Binance\Bnb($api);

$config = [
    'contract_address' => '0x55d398326f99059fF775485246999027B3197955',// USDT BEP20
    'decimals' => 18,
];
$bep20 = new \Binance\BEP20($api, $config);

// *Check balances
$address = '0x1667ca2c7****021be3a';
$bnb->bnbBalance($address);
$bep20->balance($address);

// Transaction transfer (offline signature)
$from = '0x1667ca2c7****021be3a';
$to = '0xd8699f0****b60eef021';
$amount = 0.1;
$bnb->transfer($from, $to, $amount);
$bep20->transfer($from, $to, $amount);

// Query the latest block
$bnb->blockNumber();
$bep20->blockNumber();

// Query information according to the blockchain
$blockID = 24631027;
$bnb->getBlockByNumber($blockID);
$bep20->getBlockByNumber($blockID);

// Returns the receipt of a transaction by transaction hash
$txHash = '0x4dd20d01af4c621d2f****77988bfb245a18bfb6f50604b';
$bnb->getTransactionReceipt($txHash);
$bep20->getTransactionReceipt($txHash);

// Returns the information about a transaction requested by transaction hash
$txHash = '0x4dd20d01af4c621d2f****77988bfb245a18bfb6f50604b';
$bnb->getTransactionByHash($txHash);
$bep20->getTransactionByHash($txHash);

// Query transaction status based on transaction hash
$txHash = '0x4dd20d01af4c621d2f****77988bfb245a18bfb6f50604b';
$bnb->receiptStatus($txHash);
$bep20->receiptStatus($txHash);
```

Plan
----

[](#plan)

- Support ERC721|ERC-1155
- Smart Contract

🌟🌟
--

[](#)

[![Stargazers over time](https://camo.githubusercontent.com/262812db115380c00e910f8e2a85423893f6f3f660b01ff326d24be155754ee2/68747470733a2f2f7374617263686172742e63632f46656e67756f7a2f6273632d7068702e737667)](https://starchart.cc/Fenguoz/bsc-php)

Cooperate
---------

[](#cooperate)

Contact

- WX：zgf243944672
- QQ：243944672

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% 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

Every ~64 days

Total

14

Last Release

442d ago

Major Versions

0.1.0 → 1.0.02023-02-09

1.0.0 → 2.0.02023-02-09

PHP version history (2 changes)1.0.0PHP &gt;=7.2

2.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b1a4edd9ce705e6ea4c191715ec70228e641722feacc44a8fd634088e4287c1f?d=identicon)[243944672](/maintainers/243944672)

---

Top Contributors

[![Fenguoz](https://avatars.githubusercontent.com/u/28383092?v=4)](https://github.com/Fenguoz "Fenguoz (22 commits)")[![saeedix](https://avatars.githubusercontent.com/u/17952050?v=4)](https://github.com/saeedix "saeedix (1 commits)")[![SuprimeKebab](https://avatars.githubusercontent.com/u/145693088?v=4)](https://github.com/SuprimeKebab "SuprimeKebab (1 commits)")

---

Tags

bep20binancebinance-chainbnbbscphpphpbinanceBEP20bnb

### Embed Badge

![Health badge](/badges/fenguoz-bsc-php/health.svg)

```
[![Health](https://phpackages.com/badges/fenguoz-bsc-php/health.svg)](https://phpackages.com/packages/fenguoz-bsc-php)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M47](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[soneso/stellar-php-sdk

Stellar PHP SDK for the Stellar Network

4154.3k4](/packages/soneso-stellar-php-sdk)[egroupware/egroupware

EGroupware extends a classic groupware with an integrated CRM-system, a secure file-server and Collabora Online Office.

2931.7k](/packages/egroupware-egroupware)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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