diff --git a/README-CN.md b/README-CN.md index a3a859d..3dd7c91 100644 --- a/README-CN.md +++ b/README-CN.md @@ -1,12 +1,12 @@ -[English](./README.md) | 中文 +[English](./README.md) | [繁體中文](./README-TW.md) | 繁體中文

BSC-PHP

- Stable Version - Php Version - bsc-php License - Total Downloads + Stable Version + Php Version + bsc-php License + Total Downloads

## 概述 @@ -134,10 +134,4 @@ $bep20->receiptStatus($txHash); ## 🌟🌟 -[![Stargazers over time](https://starchart.cc/Fenguoz/bsc-php.svg)](https://starchart.cc/Fenguoz/bsc-php) - -## 合作 - -联系方式 -- WX:zgf243944672 -- QQ:243944672 +[![Stargazers over time](https://starchart.cc/jacky50737/bsc-php.svg)](https://starchart.cc/jacky50737/bsc-php) diff --git a/README-TW.md b/README-TW.md new file mode 100644 index 0000000..afa7537 --- /dev/null +++ b/README-TW.md @@ -0,0 +1,144 @@ +[English](./README.md) | 繁體中文 | [简体中文](./README-CN.md) + +

BSC-PHP

+ +

+ Stable Version + Php Version + bsc-php License + Total Downloads +

+ +## 概述 + +BSC-PHP 目前支援币安智能链的 BNB 和 BEP20 數位資產常用的生成地址,發起轉帳,查詢餘額,離線簽名等功能。 + +## 特點 + +1. 一套寫法兼容 TRON 網路中 TRX 貨幣和 TRC 系列所有通證 +1. 介面方法可靈活增減 + +## 支援方法 + +### 錢包 + +- \*產生私鑰創建帳戶 `newAccountByPrivateKey()` +- \*產生助憶詞創建帳戶 `newAccountByMnemonic()` +- 使用助憶詞還原帳戶 `revertAccountByMnemonic(string $mnemonic)` +- 根據私鑰得到地址 `revertAccountByPrivateKey(string $privateKey)` + +### Bnb & BEP20 + +- \*查詢餘額(BNB) `bnbBalance(string $address)` +- \*查詢餘額(BEP20) `balance(string $address)` +- \*交易轉帳(離線簽名) `transfer(string $from, string $to, float $amount)` +- 查詢最新區塊 `blockNumber()` +- 根據區塊鏈查詢資訊 `getBlockByNumber(int $blockID)` +- 根據交易雜湊返回交易的收據 `getTransactionReceipt(string $txHash)` +- \*根據交易雜湊返回關於所請求交易的資訊 `getTransactionByHash(string $txHash)` +- \*根據交易雜湊查詢交易狀態 `receiptStatus(string $txHash)` + +## 快速開始 + +### 安裝 + +PHP8 + +```php +composer require jacky50737/bsc-php + +``` + +or PHP7 + +```php +composer require jacky50737/bsc-php ~1.0 +``` + +### 介面 + +#### Wallet + +```php +$wallet = new \Binance\Wallet(); + +// 產生私鑰建立帳戶 +$wallet->newAccountByPrivateKey(); + +// 產生助憶詞建立帳戶 +$wallet->newAccountByMnemonic(); + +// 使用助憶詞還原帳戶 +$mnemonic = 'elite link code extra twist autumn flower purse excuse harsh kitchen whip'; +$wallet->revertAccountByMnemonic($mnemonic); + +// 根據私鑰得到地址 +$privateKey = '5e9340935f4c02628cec5d04cc281012537cafa8dae0e27ff56563b8dffab368'; +$wallet->revertAccountByPrivateKey($privateKey); +``` + +#### Bnb & BEP20 + +```php +## 方法 1 : BSC RPC Nodes +$uri = 'https://bsc-dataseed1.defibit.io/';// Mainnet +// $uri = 'https://data-seed-prebsc-1-s1.binance.org:8545/';// Testnet +$api = new \Binance\NodeApi($uri); + +## 方法 2 : Bscscan Api +$apiKey = 'QVG2GK41ASNSD21KJTXUAQ4JTRQ4XUQZCX'; +$api = new \Binance\BscscanApi($apiKey); + +$bnb = new \Binance\Bnb($api); + +$config = [ + 'contract_address' => '0x55d398326f99059fF775485246999027B3197955',// USDT BEP20 + 'decimals' => 18, +]; +$bep20 = new \Binance\BEP20($api, $config); + +// 查詢餘額 +$address = '0x1667ca2c72d8699f0c34c55ea00b60eef021be3a'; +$bnb->bnbBalance($address); +$bep20->balance($address); + +// 交易轉帳(離線簽名) +$from = '0x1667ca2c72d8699f0c34c55ea00b60eef021be3a'; +$to = '0x1667ca2c72d8699f0c34c55ea00b60eef021****'; +$amount = 0.1; +$bnb->transfer($from, $to, $amount); +$bep20->transfer($from, $to, $amount); + +// 查詢最新區塊 +$bnb->blockNumber(); +$bep20->blockNumber(); + +// 根據區塊鏈查詢資訊 +$blockID = 24631027; +$bnb->getBlockByNumber($blockID); +$bep20->getBlockByNumber($blockID); + +// 根據交易雜湊返回交易的收據 +$txHash = '0x4dd20d01af4c621d2fc293dff17a8fd8403ea3577988bfb245a18bfb6f50604b'; +$bnb->getTransactionReceipt($txHash); +$bep20->getTransactionReceipt($txHash); + +// 根據交易雜湊返回關於所請求交易的資訊 +$txHash = '0x4dd20d01af4c621d2fc293dff17a8fd8403ea3577988bfb245a18bfb6f50604b'; +$bnb->getTransactionByHash($txHash); +$bep20->getTransactionByHash($txHash); + +// 根據交易雜湊查詢交易狀態 +$txHash = '0x4dd20d01af4c621d2fc293dff17a8fd8403ea3577988bfb245a18bfb6f50604b'; +$bnb->receiptStatus($txHash); +$bep20->receiptStatus($txHash); +``` + +## 计划 + +- 支持 ERC721|ERC-1155 +- 智能合约 + +## 🌟🌟 + +[![Stargazers over time](https://starchart.cc/jacky50737/bsc-php.svg)](https://starchart.cc/jacky50737/bsc-php) \ No newline at end of file diff --git a/README.md b/README.md index e819e9b..fb28d2e 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -English | [中文](./README-CN.md) +English | [繁體中文](./README-TW.md) | [简体中文](./README-CN.md)

