{"id":23272832,"url":"https://github.com/fenguoz/bsc-php","last_synced_at":"2025-10-29T13:31:24.171Z","repository":{"id":65185689,"uuid":"489585475","full_name":"Fenguoz/bsc-php","owner":"Fenguoz","description":"Support Binance Smart Chain BNB/BEP20 digital assets, including address creation, balance query, transaction transfer, query the latest blockchain, query information based on blockchain, query information based on transaction hash, etc.","archived":false,"fork":false,"pushed_at":"2024-08-16T08:17:47.000Z","size":22,"stargazers_count":39,"open_issues_count":16,"forks_count":42,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-07T10:12:49.695Z","etag":null,"topics":["bep20","binance","binance-chain","bnb","bsc","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fenguoz.png","metadata":{"files":{"readme":"README-CN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-07T06:08:07.000Z","updated_at":"2025-01-24T14:43:27.000Z","dependencies_parsed_at":"2024-03-25T10:31:50.828Z","dependency_job_id":"a53e4059-f570-4b47-b248-685cf8ccd682","html_url":"https://github.com/Fenguoz/bsc-php","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"916a96185790d50dc0e838ae19543f4e0fce1cd4"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fenguoz%2Fbsc-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fenguoz%2Fbsc-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fenguoz%2Fbsc-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fenguoz%2Fbsc-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fenguoz","download_url":"https://codeload.github.com/Fenguoz/bsc-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238829609,"owners_count":19537722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bep20","binance","binance-chain","bnb","bsc","php"],"created_at":"2024-12-19T19:19:43.760Z","updated_at":"2025-10-29T13:31:24.165Z","avatar_url":"https://github.com/Fenguoz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[English](./README.md) | 中文\n\n\u003ch1 align=\"center\"\u003eBSC-PHP\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/Fenguoz/bsc-php/releases\"\u003e\u003cimg src=\"https://poser.pugx.org/Fenguoz/bsc-php/v/stable\" alt=\"Stable Version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.php.net\"\u003e\u003cimg src=\"https://img.shields.io/badge/php-%3E=7.2-brightgreen.svg?maxAge=2592000\" alt=\"Php Version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/Fenguoz/bsc-php/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/fenguoz/bsc-php.svg?maxAge=2592000\" alt=\"bsc-php License\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://packagist.org/packages/Fenguoz/bsc-php\"\u003e\u003cimg src=\"https://poser.pugx.org/Fenguoz/bsc-php/downloads\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## 概述\n\nBSC-PHP 目前支持币安智能链的 BNB 和 BEP20 数字资产常用的生成地址，发起转账，查询余额，离线签名等功能。\n\n## 特点\n\n1. 一套写法兼容 BSC 网络中 BNB 货币和 BEP20 系列所有通证\n1. 接口方法可可灵活增减\n\n## 支持方法\n\n### wallet\n- *生成私钥创建账户 `newAccountByPrivateKey()`\n- *生成助记词创建账户 `newAccountByMnemonic()`\n- 使用助记词还原账户 `revertAccountByMnemonic(string $mnemonic)`\n- 根据私钥得到地址 `revertAccountByPrivateKey(string $privateKey)`\n\n### Bnb \u0026 BEP20\n- *查询余额(BNB) `bnbBalance(string $address)`\n- *查询余额(BEP20) `balance(string $address)`\n- *交易转账(离线签名) `transfer(string $from, string $to, float $amount)`\n- 查询最新区块 `blockNumber()`\n- 根据区块链查询信息 `getBlockByNumber(int $blockID)`\n- 根据交易哈希返回交易的收据 `getTransactionReceipt(string $txHash)`\n- *根据交易哈希返回关于所请求交易的信息 `getTransactionByHash(string $txHash)`\n- *根据交易哈希查询交易状态 `receiptStatus(string $txHash)`\n\n## 快速开始\n\n### 安装\n\nPHP8\n``` php\ncomposer require fenguoz/bsc-php\n```\n\nor PHP7\n``` php\ncomposer require fenguoz/bsc-php ~1.0\n```\n\n### 接口调用\n\n#### Wallet\n``` php\n$wallet = new \\Binance\\Wallet();\n\n// 生成私钥创建账户\n$wallet-\u003enewAccountByPrivateKey();\n\n// 生成助记词创建账户\n$wallet-\u003enewAccountByMnemonic();\n\n// 使用助记词还原账户\n$mnemonic = 'elite link code extra twist autumn flower purse excuse harsh kitchen whip';\n$wallet-\u003erevertAccountByMnemonic($mnemonic);\n\n// 根据私钥得到地址\n$privateKey = '5e9340935f4c02****f56563b8dffab368';\n$wallet-\u003erevertAccountByPrivateKey($privateKey);\n``` \n\n#### Bnb \u0026 BEP20\n``` php\n## 方法 1 : BSC RPC Nodes\n$uri = 'https://bsc-dataseed1.binance.org';// Mainnet\n$api = new \\Binance\\NodeApi($uri);\n// $uri = 'https://data-seed-prebsc-1-s1.binance.org:8545/';// Testnet\n// $api = new \\Binance\\NodeApi($uri, null, null, 'testnet');\n\n## 方法 2 : Bscscan Api\n$apiKey = 'QVG2GK41A****RQ4XUQZCX';\n$api = new \\Binance\\BscscanApi($apiKey);\n\n$bnb = new \\Binance\\Bnb($api);\n\n$config = [\n    'contract_address' =\u003e '0x55d398326f99059fF775485246999027B3197955',// USDT BEP20\n    'decimals' =\u003e 18,\n];\n$bep20 = new \\Binance\\BEP20($api, $config);\n\n// 查询余额\n$address = '0x1667ca2c7****021be3a';\n$bnb-\u003ebnbBalance($address);\n$bep20-\u003ebalance($address);\n\n// 交易转账(离线签名)\n$from = '0x1667ca2c7****021be3a';\n$to = '0xd8699f0****b60eef021';\n$amount = 0.1;\n$bnb-\u003etransfer($from, $to, $amount);\n$bep20-\u003etransfer($from, $to, $amount);\n\n// 查询最新区块\n$bnb-\u003eblockNumber();\n$bep20-\u003eblockNumber();\n\n// 根据区块链查询信息\n$blockID = 24631027;\n$bnb-\u003egetBlockByNumber($blockID);\n$bep20-\u003egetBlockByNumber($blockID);\n\n// 根据交易哈希返回交易的收据\n$txHash = '0x4dd20d01af4c621d2f****77988bfb245a18bfb6f50604b';\n$bnb-\u003egetTransactionReceipt($txHash);\n$bep20-\u003egetTransactionReceipt($txHash);\n\n// 根据交易哈希返回关于所请求交易的信息\n$txHash = '0x4dd20d01af4c621d2f****77988bfb245a18bfb6f50604b';\n$bnb-\u003egetTransactionByHash($txHash);\n$bep20-\u003egetTransactionByHash($txHash);\n\n// 根据交易哈希查询交易状态\n$txHash = '0x4dd20d01af4c621d2f****77988bfb245a18bfb6f50604b';\n$bnb-\u003ereceiptStatus($txHash);\n$bep20-\u003ereceiptStatus($txHash);\n```\n\n## 计划\n\n- 支持 ERC721|ERC-1155\n- 智能合约\n\n## 🌟🌟\n\n[![Stargazers over time](https://starchart.cc/Fenguoz/bsc-php.svg)](https://starchart.cc/Fenguoz/bsc-php)\n\n## 合作\n\n联系方式\n- WX：zgf243944672\n- QQ：243944672\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffenguoz%2Fbsc-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffenguoz%2Fbsc-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffenguoz%2Fbsc-php/lists"}