BSC-PHP

- Stable Version - Php Version - bsc-php License - Total Downloads + Stable Version + Php Version + bsc-php License + Total Downloads

## Introduction @@ -21,40 +21,44 @@ Support Binance's BNB and BEP20, which include functions such as address creatio ## Support Method ### wallet -- *Generate a private key to create an account `newAccountByPrivateKey()` -- *Generate mnemonic and create an account `newAccountByMnemonic()` + +- \*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 & BEP20 -- *Check balances(BNB) `bnbBalance(string $address)` -- *Check balances(BEP20) `balance(string $address)` + +- \*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)` - +- \*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 ### Install PHP8 -``` php -composer require fenguoz/bsc-php + +```php +composer require jacky50737/bsc-php ``` or PHP7 -``` php -composer require fenguoz/bsc-php ~1.0 + +```php +composer require jacky50737/bsc-php ~1.0 ``` ### Interface #### Wallet -``` php + +```php $wallet = new \Binance\Wallet(); // Generate a private key to create an account @@ -70,10 +74,11 @@ $wallet->revertAccountByMnemonic($mnemonic); // Get the address according to the private key $privateKey = '5e9340935f4c02628cec5d04cc281012537cafa8dae0e27ff56563b8dffab368'; $wallet->revertAccountByPrivateKey($privateKey); -``` +``` #### Bnb & BEP20 -``` php + +```php ## Method 1 : BSC RPC Nodes $uri = 'https://bsc-dataseed1.defibit.io/';// Mainnet // $uri = 'https://data-seed-prebsc-1-s1.binance.org:8545/';// Testnet @@ -135,10 +140,4 @@ $bep20->receiptStatus($txHash); ## 🌟🌟 -[![Stargazers over time](https://starchart.cc/Fenguoz/bsc-php.svg)](https://starchart.cc/Fenguoz/bsc-php) - -## Cooperate - -Contact -- WX:zgf243944672 -- QQ:243944672 +[![Stargazers over time](https://starchart.cc/jacky50737/bsc-php.svg)](https://starchart.cc/jacky50737/bsc-php) \ No newline at end of file diff --git a/composer.json b/composer.json index 87d67b6..47ad307 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "fenguoz/bsc-php", - "description": "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", + "name": "jacky50737/bsc-php", + "description": "支援 Binance 的 BNB 和 BEP20,包括地址創建、餘額查詢、交易轉帳、查詢最新區塊鏈、基於區塊鏈查詢資訊以及基於交易哈希查詢資訊等功能", "keywords": [ "php", "binance", @@ -8,12 +8,12 @@ "bep20" ], "type": "library", - "homepage": "https://github.com/Fenguoz/bsc-php", + "homepage": "https://github.com/jacky50737/bsc-php", "license": "MIT", "authors": [ { - "name": "Fenguoz", - "email": "243944672@qq.com" + "name": "JackyKuo", + "email": "jacky50737@gmail.com" } ], "require": { @@ -24,7 +24,7 @@ "sop/crypto-encoding": "^0.2.0", "sop/crypto-types": "^0.2.1", "phpseclib/phpseclib": "~2.0.11", - "guzzlehttp/guzzle": "^6.5", + "guzzlehttp/guzzle": "^7.5", "fenguoz/bip39-mnemonic-php": "~1.2.0", "fenguoz/minter-php-bip-44": "~1.0", "ext-gmp": "*",