Kirin 3 주 전
부모
커밋
7fd33a11f6
100개의 변경된 파일8842개의 추가작업 그리고 36개의 파일을 삭제
  1. 20 0
      app/common.php
  2. 5 1
      composer.json
  3. 960 35
      composer.lock
  4. 32 0
      config/blockchain.php
  5. 1 0
      public/.well-known/acme-challenge/ozw54pdcX8Uth53daD4a2gOO0H7aJu65odMUbI6Pjgw
  6. 66 0
      qiniu/services/blockchain/SolanaService.php
  7. 35 0
      qiniu/services/blockchain/Throwable/Web3Exception.php
  8. 269 0
      qiniu/services/blockchain/TransactionService.php
  9. 146 0
      qiniu/services/blockchain/Web3Service.php
  10. 42 0
      qiniu/services/blockchain/bsc/Bep20.php
  11. 40 0
      qiniu/services/blockchain/bsc/Bep721.php
  12. 16 0
      qiniu/services/blockchain/bsc/Callback.php
  13. 56 0
      qiniu/services/blockchain/bsc/Credential.php
  14. 68 0
      qiniu/services/blockchain/bsc/Kit.php
  15. 87 0
      qiniu/services/blockchain/bsc/NodeClient.php
  16. 185 0
      qiniu/services/blockchain/bsc/SmartContract.php
  17. 132 0
      qiniu/services/blockchain/bsc/Transactor.php
  18. 14 0
      qiniu/services/blockchain/bsc/helper.php
  19. 257 0
      qiniu/services/blockchain/bsc/json/bep20.json
  20. 636 0
      qiniu/services/blockchain/bsc/src/Contract.php
  21. 399 0
      qiniu/services/blockchain/bsc/src/Contracts/Ethabi.php
  22. 273 0
      qiniu/services/blockchain/bsc/src/Contracts/SolidityType.php
  23. 86 0
      qiniu/services/blockchain/bsc/src/Contracts/Types/Address.php
  24. 81 0
      qiniu/services/blockchain/bsc/src/Contracts/Types/Boolean.php
  25. 100 0
      qiniu/services/blockchain/bsc/src/Contracts/Types/Bytes.php
  26. 97 0
      qiniu/services/blockchain/bsc/src/Contracts/Types/DynamicBytes.php
  27. 39 0
      qiniu/services/blockchain/bsc/src/Contracts/Types/IType.php
  28. 82 0
      qiniu/services/blockchain/bsc/src/Contracts/Types/Integer.php
  29. 90 0
      qiniu/services/blockchain/bsc/src/Contracts/Types/Str.php
  30. 82 0
      qiniu/services/blockchain/bsc/src/Contracts/Types/Uinteger.php
  31. 180 0
      qiniu/services/blockchain/bsc/src/Eth.php
  32. 44 0
      qiniu/services/blockchain/bsc/src/Formatters/AddressFormatter.php
  33. 33 0
      qiniu/services/blockchain/bsc/src/Formatters/BigNumberFormatter.php
  34. 30 0
      qiniu/services/blockchain/bsc/src/Formatters/BooleanFormatter.php
  35. 38 0
      qiniu/services/blockchain/bsc/src/Formatters/HexFormatter.php
  36. 23 0
      qiniu/services/blockchain/bsc/src/Formatters/IFormatter.php
  37. 44 0
      qiniu/services/blockchain/bsc/src/Formatters/IntegerFormatter.php
  38. 34 0
      qiniu/services/blockchain/bsc/src/Formatters/NumberFormatter.php
  39. 35 0
      qiniu/services/blockchain/bsc/src/Formatters/OptionalQuantityFormatter.php
  40. 37 0
      qiniu/services/blockchain/bsc/src/Formatters/PostFormatter.php
  41. 47 0
      qiniu/services/blockchain/bsc/src/Formatters/QuantityFormatter.php
  42. 30 0
      qiniu/services/blockchain/bsc/src/Formatters/StringFormatter.php
  43. 47 0
      qiniu/services/blockchain/bsc/src/Formatters/TransactionFormatter.php
  44. 57 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/Accounts.php
  45. 60 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/BlockNumber.php
  46. 70 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/Call.php
  47. 58 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/Coinbase.php
  48. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/CompileLLL.php
  49. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/CompileSerpent.php
  50. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/CompileSolidity.php
  51. 67 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/EstimateGas.php
  52. 61 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GasPrice.php
  53. 74 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetBalance.php
  54. 66 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetBlockByHash.php
  55. 71 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetBlockByNumber.php
  56. 67 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetBlockTransactionCountByHash.php
  57. 69 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetBlockTransactionCountByNumber.php
  58. 71 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetCode.php
  59. 58 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetCompilers.php
  60. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetFilterChanges.php
  61. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetFilterLogs.php
  62. 61 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetLogs.php
  63. 72 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetStorageAt.php
  64. 66 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetTransactionByBlockHashAndIndex.php
  65. 68 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetTransactionByBlockNumberAndIndex.php
  66. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetTransactionByHash.php
  67. 74 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetTransactionCount.php
  68. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetTransactionReceipt.php
  69. 66 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetUncleByBlockHashAndIndex.php
  70. 68 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetUncleByBlockNumberAndIndex.php
  71. 67 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetUncleCountByBlockHash.php
  72. 72 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetUncleCountByBlockNumber.php
  73. 58 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/GetWork.php
  74. 61 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/Hashrate.php
  75. 58 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/Mining.php
  76. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/NewBlockFilter.php
  77. 61 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/NewFilter.php
  78. 58 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/NewPendingTransactionFilter.php
  79. 61 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/ProtocolVersion.php
  80. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/SendRawTransaction.php
  81. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/SendTransaction.php
  82. 66 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/Sign.php
  83. 61 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/SubmitHashrate.php
  84. 65 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/SubmitWork.php
  85. 58 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/Syncing.php
  86. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Eth/UninstallFilter.php
  87. 158 0
      qiniu/services/blockchain/bsc/src/Methods/EthMethod.php
  88. 24 0
      qiniu/services/blockchain/bsc/src/Methods/IMethod.php
  89. 29 0
      qiniu/services/blockchain/bsc/src/Methods/IRPC.php
  90. 215 0
      qiniu/services/blockchain/bsc/src/Methods/JSONRPC.php
  91. 58 0
      qiniu/services/blockchain/bsc/src/Methods/Net/Listening.php
  92. 61 0
      qiniu/services/blockchain/bsc/src/Methods/Net/PeerCount.php
  93. 58 0
      qiniu/services/blockchain/bsc/src/Methods/Net/Version.php
  94. 58 0
      qiniu/services/blockchain/bsc/src/Methods/Personal/ListAccounts.php
  95. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Personal/NewAccount.php
  96. 66 0
      qiniu/services/blockchain/bsc/src/Methods/Personal/SendTransaction.php
  97. 70 0
      qiniu/services/blockchain/bsc/src/Methods/Personal/UnlockAccount.php
  98. 61 0
      qiniu/services/blockchain/bsc/src/Methods/Shh/AddToGroup.php
  99. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Shh/GetFilterChanges.php
  100. 64 0
      qiniu/services/blockchain/bsc/src/Methods/Shh/GetMessages.php

+ 20 - 0
app/common.php

@@ -12,6 +12,7 @@ use think\db\exception\DataNotFoundException;
 use think\db\exception\DbException;
 use think\db\exception\ModelNotFoundException;
 use think\exception\ValidateException;
+use think\facade\Config;
 use think\facade\Log;
 
 if (!function_exists('filter_str')) {
@@ -853,4 +854,23 @@ if (!function_exists('trade_password')) {
             throw new ValidateException('交易密码错误');
         }
     }
+}
+
+if (!function_exists('get_token_info')) {
+    /**
+     * 获取token信息
+     * @param $token
+     * @param string $field
+     * @param mixed $default
+     * @param string $chain
+     * @return mixed|string
+     */
+    function get_token_info($token, string $field = '', $default = '', string $chain = 'bsc')
+    {
+        $token = strtolower($token);
+        $key = 'blockchain.' . $chain . '.tokens.' . $token;
+        $value = Config::get($key);
+        if ($field) return $value[$field] ?? $default;
+        return $value ?? $default;
+    }
 }

+ 5 - 1
composer.json

@@ -51,7 +51,11 @@
     "ext-openssl": "*",
     "overtrue/wechat": "^5.30",
     "joypack/tencent-map": "^1.0",
-    "alipaysdk/easysdk": "^2.2"
+    "alipaysdk/easysdk": "^2.2",
+    "web3p/ethereum-tx": "^0.4.3",
+    "bitwasp/bitcoin": "^1.0",
+    "ext-gmp": "*",
+    "ext-sodium": "*"
   },
   "require-dev": {
     "symfony/var-dumper": "^4.2",

+ 960 - 35
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "42efa29f92d7a957b961fb1185458530",
+    "content-hash": "17d9a2248d075998bec6a53188ba4224",
     "packages": [
         {
             "name": "adbario/php-dot-notation",
@@ -854,6 +854,163 @@
             },
             "time": "2022-12-07T17:46:57+00:00"
         },
+        {
+            "name": "bitwasp/bech32",
+            "version": "v0.0.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/Bit-Wasp/bech32.git",
+                "reference": "e1ea58c848a4ec59d81b697b3dfe9cc99968d0e7"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/Bit-Wasp/bech32/zipball/e1ea58c848a4ec59d81b697b3dfe9cc99968d0e7",
+                "reference": "e1ea58c848a4ec59d81b697b3dfe9cc99968d0e7",
+                "shasum": ""
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^5.4.0",
+                "squizlabs/php_codesniffer": "^2.0.0"
+            },
+            "type": "library",
+            "autoload": {
+                "files": [
+                    "src/bech32.php"
+                ],
+                "psr-4": {
+                    "BitWasp\\Bech32\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Unlicense"
+            ],
+            "authors": [
+                {
+                    "name": "Thomas Kerin",
+                    "homepage": "https://thomaskerin.io",
+                    "role": "Author"
+                }
+            ],
+            "description": "Pure (no dependencies) implementation of bech32",
+            "homepage": "https://github.com/bit-wasp/bech32",
+            "support": {
+                "issues": "https://github.com/Bit-Wasp/bech32/issues",
+                "source": "https://github.com/Bit-Wasp/bech32/tree/more-tests"
+            },
+            "time": "2018-02-05T22:23:47+00:00"
+        },
+        {
+            "name": "bitwasp/bitcoin",
+            "version": "v1.0.4",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/Bit-Wasp/bitcoin-php.git",
+                "reference": "65ff8384a15e805effcf600fb08cef3a0fc63824"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/Bit-Wasp/bitcoin-php/zipball/65ff8384a15e805effcf600fb08cef3a0fc63824",
+                "reference": "65ff8384a15e805effcf600fb08cef3a0fc63824",
+                "shasum": ""
+            },
+            "require": {
+                "bitwasp/bech32": "^0.0.1",
+                "bitwasp/buffertools": "^0.5.0",
+                "composer/semver": "^1.4.0",
+                "lastguest/murmurhash": "v2.0.0",
+                "mdanter/ecc": "^0.5.0",
+                "php-64bit": ">=7.0",
+                "pleonasm/merkle-tree": "1.0.0"
+            },
+            "require-dev": {
+                "bitwasp/bitcoinconsensus": "v3.0.0",
+                "bitwasp/secp256k1-php": "^v0.2.0",
+                "ext-json": "*",
+                "nbobtc/bitcoind-php": "v2.0.2",
+                "phpunit/phpunit": "^5.4.0",
+                "squizlabs/php_codesniffer": "^2.0.0"
+            },
+            "suggest": {
+                "ext-bitcoinconsensus": "The bitcoinconsensus library for safest possible script verification",
+                "ext-secp256k1": "The secp256k1 library for fast and safe elliptic curve operations"
+            },
+            "type": "library",
+            "autoload": {
+                "files": [
+                    "src/Script/functions.php"
+                ],
+                "psr-4": {
+                    "BitWasp\\Bitcoin\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Unlicense"
+            ],
+            "authors": [
+                {
+                    "name": "Thomas Kerin",
+                    "homepage": "https://thomaskerin.io",
+                    "role": "Author"
+                }
+            ],
+            "description": "PHP Bitcoin library with functions for transactions, signatures, serialization, Random/Deterministic ECDSA keys, blocks, RPC bindings",
+            "homepage": "https://github.com/bit-wasp/bitcoin-php",
+            "support": {
+                "issues": "https://github.com/Bit-Wasp/bitcoin-php/issues",
+                "source": "https://github.com/Bit-Wasp/bitcoin-php/tree/v1.0.4"
+            },
+            "time": "2019-12-10T23:28:26+00:00"
+        },
+        {
+            "name": "bitwasp/buffertools",
+            "version": "v0.5.7",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/Bit-Wasp/buffertools-php.git",
+                "reference": "133746d0b514e0016d8479b54aa97475405a9f1f"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/Bit-Wasp/buffertools-php/zipball/133746d0b514e0016d8479b54aa97475405a9f1f",
+                "reference": "133746d0b514e0016d8479b54aa97475405a9f1f",
+                "shasum": ""
+            },
+            "require": {
+                "php-64bit": ">=7.0.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^6.0",
+                "squizlabs/php_codesniffer": "~2.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "BitWasp\\Buffertools\\": "src/Buffertools/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Thomas Kerin",
+                    "homepage": "https://thomaskerin.io"
+                },
+                {
+                    "name": "Ruben de Vries",
+                    "email": "ruben@rubensayshi.com"
+                }
+            ],
+            "description": "Toolbox for working with binary and hex data. Similar to NodeJS Buffer.",
+            "support": {
+                "issues": "https://github.com/Bit-Wasp/buffertools-php/issues",
+                "source": "https://github.com/Bit-Wasp/buffertools-php/tree/v0.5.7"
+            },
+            "time": "2020-01-17T21:31:49+00:00"
+        },
         {
             "name": "carbonphp/carbon-doctrine-types",
             "version": "2.1.0",
@@ -929,6 +1086,86 @@
             ],
             "time": "2023-12-11T17:09:12+00:00"
         },
+        {
+            "name": "composer/semver",
+            "version": "1.7.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/composer/semver.git",
+                "reference": "647490bbcaf7fc4891c58f47b825eb99d19c377a"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/composer/semver/zipball/647490bbcaf7fc4891c58f47b825eb99d19c377a",
+                "reference": "647490bbcaf7fc4891c58f47b825eb99d19c377a",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^5.3.2 || ^7.0 || ^8.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^4.5 || ^5.0.5"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Composer\\Semver\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nils Adermann",
+                    "email": "naderman@naderman.de",
+                    "homepage": "http://www.naderman.de"
+                },
+                {
+                    "name": "Jordi Boggiano",
+                    "email": "j.boggiano@seld.be",
+                    "homepage": "http://seld.be"
+                },
+                {
+                    "name": "Rob Bast",
+                    "email": "rob.bast@gmail.com",
+                    "homepage": "http://robbast.nl"
+                }
+            ],
+            "description": "Semver library that offers utilities, version constraint parsing and validation.",
+            "keywords": [
+                "semantic",
+                "semver",
+                "validation",
+                "versioning"
+            ],
+            "support": {
+                "irc": "irc://irc.freenode.org/composer",
+                "issues": "https://github.com/composer/semver/issues",
+                "source": "https://github.com/composer/semver/tree/1.7.2"
+            },
+            "funding": [
+                {
+                    "url": "https://packagist.com",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/composer",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/composer/composer",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2020-12-03T15:47:16+00:00"
+        },
         {
             "name": "dasprid/enum",
             "version": "1.0.5",
@@ -1219,6 +1456,82 @@
             "description": "This is a behavior verification code PHP back-end implementation package",
             "time": "2023-03-29T10:35:25+00:00"
         },
+        {
+            "name": "fgrosse/phpasn1",
+            "version": "v2.5.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/fgrosse/PHPASN1.git",
+                "reference": "42060ed45344789fb9f21f9f1864fc47b9e3507b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/fgrosse/PHPASN1/zipball/42060ed45344789fb9f21f9f1864fc47b9e3507b",
+                "reference": "42060ed45344789fb9f21f9f1864fc47b9e3507b",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.1 || ^8.0"
+            },
+            "require-dev": {
+                "php-coveralls/php-coveralls": "~2.0",
+                "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
+            },
+            "suggest": {
+                "ext-bcmath": "BCmath is the fallback extension for big integer calculations",
+                "ext-curl": "For loading OID information from the web if they have not bee defined statically",
+                "ext-gmp": "GMP is the preferred extension for big integer calculations",
+                "phpseclib/bcmath_compat": "BCmath polyfill for servers where neither GMP nor BCmath is available"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.0.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "FG\\": "lib/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Friedrich Große",
+                    "email": "friedrich.grosse@gmail.com",
+                    "homepage": "https://github.com/FGrosse",
+                    "role": "Author"
+                },
+                {
+                    "name": "All contributors",
+                    "homepage": "https://github.com/FGrosse/PHPASN1/contributors"
+                }
+            ],
+            "description": "A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.",
+            "homepage": "https://github.com/FGrosse/PHPASN1",
+            "keywords": [
+                "DER",
+                "asn.1",
+                "asn1",
+                "ber",
+                "binary",
+                "decoding",
+                "encoding",
+                "x.509",
+                "x.690",
+                "x509",
+                "x690"
+            ],
+            "support": {
+                "issues": "https://github.com/fgrosse/PHPASN1/issues",
+                "source": "https://github.com/fgrosse/PHPASN1/tree/v2.5.0"
+            },
+            "abandoned": true,
+            "time": "2022-12-19T11:08:26+00:00"
+        },
         {
             "name": "firebase/php-jwt",
             "version": "v6.10.0",
@@ -1389,13 +1702,7 @@
                 "type": "zip",
                 "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b",
                 "reference": "d281ed313b989f213357e3be1a179f02196ac99b",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "shasum": ""
             },
             "require": {
                 "ext-json": "*",
@@ -2160,6 +2467,106 @@
             },
             "time": "2021-11-16T06:49:35+00:00"
         },
+        {
+            "name": "kornrunner/keccak",
+            "version": "1.1.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/kornrunner/php-keccak.git",
+                "reference": "433749d28e117fb97baf9f2631b92b5d9ab3c890"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/kornrunner/php-keccak/zipball/433749d28e117fb97baf9f2631b92b5d9ab3c890",
+                "reference": "433749d28e117fb97baf9f2631b92b5d9ab3c890",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.3",
+                "symfony/polyfill-mbstring": "^1.8"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^8.2"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "kornrunner\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Boris Momcilovic",
+                    "homepage": "https://github.com/kornrunner/php-keccak"
+                }
+            ],
+            "description": "Pure PHP implementation of Keccak",
+            "keywords": [
+                "keccak",
+                "sha-3",
+                "sha3-256"
+            ],
+            "support": {
+                "issues": "https://github.com/kornrunner/php-keccak/issues",
+                "source": "https://github.com/kornrunner/php-keccak/tree/1.1.0"
+            },
+            "time": "2020-12-07T15:40:44+00:00"
+        },
+        {
+            "name": "lastguest/murmurhash",
+            "version": "2.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/lastguest/murmurhash-php.git",
+                "reference": "4fb7516f67e695e5d7fa129d1bbb925ec0ebe408"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/lastguest/murmurhash-php/zipball/4fb7516f67e695e5d7fa129d1bbb925ec0ebe408",
+                "reference": "4fb7516f67e695e5d7fa129d1bbb925ec0ebe408",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7"
+            },
+            "require-dev": {
+                "phpstan/phpstan": "^0.6.3",
+                "phpunit/phpunit": "^5"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "lastguest\\": "src/lastguest/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Stefano Azzolini",
+                    "email": "lastguest@gmail.com",
+                    "homepage": "https://github.com/lastguest/murmurhash-php"
+                }
+            ],
+            "description": "MurmurHash3 Hash",
+            "homepage": "https://github.com/lastguest/murmurhash-php",
+            "keywords": [
+                "hash",
+                "hashing",
+                "murmur"
+            ],
+            "support": {
+                "issues": "https://github.com/lastguest/murmurhash-php/issues",
+                "source": "https://github.com/lastguest/murmurhash-php/tree/master"
+            },
+            "time": "2017-10-10T15:16:12+00:00"
+        },
         {
             "name": "league/flysystem",
             "version": "1.1.10",
@@ -2642,6 +3049,83 @@
             },
             "time": "2022-12-02T22:17:43+00:00"
         },
+        {
+            "name": "mdanter/ecc",
+            "version": "v0.5.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/phpecc/phpecc.git",
+                "reference": "b95f25cc1bacc83a9f0ccd375900b7cfd343029e"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/phpecc/phpecc/zipball/b95f25cc1bacc83a9f0ccd375900b7cfd343029e",
+                "reference": "b95f25cc1bacc83a9f0ccd375900b7cfd343029e",
+                "shasum": ""
+            },
+            "require": {
+                "ext-gmp": "*",
+                "fgrosse/phpasn1": "^2.0",
+                "php": "^7.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^6.0",
+                "squizlabs/php_codesniffer": "^2.0",
+                "symfony/yaml": "^2.6|^3.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Mdanter\\Ecc\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Matyas Danter",
+                    "homepage": "http://matejdanter.com/",
+                    "role": "Author"
+                },
+                {
+                    "name": "Thibaud Fabre",
+                    "email": "thibaud@aztech.io",
+                    "homepage": "http://aztech.io",
+                    "role": "Maintainer"
+                },
+                {
+                    "name": "Thomas Kerin",
+                    "email": "afk11@users.noreply.github.com",
+                    "role": "Maintainer"
+                }
+            ],
+            "description": "PHP Elliptic Curve Cryptography library",
+            "homepage": "https://github.com/phpecc/phpecc",
+            "keywords": [
+                "Diffie",
+                "ECDSA",
+                "Hellman",
+                "curve",
+                "ecdh",
+                "elliptic",
+                "nistp192",
+                "nistp224",
+                "nistp256",
+                "nistp384",
+                "nistp521",
+                "phpecc",
+                "secp256k1",
+                "secp256r1"
+            ],
+            "support": {
+                "issues": "https://github.com/phpecc/phpecc/issues",
+                "source": "https://github.com/phpecc/phpecc/tree/master"
+            },
+            "abandoned": "paragonie/ecc",
+            "time": "2018-12-03T18:17:01+00:00"
+        },
         {
             "name": "monolog/monolog",
             "version": "2.10.0",
@@ -3386,16 +3870,96 @@
                 "tecnickcom/tcpdf": "^6.5"
             },
             "suggest": {
-                "dompdf/dompdf": "Option for rendering PDF with PDF Writer",
-                "ext-intl": "PHP Internationalization Functions",
-                "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
-                "mpdf/mpdf": "Option for rendering PDF with PDF Writer",
-                "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
+                "dompdf/dompdf": "Option for rendering PDF with PDF Writer",
+                "ext-intl": "PHP Internationalization Functions",
+                "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
+                "mpdf/mpdf": "Option for rendering PDF with PDF Writer",
+                "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Maarten Balliauw",
+                    "homepage": "https://blog.maartenballiauw.be"
+                },
+                {
+                    "name": "Mark Baker",
+                    "homepage": "https://markbakeruk.net"
+                },
+                {
+                    "name": "Franck Lefevre",
+                    "homepage": "https://rootslabs.net"
+                },
+                {
+                    "name": "Erik Tilt"
+                },
+                {
+                    "name": "Adrien Crivelli"
+                }
+            ],
+            "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
+            "homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
+            "keywords": [
+                "OpenXML",
+                "excel",
+                "gnumeric",
+                "ods",
+                "php",
+                "spreadsheet",
+                "xls",
+                "xlsx"
+            ],
+            "support": {
+                "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
+                "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.29.4"
+            },
+            "time": "2024-11-10T16:26:22+00:00"
+        },
+        {
+            "name": "phpseclib/phpseclib",
+            "version": "2.0.48",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/phpseclib/phpseclib.git",
+                "reference": "eaa7be704b8b93a6913b69eb7f645a59d7731b61"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/eaa7be704b8b93a6913b69eb7f645a59d7731b61",
+                "reference": "eaa7be704b8b93a6913b69eb7f645a59d7731b61",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3"
+            },
+            "require-dev": {
+                "phing/phing": "~2.7",
+                "phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4",
+                "squizlabs/php_codesniffer": "~2.0"
+            },
+            "suggest": {
+                "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
+                "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",
+                "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
+                "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations.",
+                "ext-xml": "Install the XML extension to load XML formatted public keys."
             },
             "type": "library",
             "autoload": {
+                "files": [
+                    "phpseclib/bootstrap.php"
+                ],
                 "psr-4": {
-                    "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
+                    "phpseclib\\": "phpseclib/"
                 }
             },
             "notification-url": "https://packagist.org/downloads/",
@@ -3404,41 +3968,71 @@
             ],
             "authors": [
                 {
-                    "name": "Maarten Balliauw",
-                    "homepage": "https://blog.maartenballiauw.be"
+                    "name": "Jim Wigginton",
+                    "email": "terrafrost@php.net",
+                    "role": "Lead Developer"
                 },
                 {
-                    "name": "Mark Baker",
-                    "homepage": "https://markbakeruk.net"
+                    "name": "Patrick Monnerat",
+                    "email": "pm@datasphere.ch",
+                    "role": "Developer"
                 },
                 {
-                    "name": "Franck Lefevre",
-                    "homepage": "https://rootslabs.net"
+                    "name": "Andreas Fischer",
+                    "email": "bantu@phpbb.com",
+                    "role": "Developer"
                 },
                 {
-                    "name": "Erik Tilt"
+                    "name": "Hans-Jürgen Petrich",
+                    "email": "petrich@tronic-media.com",
+                    "role": "Developer"
                 },
                 {
-                    "name": "Adrien Crivelli"
+                    "name": "Graham Campbell",
+                    "email": "graham@alt-three.com",
+                    "role": "Developer"
                 }
             ],
-            "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
-            "homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
+            "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
+            "homepage": "http://phpseclib.sourceforge.net",
             "keywords": [
-                "OpenXML",
-                "excel",
-                "gnumeric",
-                "ods",
-                "php",
-                "spreadsheet",
-                "xls",
-                "xlsx"
+                "BigInteger",
+                "aes",
+                "asn.1",
+                "asn1",
+                "blowfish",
+                "crypto",
+                "cryptography",
+                "encryption",
+                "rsa",
+                "security",
+                "sftp",
+                "signature",
+                "signing",
+                "ssh",
+                "twofish",
+                "x.509",
+                "x509"
             ],
             "support": {
-                "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
-                "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.29.4"
+                "issues": "https://github.com/phpseclib/phpseclib/issues",
+                "source": "https://github.com/phpseclib/phpseclib/tree/2.0.48"
             },
-            "time": "2024-11-10T16:26:22+00:00"
+            "funding": [
+                {
+                    "url": "https://github.com/terrafrost",
+                    "type": "github"
+                },
+                {
+                    "url": "https://www.patreon.com/phpseclib",
+                    "type": "patreon"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2024-12-14T21:03:54+00:00"
         },
         {
             "name": "pimple/pimple",
@@ -3499,6 +4093,53 @@
             },
             "time": "2021-10-28T11:13:42+00:00"
         },
+        {
+            "name": "pleonasm/merkle-tree",
+            "version": "1.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/pleonasm/merkle-tree.git",
+                "reference": "9ddc9d0a0e396750fada378f3aa90f6c02dd56a1"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/pleonasm/merkle-tree/zipball/9ddc9d0a0e396750fada378f3aa90f6c02dd56a1",
+                "reference": "9ddc9d0a0e396750fada378f3aa90f6c02dd56a1",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.4.0"
+            },
+            "require-dev": {
+                "ext-xdebug": ">=2.2.0",
+                "phpunit/php-invoker": ">=1.0.0,<1.2.0",
+                "phpunit/phpunit": "3.7.19",
+                "satooshi/php-coveralls": "*@dev",
+                "squizlabs/php_codesniffer": "*"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-0": {
+                    "Pleo": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-2-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Matthew Nagi",
+                    "email": "matthew.nagi@base-2.net"
+                }
+            ],
+            "description": "An implementation of a Merkle Tree in PHP",
+            "support": {
+                "issues": "https://github.com/pleonasm/merkle-tree/issues",
+                "source": "https://github.com/pleonasm/merkle-tree/tree/master"
+            },
+            "time": "2013-05-22T20:46:20+00:00"
+        },
         {
             "name": "psr/cache",
             "version": "1.0.1",
@@ -4278,6 +4919,153 @@
             ],
             "time": "2023-11-16T16:16:50+00:00"
         },
+        {
+            "name": "simplito/bigint-wrapper-php",
+            "version": "1.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/simplito/bigint-wrapper-php.git",
+                "reference": "cf21ec76d33f103add487b3eadbd9f5033a25930"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/simplito/bigint-wrapper-php/zipball/cf21ec76d33f103add487b3eadbd9f5033a25930",
+                "reference": "cf21ec76d33f103add487b3eadbd9f5033a25930",
+                "shasum": ""
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "BI\\": "lib/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Simplito Team",
+                    "email": "s.smyczynski@simplito.com",
+                    "homepage": "https://simplito.com"
+                }
+            ],
+            "description": "Common interface for php_gmp and php_bcmath modules",
+            "support": {
+                "issues": "https://github.com/simplito/bigint-wrapper-php/issues",
+                "source": "https://github.com/simplito/bigint-wrapper-php/tree/1.0.0"
+            },
+            "time": "2018-02-27T12:38:08+00:00"
+        },
+        {
+            "name": "simplito/bn-php",
+            "version": "1.1.4",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/simplito/bn-php.git",
+                "reference": "83446756a81720eacc2ffb87ff97958431451fd6"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/simplito/bn-php/zipball/83446756a81720eacc2ffb87ff97958431451fd6",
+                "reference": "83446756a81720eacc2ffb87ff97958431451fd6",
+                "shasum": ""
+            },
+            "require": {
+                "simplito/bigint-wrapper-php": "~1.0.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "*"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "BN\\": "lib/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Simplito Team",
+                    "email": "s.smyczynski@simplito.com",
+                    "homepage": "https://simplito.com"
+                }
+            ],
+            "description": "Big number implementation compatible with bn.js",
+            "support": {
+                "issues": "https://github.com/simplito/bn-php/issues",
+                "source": "https://github.com/simplito/bn-php/tree/1.1.4"
+            },
+            "time": "2024-01-10T16:16:59+00:00"
+        },
+        {
+            "name": "simplito/elliptic-php",
+            "version": "1.0.12",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/simplito/elliptic-php.git",
+                "reference": "be321666781be2be2c89c79c43ffcac834bc8868"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/simplito/elliptic-php/zipball/be321666781be2be2c89c79c43ffcac834bc8868",
+                "reference": "be321666781be2be2c89c79c43ffcac834bc8868",
+                "shasum": ""
+            },
+            "require": {
+                "ext-gmp": "*",
+                "simplito/bn-php": "~1.1.0"
+            },
+            "require-dev": {
+                "phpbench/phpbench": "@dev",
+                "phpunit/phpunit": "*"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Elliptic\\": "lib/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Simplito Team",
+                    "email": "s.smyczynski@simplito.com",
+                    "homepage": "https://simplito.com"
+                }
+            ],
+            "description": "Fast elliptic curve cryptography",
+            "homepage": "https://github.com/simplito/elliptic-php",
+            "keywords": [
+                "Curve25519",
+                "ECDSA",
+                "Ed25519",
+                "EdDSA",
+                "cryptography",
+                "curve",
+                "curve25519-weier",
+                "ecc",
+                "ecdh",
+                "elliptic",
+                "nistp192",
+                "nistp224",
+                "nistp256",
+                "nistp384",
+                "nistp521",
+                "secp256k1"
+            ],
+            "support": {
+                "issues": "https://github.com/simplito/elliptic-php/issues",
+                "source": "https://github.com/simplito/elliptic-php/tree/1.0.12"
+            },
+            "time": "2024-01-09T14:57:04+00:00"
+        },
         {
             "name": "stechstudio/backoff",
             "version": "1.2.1",
@@ -6393,6 +7181,143 @@
             },
             "time": "2023-03-09T07:52:09+00:00"
         },
+        {
+            "name": "web3p/ethereum-tx",
+            "version": "0.4.3",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/web3p/ethereum-tx.git",
+                "reference": "8dc1adc10ae45ac440c43ac32a3c5adf63ed8cef"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/web3p/ethereum-tx/zipball/8dc1adc10ae45ac440c43ac32a3c5adf63ed8cef",
+                "reference": "8dc1adc10ae45ac440c43ac32a3c5adf63ed8cef",
+                "shasum": ""
+            },
+            "require": {
+                "kornrunner/keccak": "~1",
+                "php": "^7.1|^8.0",
+                "simplito/elliptic-php": "~1.0.6",
+                "web3p/ethereum-util": "~0.1.3",
+                "web3p/rlp": "0.3.4"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~7|~8.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Web3p\\EthereumTx\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "sc0Vu",
+                    "email": "alk03073135@gmail.com"
+                }
+            ],
+            "description": "Ethereum transaction library in PHP.",
+            "support": {
+                "issues": "https://github.com/web3p/ethereum-tx/issues",
+                "source": "https://github.com/web3p/ethereum-tx/tree/0.4.3"
+            },
+            "time": "2021-09-01T05:13:20+00:00"
+        },
+        {
+            "name": "web3p/ethereum-util",
+            "version": "0.1.4",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/web3p/ethereum-util.git",
+                "reference": "9a01f5389835d4092d338bb7b7d119017052ca68"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/web3p/ethereum-util/zipball/9a01f5389835d4092d338bb7b7d119017052ca68",
+                "reference": "9a01f5389835d4092d338bb7b7d119017052ca68",
+                "shasum": ""
+            },
+            "require": {
+                "kornrunner/keccak": "~1",
+                "php": "^7.1 | ^8.0",
+                "phpseclib/phpseclib": "~2.0",
+                "simplito/elliptic-php": "~1.0.6"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~7 | ~8.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Web3p\\EthereumUtil\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "sc0Vu",
+                    "email": "alk03073135@gmail.com"
+                }
+            ],
+            "description": "A collection of utility functions for Ethereum written in PHP.",
+            "support": {
+                "issues": "https://github.com/web3p/ethereum-util/issues",
+                "source": "https://github.com/web3p/ethereum-util/tree/0.1.4"
+            },
+            "time": "2022-12-18T05:42:39+00:00"
+        },
+        {
+            "name": "web3p/rlp",
+            "version": "0.3.4",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/web3p/rlp.git",
+                "reference": "1653af23142863b490bdf22c6d0335bdb588c983"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/web3p/rlp/zipball/1653af23142863b490bdf22c6d0335bdb588c983",
+                "reference": "1653af23142863b490bdf22c6d0335bdb588c983",
+                "shasum": ""
+            },
+            "require": {
+                "ext-mbstring": "*",
+                "php": "^7.1 | ^8.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~7|~8.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Web3p\\RLP\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "sc0Vu",
+                    "email": "alk03073135@gmail.com"
+                }
+            ],
+            "description": "Recursive Length Prefix Encoding in PHP.",
+            "support": {
+                "issues": "https://github.com/web3p/rlp/issues",
+                "source": "https://github.com/web3p/rlp/tree/0.3.4"
+            },
+            "time": "2021-08-30T10:22:03+00:00"
+        },
         {
             "name": "yurunsoft/composer-include-files",
             "version": "v2.0.0",

+ 32 - 0
config/blockchain.php

@@ -0,0 +1,32 @@
+<?php
+/**
+ * @Created by PhpStorm
+ * @author: Kirin
+ * @day: 2025/2/19
+ * @time: 10:50
+ */
+
+
+// +----------------------------------------------------------------------
+// | 区块链配置
+// +----------------------------------------------------------------------
+return [
+    // BSC
+    'bsc' => [
+        'node' => 'https://omniscient-icy-dew.bsc.quiknode.pro/efd8465113691a992370197ae68b81439dcd1e9d/',
+        'tokens' => [
+            'usdt' => [
+//        'address' => '0x55d398326f99059fF775485246999027B3197955',//USDT合约地址
+                'address' => '0x8f5f8daC38461E5b1A6b230D30433f8A593CCD57',//USDT测试合约地址
+//        'decimal' => 18,
+                'decimal' => 18,
+                'private_key' => '0294f6a2b958585b6bf07b44ceeb1c0eb18796e64e2ecc107c0d4df8fcc0a646',
+                'extract' => true,
+                'charge' => true,
+                'recharge_address' => '0x784d0518bE4250F9c0dA7435f0C934f68F13Bb4C',
+                'type' => 'bep20',
+            ],
+        ],
+    ]
+
+];

+ 1 - 0
public/.well-known/acme-challenge/ozw54pdcX8Uth53daD4a2gOO0H7aJu65odMUbI6Pjgw

@@ -0,0 +1 @@
+ozw54pdcX8Uth53daD4a2gOO0H7aJu65odMUbI6Pjgw.Pcas9PbLg5cSa2DnIqG--cqM48P4qyTKg6NTDleiGM0

+ 66 - 0
qiniu/services/blockchain/SolanaService.php

@@ -0,0 +1,66 @@
+<?php
+/**
+ * @Created by PhpStorm
+ * @author: Kirin
+ * @day: 2024/6/27
+ * @time: 19:16
+ */
+
+namespace qiniu\services\blockchain;
+
+
+use BitWasp\Bitcoin\Base58;
+use BitWasp\Buffertools\Buffer;
+use think\Exception;
+
+class SolanaService
+{
+
+    private static $node = 'https://solana-mainnet.core.chainstack.com/867a25e325f29ac68e3b5185af1abb68';
+
+    public static function signCheck($sign, $address, $message)
+    {
+        if (!is_array($sign)) {
+            $sign = explode(',', $sign);
+        }
+        if (!count($sign) == 64) {
+            throw new Exception('Sign fail');
+        }
+        $sign_str = self::uint8ArrayToByteString($sign);
+        $sign_buffer = new Buffer($sign_str, 64);
+        $key_buffer2 = Base58::decode($address);
+        return sodium_crypto_sign_verify_detached($sign_buffer->getBinary(), $message, $key_buffer2->getBinary());
+    }
+
+
+    private static function uint8ArrayToByteString(array $uint8Array): string
+    {
+        return call_user_func_array('pack', array_merge(array('C*'), $uint8Array));
+    }
+
+
+    private static function byteStringToUint8Array(string $byteString): array
+    {
+        $uint8Array = unpack('C*', $byteString);
+        return array_values($uint8Array);
+    }
+
+    public static function getTransaction($tx)
+    {
+        $data = [
+            'jsonrpc' => '2.0',
+            'id' => 1,
+            'method' => 'getTransaction',
+            'params' => [
+                $tx,
+                [
+                    'maxSupportedTransactionVersion' => 0,
+                    'encoding' => 'json'
+                ],
+
+            ],
+        ];
+        $res = do_request(self::$node, [], $data, ['Content-Type: application/json'], true, true);
+        return json_decode($res, true);
+    }
+}

+ 35 - 0
qiniu/services/blockchain/Throwable/Web3Exception.php

@@ -0,0 +1,35 @@
+<?php
+// +----------------------------------------------------------------------
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
+// +----------------------------------------------------------------------
+// | Author: CRMEB Team <admin@crmeb.com>
+// +----------------------------------------------------------------------
+
+namespace qiniu\services\blockchain\Throwable;
+
+
+use Throwable;
+
+/**
+ * Class AuthException
+ * @package crmeb\exceptions
+ */
+class Web3Exception extends \RuntimeException
+{
+    public function __construct($message = "", $code = 0, Throwable $previous = null)
+    {
+        if (is_array($message)) {
+            $errInfo = $message;
+            $message = $errInfo[1] ?? '未知错误';
+            if ($code === 0) {
+                $code = $errInfo[0] ?? 400;
+            }
+        }
+
+        parent::__construct($message, $code, $previous);
+    }
+}

+ 269 - 0
qiniu/services/blockchain/TransactionService.php

@@ -0,0 +1,269 @@
+<?php
+
+
+namespace qiniu\services\blockchain;
+
+
+use app\admin\model\Extract;
+use app\admin\model\Order;
+use app\admin\model\Point;
+use app\admin\model\Recharge;
+use app\admin\model\User;
+use app\admin\model\UserTokenLog;
+use think\Config;
+use think\Exception;
+
+class TransactionService
+{
+
+    private static $errorMsg;
+
+    const DEFAULT_ERROR_MSG = '操作失败,请稍候再试!';
+
+    /**
+     * 设置错误信息
+     * @param string $errorMsg
+     * @return bool
+     */
+    protected static function setErrorInfo(string $errorMsg = self::DEFAULT_ERROR_MSG): bool
+    {
+        self::$errorMsg = $errorMsg;
+        return false;
+    }
+
+    /**
+     * 获取错误信息
+     * @param string $defaultMsg
+     * @return string
+     */
+    public static function getErrorInfo(string $defaultMsg = self::DEFAULT_ERROR_MSG): string
+    {
+        return !empty(self::$errorMsg) ? self::$errorMsg : $defaultMsg;
+    }
+
+    public static function checkExtractTransfer()
+    {
+        $list = Extract::where('status', 'in', ['0', '4'])->where('number', '>', 0)->whereNotNull('transactionHash')->select();
+        foreach ($list as $v) {
+            try {
+                $res = Web3Service::instance($v['token'])::getBNBTransferInfo($v['transactionHash']);
+            } catch (\RuntimeException $e) {
+                if ($e->getMessage() == 'Something wrong happened.') {
+                    if ($v['createtime'] < time() - 3600 * 24) {
+                        try {
+                            Extract::startTrans();
+                            Extract::where('id', $v['id'])->update(['status' => '2']);
+                            UserTokenLog::income($v['user_id'], $v['token'], 'extra_fail', '提币失败', $v['number'], '用户提币失败', $v['id']);
+                            Extract::commit();
+                        } catch (Exception $ee) {
+                            Extract::rollback();
+                            return self::setErrorInfo($ee->getMessage());
+                        }
+                    }
+                    continue;
+                } else {
+                    return self::setErrorInfo($e->getMessage());
+                }
+            }
+            if ($res) {
+                Extract::startTrans();
+                try {
+                    if (isset($res->status) && $res->status == '0x1') {
+                        $number = $v['real_get'];
+                        $result = Web3Service::instance($v['token'])::transfer($v['address'], $number);
+                        Extract::where('id', $v['id'])->update(['status' => '3', 'send_transactionHash' => $result]);
+                    } else if (isset($res->status) && $res->status == '0x0') {
+                        Extract::where('id', $v['id'])->update(['status' => '2']);
+                        UserTokenLog::income($v['user_id'], $v['token'], 'extra_fail', '提币失败', $v['number'], '用户提币失败', $v['id']);
+                    }
+                    Extract::commit();
+                } catch (Exception $e) {
+                    Extract::rollback();
+                    return self::setErrorInfo($e->getMessage());
+                } catch (\RuntimeException $e) {
+                    $pass_error = [
+                        'replacement transaction underpriced',
+                        'nonce too low',
+                        'cURL error 6: Could not resolve: ' . Config::get('endpoint') . ' (Successful completion) (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)',
+                    ];
+                    @file_put_contents('Extract.txt', $v['id'] . ':' . $e->getMessage() . PHP_EOL, FILE_APPEND);
+                    if (in_array($e->getMessage(), $pass_error)) {
+                        Extract::where('id', $v['id'])->update(['status' => '4']);
+                    } else
+                        Extract::where('id', $v['id'])->update(['status' => '1']);
+                    Extract::commit();
+                }
+            }
+        }
+        return true;
+    }
+
+    public static function checkExtractSendTransfer()
+    {
+        $list = Extract::where('status', '3')->select();
+        foreach ($list as $v) {
+            Extract::startTrans();
+            try {
+                if ($res = Web3Service::instance($v['token'])::getTransferInfo($v['send_transactionHash'])) {
+                    try {
+                        if (isset($res->status) && $res->status == '0x1') {
+                            Extract::where('id', $v['id'])->update(['status' => '1']);
+                        } else {
+                            Extract::where('id', $v['id'])->update(['status' => '4']);
+                        }
+                        Extract::commit();
+                    } catch (Exception $e) {
+                        Extract::rollback();
+                        return self::setErrorInfo($e->getMessage());
+                    }
+                }
+            } catch (\RuntimeException $e) {
+                if ($v['createtime'] < time() - 3600) {
+                    Extract::where('id', $v['id'])->update(['status' => '4']);
+                    Extract::commit();
+                } else {
+                    Extract::commit();
+                }
+            }
+        }
+        return true;
+    }
+
+    public static function checkRechargeTransfer()
+    {
+        $list = Recharge::where('status', '0')->select();
+        foreach ($list as $v) {
+            try {
+                $res = Web3Service::instance($v['token'])::getBNBTransferInfo($v['transactionHash']);
+            } catch (\RuntimeException $e) {
+                if ($e->getMessage() == 'Something wrong happened.') {
+                    continue;
+                } else {
+                    return self::setErrorInfo($e->getMessage());
+                }
+            }
+            if ($res) {
+                Recharge::startTrans();
+                try {
+                    $user = User::where('id', $v['user_id'])->find();
+                    if (isset($res->status) && $res->status == '0x1' && $res->from == strtolower($user['address']) && $res->to == strtolower(Config::get(strtolower($v['token'] . '.address')))) {
+                        $token_log = Web3Service::instance($v['token'])::getBlockTransfer(hexdec($res->blockNumber), $v['transactionHash']);
+                        foreach ($token_log as $vv) {
+                            if ($vv->params['to'] == strtolower(Config::get(strtolower($v['token']) . '.recharge_address') ?: Web3Service::instance($v['token'])::getAddress()) && $vv->params['from'] == $user['address']) {
+                                $value = $vv->params['value']->toString();
+                                $value = bcdiv($value, bcpow(10, Config::get(strtolower($v['token']) . '.decimal')), 18);
+                                if ($value > 0) {
+                                    UserTokenLog::income($user['id'], strtoupper($v['token']), 'recharge', '用户充值', $value, '充值' . (float)$value . strtoupper($v['token']), $v['id']);
+                                }
+                            }
+                        }
+                        Recharge::where('id', $v['id'])->update(['status' => '1']);
+                    } else {
+                        Recharge::where('id', $v['id'])->update(['status' => '2']);
+                    }
+                    Recharge::commit();
+                } catch (Exception $e) {
+                    Recharge::rollback();
+                    return self::setErrorInfo($e->getMessage());
+                }
+            }
+        }
+        return true;
+    }
+
+
+    public static function checkOrderTransfer()
+    {
+        $list = Order::where('status', '0')->select();
+        foreach ($list as $v) {
+            if ($v['transferHash']) {
+                try {
+                    $res = Web3Service::instance('USDT')::getBNBTransferInfo($v['transferHash']);
+                } catch (\RuntimeException $e) {
+                    if ($e->getMessage() == 'Something wrong happened.') {
+                        continue;
+                    } else {
+                        return self::setErrorInfo($e->getMessage());
+                    }
+                }
+                if ($res) {
+                    Order::startTrans();
+                    try {
+                        $user = User::where('id', $v['user_id'])->find();
+                        if (isset($res->status) && $res->status == '0x1' && $res->from == strtolower($user['address']) && $res->to == strtolower(Config::get(strtolower('usdt.address')))) {
+                            $token_log = Web3Service::instance('USDT')::getBlockTransfer(hexdec($res->blockNumber), $v['transferHash']);
+                            foreach ($token_log as $vv) {
+                                if ($vv->params['to'] == strtolower(Config::get('usdt.recharge_address') ?: Web3Service::instance('USDT')::getAddress()) && $vv->params['from'] == $user['address']) {
+                                    $value = $vv->params['value']->toString();
+                                    $value = bcdiv($value, bcpow(10, Config::get('usdt.decimal')), 18);
+                                    if ($value >= $v['num']) {
+                                        Order::orderDeal($v['id'], '1');
+                                    }
+                                }
+                            }
+                        } else {
+                            Order::where('id', $v['id'])->update(['status' => '2']);
+                        }
+                        Order::commit();
+                    } catch (Exception $e) {
+                        Order::rollback();
+                        return self::setErrorInfo($e->getMessage());
+                    }
+                }
+            } else {
+                if ($v['updatetime'] < (time() - 16 * 60)) {
+                    Order::where('id', $v['id'])->update(['status' => '2', 'deletetime' => time()]);
+                }
+            }
+        }
+        return true;
+    }
+
+
+    public static function checkPointTransfer()
+    {
+        $list = Point::where('status', '0')->select();
+        foreach ($list as $v) {
+            if ($v['transferHash']) {
+                try {
+                    $res = Web3Service::instance('USDT')::getBNBTransferInfo($v['transferHash']);
+                } catch (\RuntimeException $e) {
+                    if ($e->getMessage() == 'Something wrong happened.') {
+                        continue;
+                    } else {
+                        return self::setErrorInfo($e->getMessage());
+                    }
+                }
+                if ($res) {
+                    Point::startTrans();
+                    try {
+                        $user = User::where('id', $v['user_id'])->find();
+                        if (isset($res->status) && $res->status == '0x1' && $res->from == strtolower($user['address']) && $res->to == strtolower(Config::get(strtolower('usdt.address')))) {
+                            $token_log = Web3Service::instance('USDT')::getBlockTransfer(hexdec($res->blockNumber), $v['transferHash']);
+                            foreach ($token_log as $vv) {
+                                if ($vv->params['to'] == strtolower(Config::get('usdt.recharge_address') ?: Web3Service::instance('USDT')::getAddress()) && $vv->params['from'] == $user['address']) {
+                                    $value = $vv->params['value']->toString();
+                                    $value = bcdiv($value, bcpow(10, Config::get('usdt.decimal')), 18);
+                                    if ($value >= $v['num']) {
+                                        Point::orderDeal($v['id'], '1');
+                                    }
+                                }
+                            }
+                        } else {
+                            Point::where('id', $v['id'])->update(['status' => '2']);
+                        }
+                        Point::commit();
+                    } catch (Exception $e) {
+                        Point::rollback();
+                        return self::setErrorInfo($e->getMessage());
+                    }
+                }
+            } else {
+                if ($v['updatetime'] < (time() - 16 * 60)) {
+                    Point::where('id', $v['id'])->update(['status' => '2', 'deletetime' => time()]);
+                }
+            }
+        }
+        return true;
+    }
+}

+ 146 - 0
qiniu/services/blockchain/Web3Service.php

@@ -0,0 +1,146 @@
+<?php
+
+namespace qiniu\services\blockchain;
+
+use qiniu\services\blockchain\bsc\Bep20;
+use qiniu\services\blockchain\bsc\Bep721;
+use qiniu\services\blockchain\bsc\Callback;
+use qiniu\services\blockchain\bsc\Credential;
+use qiniu\services\blockchain\bsc\Kit;
+use qiniu\services\blockchain\bsc\NodeClient;
+use qiniu\services\blockchain\Throwable\Web3Exception;
+use Web3p\EthereumUtil\Util;
+
+define('EVENTSIG_TRANSFER', '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef');
+
+class Web3Service
+{
+
+    /** @var Bep20|Bep721 $token */
+    private static $token;
+
+    private static $decimal;
+
+    private static $address;
+
+    private static $kit;
+
+
+    public function __construct($contact, $decimal, $type, $private_key)
+    {
+        $node = NodeClient::create('mainNet');
+        $credential = Credential::fromKey($private_key);
+        self::$kit = new Kit($node, $credential);
+        self::$address = $credential->getAddress();
+        self::$token = self::$kit->$type($contact);
+        self::$decimal = $decimal;
+    }
+
+    /**
+     * @param $token
+     * @return Web3Service
+     * @throws Web3Exception
+     */
+    public static function instance($token): Web3Service
+    {
+        if (!get_token_info($token, 'address')) {
+            throw new Web3Exception('未定义Token');
+        }
+        return new self(get_token_info($token, 'address'), get_token_info($token, 'decimal'), get_token_info($token, 'type'), get_token_info($token, 'private_key'));
+    }
+
+    /**
+     * 签名转地址
+     * @param $str
+     * @param $sign
+     * @return string
+     * @throws Web3Exception
+     */
+    public static function signToAddress($str, $sign)
+    {
+        $util = new Util();
+        if (strlen($sign) != 132) {
+            throw new Web3Exception('签名格式错误,类型:001');
+        }
+        if (!$util->isHex($sign)) {
+            throw new Web3Exception('签名格式错误,类型:002');
+        }
+
+        $sign_str = $util->stripZero($sign);
+        $r = substr($sign_str, 0, 64);
+        $s = substr($sign_str, 64, 64);
+        $v = substr($sign_str, 128, 2);
+
+        $message = $util->hashPersonalMessage($str);
+
+        $public_key = $util->recoverPublicKey($message, $r, $s, hexdec($v) - 27);
+
+        return strtolower($util->publicKeyToAddress($public_key));
+    }
+
+    public static function getAddress()
+    {
+        return self::$address;
+    }
+
+    public static function getBalance($address)
+    {
+        return bcdiv(self::$token->balanceOf($address)->toString(), bcpow(10, self::$decimal), self::$decimal);
+    }
+
+    public static function getLastTransfer($num = 0)
+    {
+        return self::$token->getTransferEvents([], [], $num ? bcsub(self::$token->getBlockNumber(), $num) : 'latest');
+    }
+
+    public static function getBlockTransfer($block, $transferHash)
+    {
+        $res = self::$token->getTransferEvents([], [], $block, $block);
+        $ress = [];
+        foreach ($res as $v) {
+            if ($v->transactionHash == $transferHash) {
+                $ress[] = $v;
+            }
+        }
+        return $ress;
+    }
+
+    public static function getTransferInfo($tx_hash)
+    {
+        return self::$token->getTransactionReceipt($tx_hash);
+    }
+
+    public static function transfer($to, $amount)
+    {
+        return self::$token->transfer($to, bcmul($amount, bcpow(10, self::$decimal)));
+    }
+
+    public static function getBNBTransferInfo($tx_hash)
+    {
+        return self::$token->getTransactionReceipt($tx_hash);
+    }
+
+    public static function estimateTransferGas($to, $amount)
+    {
+        $cb = new Callback();
+        self::$token->estimateGas("transfer", self::$address, $to, bcmul($amount, bcpow(10, self::$decimal)), $cb);
+        return $cb->result->toString();
+    }
+
+    public static function getData($name, ...$args)
+    {
+        $data = self::$token->getData($name, ...$args);
+        $tx = [
+            'data' => '0x' . $data,
+            'to' => self::$token->getToAddress()
+        ];
+        return $tx;
+    }
+
+    public static function totalSupply()
+    {
+        $data = self::$token->totalSupply();
+        $value = $data->toString();
+        return bcdiv($value, bcpow(10, self::$decimal), self::$decimal);
+    }
+}

+ 42 - 0
qiniu/services/blockchain/bsc/Bep20.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace qiniu\services\blockchain\bsc;
+
+
+define('ABI_BEP20', file_get_contents(QINIU_PATH . 'services/blockchain/bsc/json/bep20.json'));
+
+//define('EVENTSIG_TRANSFER', '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef');
+
+class Bep20 extends SmartContract
+{
+    function __construct($client, $credential, $address)
+    {
+        parent::__construct($client, $credential, ABI_BEP20);
+        $this->at($address);
+    }
+
+    function getTransferEvents($from = [], $to = [], $fromBlock = 'latest', $toBlock = 'latest')
+    {
+        $toTopic = function ($addr) {
+            $addr = preg_replace('/^0x/', '', $addr);
+            return '0x' . str_pad($addr, 64, '0', STR_PAD_LEFT);
+        };
+        $from = array_map($toTopic, $from);
+        $to = array_map($toTopic, $to);
+        return $this->queryEvents([EVENTSIG_TRANSFER, $from, $to], $fromBlock, $toBlock);
+    }
+
+    function getBlockNumber()
+    {
+        $cb = new Callback();
+        $this->eth->blockNumber($cb);
+        return $cb->result->toString();
+    }
+
+    function getTransactionReceipt($tx_hash)
+    {
+        $cb = new Callback();
+        $this->eth->getTransactionReceipt($tx_hash, $cb);
+        return $cb->result;
+    }
+}

+ 40 - 0
qiniu/services/blockchain/bsc/Bep721.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace qiniu\services\blockchain\bsc;
+
+
+define('ABI_BEP721', file_get_contents('bep721.json'));
+
+class Bep721 extends SmartContract
+{
+    function __construct($client, $credential, $address)
+    {
+        parent::__construct($client, $credential, ABI_BEP721);
+        $this->at($address);
+    }
+
+    function getTransferEvents($from = [], $to = [], $fromBlock = 'latest', $toBlock = 'latest')
+    {
+        $toTopic = function ($addr) {
+            $addr = preg_replace('/^0x/', '', $addr);
+            return '0x' . str_pad($addr, 64, '0', STR_PAD_LEFT);
+        };
+        $from = array_map($toTopic, $from);
+        $to = array_map($toTopic, $to);
+        return $this->queryEvents([EVENTSIG_TRANSFER, $from, $to], $fromBlock, $toBlock);
+    }
+
+    function getBlockNumber()
+    {
+        $cb = new Callback();
+        $this->eth->blockNumber($cb);
+        return $cb->result->toString();
+    }
+
+    function getTransactionReceipt($tx_hash)
+    {
+        $cb = new Callback();
+        $this->eth->getTransactionReceipt($tx_hash, $cb);
+        return $cb->result;
+    }
+}

+ 16 - 0
qiniu/services/blockchain/bsc/Callback.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace qiniu\services\blockchain\bsc;
+
+class Callback
+{
+    public $result;
+
+    function __invoke($error, $result)
+    {
+        //$this->error = $error;
+        if ($error) throw $error;
+        $this->result = $result;
+    }
+}
+

+ 56 - 0
qiniu/services/blockchain/bsc/Credential.php

@@ -0,0 +1,56 @@
+<?php
+
+namespace qiniu\services\blockchain\bsc;
+
+use Elliptic\EC;
+use kornrunner\Keccak;
+use Web3p\EthereumTx\Transaction;
+
+class Credential
+{
+    private $keyPair;
+
+    public function __construct($keyPair)
+    {
+        $this->keyPair = $keyPair;
+    }
+
+    public function getPublicKey()
+    {
+        return $this->keyPair->getPublic()->encode('hex');
+    }
+
+    public function getPrivateKey()
+    {
+        return $this->keyPair->getPrivate()->toString(16, 2);
+    }
+
+    public function getAddress()
+    {
+        $pubkey = $this->getPublicKey();
+        return "0x" . substr(Keccak::hash(substr(hex2bin($pubkey), 1), 256), 24);
+    }
+
+    public function signTransaction($raw)
+    {
+        $txreq = new Transaction($raw);
+        $privateKey = $this->getPrivateKey();
+        $signed = '0x' . $txreq->sign($privateKey);
+        return $signed;
+    }
+
+    public static function create()
+    {
+        $ec = new EC('secp256k1');
+        $keyPair = $ec->genKeyPair();
+        return new self($keyPair);
+    }
+
+    public static function fromKey($privateKey)
+    {
+        $ec = new EC('secp256k1');
+        $keyPair = $ec->keyFromPrivate($privateKey);
+        return new self($keyPair);
+    }
+
+}

+ 68 - 0
qiniu/services/blockchain/bsc/Kit.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace qiniu\services\blockchain\bsc;
+
+use Exception;
+
+class Kit
+{
+    protected $client;
+    protected $credential;
+    protected $transactor;
+
+    function __construct($client, $credential)
+    {
+        $this->client = $client;
+        $this->credential = $credential;
+
+        $this->transactor = new Transactor($client, $credential);
+    }
+
+    function getSender()
+    {
+        return $this->credential->getAddress();
+    }
+
+    function balanceOf($addr)
+    {
+        return $this->client->getBalance($addr);
+    }
+
+    function transfer($to, $value)
+    {
+        $tx = [
+            'to' => $to,
+            'value' => $value
+        ];
+        return $this->transactor->transact($tx);
+    }
+
+    //abi, bytecode, args...
+    function deployContract()
+    {
+        $args = func_get_args();
+        if (count($args) < 2) {
+            throw new Exception('no enough deploy parameters');
+        }
+        $abi = array_shift($args);
+        $bytecode = array_shift($args);
+        $contract = new SmartContract($this->client, $this->credential, $abi);
+        $contract->bytecode($bytecode);
+        return $contract->instantiate(...$args);
+    }
+
+    function waitForConfirmation($txid, $timeout = 300)
+    {
+        return $this->client->waitForConfirmation($txid, $timeout);
+    }
+
+    function bep20($addr)
+    {
+        return new Bep20($this->client, $this->credential, $addr);
+    }
+
+    function bep721($addr)
+    {
+        return new Bep721($this->client, $this->credential, $addr);
+    }
+}

+ 87 - 0
qiniu/services/blockchain/bsc/NodeClient.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace qiniu\services\blockchain\bsc;
+
+use Exception;
+use qiniu\services\blockchain\bsc\src\Providers\HttpProvider;
+use qiniu\services\blockchain\bsc\src\RequestManagers\HttpRequestManager;
+use qiniu\services\blockchain\bsc\src\Web3;
+use think\facade\Config;
+
+class NodeClient extends Web3
+{
+    const Main_Net = 'https://bsc-dataseed.binance.org/';
+    const Test_Net = 'https://data-seed-prebsc-1-s1.binance.org:8545/';
+
+    function __construct($url)
+    {
+        $provider = new HttpProvider(
+            new HttpRequestManager($url, 300) //timeout
+        );
+        parent::__construct($provider);
+    }
+
+    static function create($network)
+    {
+        if ($network === 'mainNet') return self::mainNet();
+        if ($network === 'testNet') return self::testNet();
+        throw new Exception('unsupported network');
+    }
+
+    static function testNet()
+    {
+        return new self(self::Test_Net);
+    }
+
+    static function mainNet()
+    {
+        return new self(Config::get('blockchain.bsc.node', self::Main_Net));
+    }
+
+    function getBalance($addr)
+    {
+        $cb = new Callback;
+        $this->getEth()->getBalance($addr, $cb);
+
+        return $cb->result;
+    }
+
+    function broadcast($rawtx)
+    {
+        $cb = new Callback;
+        $this->getEth()->sendRawTransaction($rawtx, $cb);
+
+        return $cb->result;
+    }
+
+    function getReceipt($txid)
+    {
+        $cb = new Callback;
+        $this->getEth()->getTransactionReceipt($txid, $cb);
+
+        return $cb->result;
+    }
+
+    function waitForConfirmation($txid, $timeout = 300)
+    {
+        $expire = time() + $timeout;
+        while (time() < $expire) {
+            try {
+                $receipt = $this->getReceipt($txid);
+                if (!is_null($receipt)) return $receipt;
+                sleep(2);
+            } catch (Exception $e) {
+            }
+        }
+        throw new Exception('tx not confirmed yet.');
+    }
+
+    function getBlockByNumber()
+    {
+        $cb = new Callback;
+        $number = hex(436);
+        $this->getEth()->getBlockByNumber($number, true, $cb);
+
+        return $cb->result;
+    }
+}

+ 185 - 0
qiniu/services/blockchain/bsc/SmartContract.php

@@ -0,0 +1,185 @@
+<?php
+
+namespace qiniu\services\blockchain\bsc;
+
+use Exception;
+use qiniu\services\blockchain\bsc\src\Contract;
+use qiniu\services\blockchain\bsc\src\Utils;
+
+class SmartContract extends Contract
+{
+    protected $web3;
+
+    //context
+    protected $gasPrice;
+    protected $gasLimit;
+    protected $value;
+    protected $credential;
+
+    protected $txMethods = [];
+    protected $viewMethods = [];
+    protected $eventSignatures = [];
+
+    public function __construct($web3, $credential, $abi)
+    {
+        parent::__construct($web3->provider, $abi);
+        $this->web3 = $web3;
+        $this->credential = $credential;
+        foreach ($this->events as $name => $event) {
+            $sig = $this->ethabi->encodeEventSignature($event);
+            $this->eventSignatures[$sig] = $event;
+        }
+        foreach ($this->functions as $function) {
+            if ($function['stateMutability'] == 'view') {
+                $this->viewMethods[] = $function['name'];
+            } else {
+                $this->txMethods[] = $function['name'];
+            }
+        }
+    }
+
+    public function setGasPrice($price)
+    {
+        if (!$price) {
+            unset($this->gasPrice);
+        } else {
+            $this->gasPrice = $price;
+        }
+        return $this;
+    }
+
+    public function setGasLimit($limit)
+    {
+        if (!$limit) {
+            unset($this->gasLimit);
+        } else {
+            $this->gasLimit = $limit;
+        }
+        return $this;
+    }
+
+    public function setValue($value)
+    {
+        if (!$value) {
+            unset($this->value);
+        } else {
+            $this->value = $value;
+        }
+        return $this;
+    }
+
+    public function setCredential($credential)
+    {
+        $this->credential = $credential;
+        return $this;
+    }
+
+    protected function transact($tx): string
+    {
+        if (!isset($this->credential)) {
+            throw new \Exception('credential not set');
+        }
+        $transactor = new Transactor($this->web3, $this->credential);
+        $tx['to'] = $this->getToAddress();
+        return $transactor->transact($tx);
+    }
+
+    protected function isTxMethod($name)
+    {
+        return in_array($name, $this->txMethods);
+    }
+
+    protected function isViewMethod($name)
+    {
+        return in_array($name, $this->viewMethods);
+    }
+
+    public function instantiate()
+    {
+        $args = func_get_args();
+
+        $data = $this->getData(...$args);
+        $tx = [
+            'data' => '0x' . $data
+        ];
+        return $this->transact($tx);
+    }
+
+    public function __call($name, $args)
+    {
+        if ($this->isTxMethod($name)) {
+            $data = $this->getData($name, ...$args);
+            $tx = [
+                'data' => '0x' . $data
+            ];
+            return $this->transact($tx);
+        }
+        if ($this->isViewMethod($name)) {
+            $cb = new Callback;
+            $args[] = $cb;
+            $this->call($name, ...$args);
+            $values = array_values($cb->result);
+            return count($values) > 1 ? $values : $values[0];
+        }
+        throw new Exception('method not supported');
+    }
+
+    public function queryEvents($topics = [], $fromBlock = 'latest', $toBlock = 'latest')
+    {
+        if (is_numeric($fromBlock)) {
+            $fromBlock = Utils::toHex($fromBlock, true);
+        }
+        if (is_numeric($toBlock)) {
+            $toBlock = Utils::toHex($toBlock, true);
+        }
+        $filter = [
+            'fromBlock' => $fromBlock,
+            'toBlock' => $toBlock,
+            'address' => $this->getToAddress(),
+            'topics' => $topics
+        ];
+        $cb = new Callback;
+        $this->web3->eth->getLogs($filter, $cb);
+        $decodedEvents = [];
+        foreach ($cb->result as $log) {
+            if (!array_key_exists($log->topics[0], $this->eventSignatures)) {
+                $msg = sprintf("unknown event: %s, skip", $log->topics[0]);
+                echo $msg . PHP_EOL;
+                continue;
+            }
+
+            $eventAbi = $this->eventSignatures[$log->topics[0]];
+
+            $types = [];
+            $names = [];
+            for ($i = 0; $i < count($eventAbi['inputs']); $i++) {
+                $types[] = $eventAbi['inputs'][$i]['type'];
+                $names[] = $eventAbi['inputs'][$i]['name'];
+            }
+            $params = '';
+            for ($i = 1; $i < count($log->topics); $i++) {
+                $params = $params . Utils::stripZero($log->topics[$i]);
+            }
+            $params = $params . Utils::stripZero($log->data);
+            //echo $eventAbi['name'] . ' => ' . $params . PHP_EOL;
+            $decodedParams = $this->ethabi->decodeParameters($types, $params);
+
+            $decodedEvent = (object)[
+                'blockHash' => $log->blockHash,
+                'blockNumber' => $log->blockNumber,
+                'transactionHash' => $log->transactionHash,
+                'removed' => $log->removed,
+                'address' => $log->address,
+                'name' => $eventAbi['name'],
+                'params' => []
+            ];
+            for ($i = 0; $i < count($names); $i++) {
+                $decodedEvent->params[$names[$i]] = $decodedParams[$i];
+            }
+            $decodedEvents[] = $decodedEvent;
+        }
+
+        return $decodedEvents;
+    }
+
+}

+ 132 - 0
qiniu/services/blockchain/bsc/Transactor.php

@@ -0,0 +1,132 @@
+<?php
+
+namespace qiniu\services\blockchain\bsc;
+
+use BI\BigInteger;
+use Exception;
+use qiniu\services\blockchain\bsc\src\Contract;
+use qiniu\services\blockchain\bsc\src\Utils;
+
+class Transactor
+{
+    protected $web3;
+
+    //context
+    protected $gasPrice;
+    protected $gasLimit;
+    protected $value;
+    protected $credential;
+
+    public function __construct($web3, $credential)
+    {
+        $this->web3 = $web3;
+        $this->credential = $credential;
+    }
+
+    public function setGasPrice($price = null)
+    {
+        $this->gasPrice = $price;
+        return $this;
+    }
+
+    public function setGasLimit($limit = null)
+    {
+        $this->gasLimit = $limit;
+        return $this;
+    }
+
+    public function setValue($value = null)
+    {
+        $this->value = $value;
+        return $this;
+    }
+
+    public function setCredential($credential)
+    {
+        $this->credential = $credential;
+        return $this;
+    }
+
+    protected function netVersion()
+    {
+        $cb = new Callback;
+        $this->web3->net->version($cb);
+        return $cb->result;
+    }
+
+    protected function getTransactionCount($address)
+    {
+        $cb = new Callback;
+        $this->web3->eth->getTransactionCount($address, 'pending', $cb);
+        return '0x' . $cb->result->toHex();
+    }
+
+    protected function estimateGasPrice()
+    {
+        $cb = new Callback;
+        $this->web3->eth->gasPrice($cb);
+        return '0x' . $cb->result->toHex();
+    }
+
+    protected function estimateGasUsage($tx)
+    {
+        //var_dump($tx);
+        $cb = new Callback;
+        $this->web3->eth->estimateGas($tx, $cb);
+        return '0x' . $cb->result->toHex();
+    }
+
+    public function transact($tx): string
+    {
+        if (!isset($this->credential)) {
+            throw new Exception('credential not set');
+        }
+
+        $from = $this->credential->getAddress();
+
+        $tx['from'] = $from;
+
+        if (!isset($tx['nonce'])) {
+            $tx['nonce'] = $this->getTransactionCount($from);
+        }
+
+        if (!isset($tx['chainId'])) {
+            $tx['chainId'] = $this->netVersion();
+        }
+
+        if (!isset($tx['value'])) {
+            if (isset($this->value)) {
+                $tx['value'] = $this->value;
+            } else {
+                $tx['value'] = '0x0';
+            }
+        }
+
+        if (!isset($tx['gasPrice'])) {
+            if (isset($this->gasPrice)) {
+                $tx['gasPrice'] = $this->gasPrice;
+            } else {
+                $tx['gasPrice'] = $this->estimateGasPrice();
+            }
+        }
+
+        if (!isset($tx['gasLimit'])) {
+            if (isset($this->gasLimit)) {
+                $tx['gasLimit'] = $this->gasLimit;
+            } else {
+                $originChainId = $tx['chainId'];
+                $tx['chainId'] = '0x' . (new BigInteger($originChainId))->toHex();
+                $tx['gasLimit'] = $this->estimateGasUsage($tx);
+                $tx['chainId'] = $originChainId;
+            }
+        }
+
+        $stx = $this->credential->signTransaction($tx);
+
+        $cb = new Callback;
+        $this->web3->eth->sendRawTransaction($stx, $cb);
+
+        return $cb->result;
+    }
+
+}

+ 14 - 0
qiniu/services/blockchain/bsc/helper.php

@@ -0,0 +1,14 @@
+<?php
+//gmp extension required
+
+function hex($str, $prefix = true)
+{
+    $bn = gmp_init($str);
+    $ret = gmp_strval($bn, 16);
+    return $prefix ? '0x' . $ret : $ret;
+}
+
+function bn($n)
+{
+    return new phpseclib\Math\BigInteger($n);
+}

+ 257 - 0
qiniu/services/blockchain/bsc/json/bep20.json

@@ -0,0 +1,257 @@
+[
+  {
+    "anonymous": false,
+    "inputs": [
+      {
+        "indexed": true,
+        "internalType": "address",
+        "name": "owner",
+        "type": "address"
+      },
+      {
+        "indexed": true,
+        "internalType": "address",
+        "name": "spender",
+        "type": "address"
+      },
+      {
+        "indexed": false,
+        "internalType": "uint256",
+        "name": "value",
+        "type": "uint256"
+      }
+    ],
+    "name": "Approval",
+    "type": "event"
+  },
+  {
+    "anonymous": false,
+    "inputs": [
+      {
+        "indexed": true,
+        "internalType": "address",
+        "name": "from",
+        "type": "address"
+      },
+      {
+        "indexed": true,
+        "internalType": "address",
+        "name": "to",
+        "type": "address"
+      },
+      {
+        "indexed": false,
+        "internalType": "uint256",
+        "name": "value",
+        "type": "uint256"
+      }
+    ],
+    "name": "Transfer",
+    "type": "event"
+  },
+  {
+    "constant": true,
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "_owner",
+        "type": "address"
+      },
+      {
+        "internalType": "address",
+        "name": "spender",
+        "type": "address"
+      }
+    ],
+    "name": "allowance",
+    "outputs": [
+      {
+        "internalType": "uint256",
+        "name": "",
+        "type": "uint256"
+      }
+    ],
+    "payable": false,
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "constant": false,
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "spender",
+        "type": "address"
+      },
+      {
+        "internalType": "uint256",
+        "name": "amount",
+        "type": "uint256"
+      }
+    ],
+    "name": "approve",
+    "outputs": [
+      {
+        "internalType": "bool",
+        "name": "",
+        "type": "bool"
+      }
+    ],
+    "payable": false,
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "constant": true,
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "account",
+        "type": "address"
+      }
+    ],
+    "name": "balanceOf",
+    "outputs": [
+      {
+        "internalType": "uint256",
+        "name": "",
+        "type": "uint256"
+      }
+    ],
+    "payable": false,
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "constant": true,
+    "inputs": [],
+    "name": "decimals",
+    "outputs": [
+      {
+        "internalType": "uint8",
+        "name": "",
+        "type": "uint8"
+      }
+    ],
+    "payable": false,
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "constant": true,
+    "inputs": [],
+    "name": "getOwner",
+    "outputs": [
+      {
+        "internalType": "address",
+        "name": "",
+        "type": "address"
+      }
+    ],
+    "payable": false,
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "constant": true,
+    "inputs": [],
+    "name": "name",
+    "outputs": [
+      {
+        "internalType": "string",
+        "name": "",
+        "type": "string"
+      }
+    ],
+    "payable": false,
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "constant": true,
+    "inputs": [],
+    "name": "symbol",
+    "outputs": [
+      {
+        "internalType": "string",
+        "name": "",
+        "type": "string"
+      }
+    ],
+    "payable": false,
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "constant": true,
+    "inputs": [],
+    "name": "totalSupply",
+    "outputs": [
+      {
+        "internalType": "uint256",
+        "name": "",
+        "type": "uint256"
+      }
+    ],
+    "payable": false,
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "constant": false,
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "recipient",
+        "type": "address"
+      },
+      {
+        "internalType": "uint256",
+        "name": "amount",
+        "type": "uint256"
+      }
+    ],
+    "name": "transfer",
+    "outputs": [
+      {
+        "internalType": "bool",
+        "name": "",
+        "type": "bool"
+      }
+    ],
+    "payable": false,
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "constant": false,
+    "inputs": [
+      {
+        "internalType": "address",
+        "name": "sender",
+        "type": "address"
+      },
+      {
+        "internalType": "address",
+        "name": "recipient",
+        "type": "address"
+      },
+      {
+        "internalType": "uint256",
+        "name": "amount",
+        "type": "uint256"
+      }
+    ],
+    "name": "transferFrom",
+    "outputs": [
+      {
+        "internalType": "bool",
+        "name": "",
+        "type": "bool"
+      }
+    ],
+    "payable": false,
+    "stateMutability": "nonpayable",
+    "type": "function"
+  }
+]

+ 636 - 0
qiniu/services/blockchain/bsc/src/Contract.php

@@ -0,0 +1,636 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ *
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ *
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Providers\Provider;
+use qiniu\services\blockchain\bsc\src\Providers\HttpProvider;
+use qiniu\services\blockchain\bsc\src\RequestManagers\RequestManager;
+use qiniu\services\blockchain\bsc\src\RequestManagers\HttpRequestManager;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Eth;
+use qiniu\services\blockchain\bsc\src\Contracts\Ethabi;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\Address;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\Boolean;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\Bytes;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\DynamicBytes;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\Integer;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\Str;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\Uinteger;
+use qiniu\services\blockchain\bsc\src\Validators\AddressValidator;
+use qiniu\services\blockchain\bsc\src\Validators\HexValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\AddressFormatter;
+use qiniu\services\blockchain\bsc\src\Validators\StringValidator;
+
+class Contract
+{
+    /**
+     * provider
+     *
+     * @var \qiniu\services\blockchain\bsc\src\Providers\Provider
+     */
+    protected $provider;
+
+    /**
+     * abi
+     *
+     * @var array
+     */
+    protected $abi;
+
+    /**
+     * constructor
+     *
+     * @var array
+     */
+    protected $constructor = [];
+
+    /**
+     * functions
+     *
+     * @var array
+     */
+    protected $functions = [];
+
+    /**
+     * events
+     *
+     * @var array
+     */
+    protected $events = [];
+
+    /**
+     * toAddress
+     *
+     * @var string
+     */
+    protected $toAddress;
+
+    /**
+     * bytecode
+     *
+     * @var string
+     */
+    protected $bytecode;
+
+    /**
+     * eth
+     *
+     * @var \qiniu\services\blockchain\bsc\src\Eth
+     */
+    protected $eth;
+
+    /**
+     * ethabi
+     *
+     * @var \qiniu\services\blockchain\bsc\src\Contracts\Ethabi
+     */
+    protected $ethabi;
+
+    /**
+     * construct
+     *
+     * @param string|\qiniu\services\blockchain\bsc\src\Providers\Provider $provider
+     * @param string|\stdClass|array $abi
+     * @return void
+     */
+    public function __construct($provider, $abi)
+    {
+        if (is_string($provider) && (filter_var($provider, FILTER_VALIDATE_URL) !== false)) {
+            // check the uri schema
+            if (preg_match('/^https?:\/\//', $provider) === 1) {
+                $requestManager = new HttpRequestManager($provider);
+
+                $this->provider = new HttpProvider($requestManager);
+            }
+        } else if ($provider instanceof Provider) {
+            $this->provider = $provider;
+        }
+        $abi = Utils::jsonToArray($abi, 5);
+
+        foreach ($abi as $item) {
+            if (isset($item['type'])) {
+                if ($item['type'] === 'function') {
+                    $this->functions[$item['name']] = $item;
+                } elseif ($item['type'] === 'constructor') {
+                    $this->constructor = $item;
+                } elseif ($item['type'] === 'event') {
+                    $this->events[$item['name']] = $item;
+                }
+            }
+        }
+        $this->abi = $abi;
+        $this->eth = new Eth($this->provider);
+        $this->ethabi = new Ethabi([
+            'address' => new Address,
+            'bool' => new Boolean,
+            'bytes' => new Bytes,
+            'dynamicBytes' => new DynamicBytes,
+            'int' => new Integer,
+            'string' => new Str,
+            'uint' => new Uinteger,
+        ]);
+    }
+
+    /**
+     * call
+     *
+     * @param string $name
+     * @param array $arguments
+     * @return void
+     */
+    // public function __call($name, $arguments)
+    // {
+    //     if (empty($this->provider)) {
+    //         throw new \RuntimeException('Please set provider first.');
+    //     }
+    //     $class = explode('\\', get_class());
+    //     if (preg_match('/^[a-zA-Z0-9]+$/', $name) === 1) {
+    //     }
+    // }
+
+    /**
+     * get
+     *
+     * @param string $name
+     * @return mixed
+     */
+    public function __get($name)
+    {
+        $method = 'get' . ucfirst($name);
+
+        if (method_exists($this, $method)) {
+            return call_user_func_array([$this, $method], []);
+        }
+        return false;
+    }
+
+    /**
+     * set
+     *
+     * @param string $name
+     * @param mixed $value
+     * @return mixed
+     */
+    public function __set($name, $value)
+    {
+        $method = 'set' . ucfirst($name);
+
+        if (method_exists($this, $method)) {
+            return call_user_func_array([$this, $method], [$value]);
+        }
+        return false;
+    }
+
+    /**
+     * getProvider
+     *
+     * @return \qiniu\services\blockchain\bsc\src\Providers\Provider
+     */
+    public function getProvider()
+    {
+        return $this->provider;
+    }
+
+    /**
+     * setProvider
+     *
+     * @param \qiniu\services\blockchain\bsc\src\Providers\Provider $provider
+     * @return $this
+     */
+    public function setProvider($provider)
+    {
+        if ($provider instanceof Provider) {
+            $this->provider = $provider;
+        }
+        return $this;
+    }
+
+    /**
+     * getFunctions
+     *
+     * @return array
+     */
+    public function getFunctions()
+    {
+        return $this->functions;
+    }
+
+    /**
+     * getEvents
+     *
+     * @return array
+     */
+    public function getEvents()
+    {
+        return $this->events;
+    }
+
+    /**
+     * @return string
+     */
+    public function getToAddress()
+    {
+        return $this->toAddress;
+    }
+
+    /**
+     * getConstructor
+     *
+     * @return array
+     */
+    public function getConstructor()
+    {
+        return $this->constructor;
+    }
+
+    /**
+     * getAbi
+     *
+     * @return array
+     */
+    public function getAbi()
+    {
+        return $this->abi;
+    }
+
+    /**
+     * setAbi
+     *
+     * @param string $abi
+     * @return $this
+     */
+    public function setAbi($abi)
+    {
+        return $this->abi($abi);
+    }
+
+    /**
+     * getEthabi
+     *
+     * @return array
+     */
+    public function getEthabi()
+    {
+        return $this->ethabi;
+    }
+
+    /**
+     * getEth
+     *
+     * @return \qiniu\services\blockchain\bsc\src\Eth
+     */
+    public function getEth()
+    {
+        return $this->eth;
+    }
+
+    /**
+     * setBytecode
+     *
+     * @param string $bytecode
+     * @return $this
+     */
+    public function setBytecode($bytecode)
+    {
+        return $this->bytecode($bytecode);
+    }
+
+    /**
+     * setToAddress
+     *
+     * @param string $bytecode
+     * @return $this
+     */
+    public function setToAddress($address)
+    {
+        return $this->at($address);
+    }
+
+    /**
+     * at
+     *
+     * @param string $address
+     * @return $this
+     */
+    public function at($address)
+    {
+        if (AddressValidator::validate($address) === false) {
+            throw new InvalidArgumentException('Please make sure address is valid.');
+        }
+        $this->toAddress = AddressFormatter::format($address);
+
+        return $this;
+    }
+
+    /**
+     * bytecode
+     *
+     * @param string $bytecode
+     * @return $this
+     */
+    public function bytecode($bytecode)
+    {
+        if (HexValidator::validate($bytecode) === false) {
+            throw new InvalidArgumentException('Please make sure bytecode is valid.');
+        }
+        $this->bytecode = Utils::stripZero($bytecode);
+
+        return $this;
+    }
+
+    /**
+     * abi
+     *
+     * @param string $abi
+     * @return $this
+     */
+    public function abi($abi)
+    {
+        if (StringValidator::validate($abi) === false) {
+            throw new InvalidArgumentException('Please make sure abi is valid.');
+        }
+        $abi = Utils::jsonToArray($abi, 5);
+
+        foreach ($abi as $item) {
+            if (isset($item['type'])) {
+                if ($item['type'] === 'function') {
+                    $this->functions[$item['name']] = $item;
+                } elseif ($item['type'] === 'constructor') {
+                    $this->constructor = $item;
+                } elseif ($item['type'] === 'event') {
+                    $this->events[$item['name']] = $item;
+                }
+            }
+        }
+        $this->abi = $abi;
+
+        return $this;
+    }
+
+    /**
+     * new
+     * Deploy a contruct with params.
+     *
+     * @param mixed
+     * @return void
+     */
+    public function new()
+    {
+        if (isset($this->constructor)) {
+            $constructor = $this->constructor;
+            $arguments = func_get_args();
+            $callback = array_pop($arguments);
+
+            if (count($arguments) < count($constructor['inputs'])) {
+                throw new InvalidArgumentException('Please make sure you have put all constructor params and callback.');
+            }
+            if (is_callable($callback) !== true) {
+                throw new \InvalidArgumentException('The last param must be callback function.');
+            }
+            if (!isset($this->bytecode)) {
+                throw new \InvalidArgumentException('Please call bytecode($bytecode) before new().');
+            }
+            $params = array_splice($arguments, 0, count($constructor['inputs']));
+            $data = $this->ethabi->encodeParameters($constructor, $params);
+            $transaction = [];
+
+            if (count($arguments) > 0) {
+                $transaction = $arguments[0];
+            }
+            $transaction['data'] = '0x' . $this->bytecode . Utils::stripZero($data);
+
+            $this->eth->sendTransaction($transaction, function ($err, $transaction) use ($callback) {
+                if ($err !== null) {
+                    return call_user_func($callback, $err, null);
+                }
+                return call_user_func($callback, null, $transaction);
+            });
+        }
+    }
+
+    /**
+     * send
+     * Send function method.
+     *
+     * @param mixed
+     * @return void
+     */
+    public function send()
+    {
+        if (isset($this->functions)) {
+            $arguments = func_get_args();
+            $method = array_splice($arguments, 0, 1)[0];
+            $callback = array_pop($arguments);
+
+            if (!is_string($method) || !isset($this->functions[$method])) {
+                throw new InvalidArgumentException('Please make sure the method exists.');
+            }
+            $function = $this->functions[$method];
+
+            if (count($arguments) < count($function['inputs'])) {
+                throw new InvalidArgumentException('Please make sure you have put all function params and callback.');
+            }
+            if (is_callable($callback) !== true) {
+                throw new \InvalidArgumentException('The last param must be callback function.');
+            }
+            $params = array_splice($arguments, 0, count($function['inputs']));
+            $data = $this->ethabi->encodeParameters($function, $params);
+            $functionName = Utils::jsonMethodToString($function);
+            $functionSignature = $this->ethabi->encodeFunctionSignature($functionName);
+            $transaction = [];
+
+            if (count($arguments) > 0) {
+                $transaction = $arguments[0];
+            }
+            $transaction['to'] = $this->toAddress;
+            $transaction['data'] = $functionSignature . Utils::stripZero($data);
+
+            $this->eth->sendTransaction($transaction, function ($err, $transaction) use ($callback) {
+                if ($err !== null) {
+                    return call_user_func($callback, $err, null);
+                }
+                return call_user_func($callback, null, $transaction);
+            });
+        }
+    }
+
+    /**
+     * call
+     * Call function method.
+     *
+     * @param mixed
+     * @return void
+     */
+    public function call()
+    {
+        if (isset($this->functions)) {
+            $arguments = func_get_args();
+            $method = array_splice($arguments, 0, 1)[0];
+            $callback = array_pop($arguments);
+
+            if (!is_string($method) || !isset($this->functions[$method])) {
+                throw new InvalidArgumentException('Please make sure the method exists.');
+            }
+            $function = $this->functions[$method];
+
+            if (count($arguments) < count($function['inputs'])) {
+                throw new InvalidArgumentException('Please make sure you have put all function params and callback.');
+            }
+            if (is_callable($callback) !== true) {
+                throw new \InvalidArgumentException('The last param must be callback function.');
+            }
+            $params = array_splice($arguments, 0, count($function['inputs']));
+            $data = $this->ethabi->encodeParameters($function, $params);
+            $functionName = Utils::jsonMethodToString($function);
+            $functionSignature = $this->ethabi->encodeFunctionSignature($functionName);
+            $transaction = [];
+
+            if (count($arguments) > 0) {
+                $transaction = $arguments[0];
+            }
+            $transaction['to'] = $this->toAddress;
+            $transaction['data'] = $functionSignature . Utils::stripZero($data);
+
+            $this->eth->call($transaction, function ($err, $transaction) use ($callback, $function) {
+                if ($err !== null) {
+                    return call_user_func($callback, $err, null);
+                }
+                $decodedTransaction = $this->ethabi->decodeParameters($function, $transaction);
+
+                return call_user_func($callback, null, $decodedTransaction);
+            });
+        }
+    }
+
+    /**
+     * estimateGas
+     * Estimate function gas.
+     *
+     * @param mixed
+     * @return void
+     */
+    public function estimateGas()
+    {
+        if (isset($this->functions) || isset($this->constructor)) {
+            $arguments = func_get_args();
+            $callback = array_pop($arguments);
+
+            if (empty($this->toAddress) && !empty($this->bytecode)) {
+                $constructor = $this->constructor;
+
+                if (count($arguments) < count($constructor['inputs'])) {
+                    throw new InvalidArgumentException('Please make sure you have put all constructor params and callback.');
+                }
+                if (is_callable($callback) !== true) {
+                    throw new \InvalidArgumentException('The last param must be callback function.');
+                }
+                if (!isset($this->bytecode)) {
+                    throw new \InvalidArgumentException('Please call bytecode($bytecode) before estimateGas().');
+                }
+                $params = array_splice($arguments, 0, count($constructor['inputs']));
+                $data = $this->ethabi->encodeParameters($constructor, $params);
+                $transaction = [];
+
+                if (count($arguments) > 0) {
+                    $transaction = $arguments[0];
+                }
+                $transaction['to'] = '';
+                $transaction['data'] = '0x' . $this->bytecode . Utils::stripZero($data);
+            } else {
+                $method = array_splice($arguments, 0, 1)[0];
+                $from = array_splice($arguments, 0, 1)[0];
+
+                if (!is_string($method) && !isset($this->functions[$method])) {
+                    throw new InvalidArgumentException('Please make sure the method is existed.');
+                }
+                $function = $this->functions[$method];
+
+                if (count($arguments) < count($function['inputs'])) {
+                    throw new InvalidArgumentException('Please make sure you have put all function params and callback.');
+                }
+                if (is_callable($callback) !== true) {
+                    throw new \InvalidArgumentException('The last param must be callback function.');
+                }
+                $params = array_splice($arguments, 0, count($function['inputs']));
+                $data = $this->ethabi->encodeParameters($function, $params);
+                $functionName = Utils::jsonMethodToString($function);
+                $functionSignature = $this->ethabi->encodeFunctionSignature($functionName);
+                $transaction = [];
+
+                if (count($arguments) > 0) {
+                    $transaction = $arguments[0];
+                }
+                $transaction['from'] = $from;
+                $transaction['to'] = $this->toAddress;
+                $transaction['data'] = $functionSignature . Utils::stripZero($data);
+            }
+
+            $this->eth->estimateGas($transaction, function ($err, $gas) use ($callback) {
+                if ($err !== null) {
+                    return call_user_func($callback, $err, null);
+                }
+                return call_user_func($callback, null, $gas);
+            });
+        }
+    }
+
+    /**
+     * getData
+     * Get the function method call data.
+     * With this function, you can send signed contract function transaction.
+     * 1. Get the funtion data with params.
+     * 2. Sign the data with user private key.
+     * 3. Call sendRawTransaction.
+     *
+     * @param mixed
+     * @return void
+     */
+    public function getData()
+    {
+        if (isset($this->functions) || isset($this->constructor)) {
+            $arguments = func_get_args();
+            $functionData = '';
+
+            if (empty($this->toAddress) && !empty($this->bytecode)) {
+                $constructor = $this->constructor;
+
+                if (count($arguments) < count($constructor['inputs'])) {
+                    throw new InvalidArgumentException('Please make sure you have put all constructor params and callback.');
+                }
+                if (!isset($this->bytecode)) {
+                    throw new \InvalidArgumentException('Please call bytecode($bytecode) before getData().');
+                }
+                $params = array_splice($arguments, 0, count($constructor['inputs']));
+                $data = $this->ethabi->encodeParameters($constructor, $params);
+                $functionData = $this->bytecode . Utils::stripZero($data);
+            } else {
+                $method = array_splice($arguments, 0, 1)[0];
+
+                if (!is_string($method) && !isset($this->functions[$method])) {
+                    throw new InvalidArgumentException('Please make sure the method is existed.');
+                }
+                $function = $this->functions[$method];
+
+                if (count($arguments) < count($function['inputs'])) {
+                    throw new InvalidArgumentException('Please make sure you have put all function params and callback.');
+                }
+                $params = array_splice($arguments, 0, count($function['inputs']));
+                $data = $this->ethabi->encodeParameters($function, $params);
+                $functionName = Utils::jsonMethodToString($function);
+                $functionSignature = $this->ethabi->encodeFunctionSignature($functionName);
+                $functionData = Utils::stripZero($functionSignature) . Utils::stripZero($data);
+            }
+            return $functionData;
+        }
+    }
+}

+ 399 - 0
qiniu/services/blockchain/bsc/src/Contracts/Ethabi.php

@@ -0,0 +1,399 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Contracts;
+
+use InvalidArgumentException;
+use stdClass;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IntegerFormatter;
+
+class Ethabi
+{
+    /**
+     * types
+     * 
+     * @var array
+     */
+    protected $types = [];
+
+    /**
+     * construct
+     * 
+     * @param array $types
+     * @return void
+     */
+    public function __construct($types=[])
+    {
+        if (!is_array($types)) {
+            $types = [];
+        }
+        $this->types = $types;
+    }
+
+    /**
+     * get
+     * 
+     * @param string $name
+     * @return mixed
+     */
+    public function __get($name)
+    {
+        $method = 'get' . ucfirst($name);
+
+        if (method_exists($this, $method)) {
+            return call_user_func_array([$this, $method], []);
+        }
+        return false;
+    }
+
+    /**
+     * set
+     * 
+     * @param string $name
+     * @param mixed $value
+     * @return mixed
+     */
+    public function __set($name, $value)
+    {
+        $method = 'set' . ucfirst($name);
+
+        if (method_exists($this, $method)) {
+            return call_user_func_array([$this, $method], [$value]);
+        }
+        return false;
+    }
+
+    /**
+     * callStatic
+     * 
+     * @param string $name
+     * @param array $arguments
+     * @return void
+     */
+    public static function __callStatic($name, $arguments)
+    {
+        // 
+    }
+
+    /**
+     * encodeFunctionSignature
+     * 
+     * @param string|stdClass|array $functionName
+     * @return string
+     */
+    public function encodeFunctionSignature($functionName)
+    {
+        if (!is_string($functionName)) {
+            $functionName = Utils::jsonMethodToString($functionName);
+        }
+        return mb_substr(Utils::sha3($functionName), 0, 10);
+    }
+
+    /**
+     * encodeEventSignature
+     * 
+     * @param string|stdClass|array $functionName
+     * @return string
+     */
+    public function encodeEventSignature($functionName)
+    {
+        if (!is_string($functionName)) {
+            $functionName = Utils::jsonMethodToString($functionName);
+        }
+        return Utils::sha3($functionName);
+    }
+
+    /**
+     * encodeParameter
+     * 
+     * @param string $type
+     * @param mixed $param
+     * @return string
+     */
+    public function encodeParameter($type, $param)
+    {
+        if (!is_string($type)) {
+            throw new InvalidArgumentException('The type to encodeParameter must be string.');
+        }
+        return $this->encodeParameters([$type], [$param]);
+    }
+
+    /**
+     * encodeParameters
+     * 
+     * @param stdClass|array $types
+     * @param array $params
+     * @return string
+     */
+    public function encodeParameters($types, $params)
+    {
+        // change json to array
+        if ($types instanceof stdClass && isset($types->inputs)) {
+            $types = Utils::jsonToArray($types, 2);
+        }
+        if (is_array($types) && isset($types['inputs'])) {
+            $inputTypes = $types;
+            $types = [];
+
+            foreach ($inputTypes['inputs'] as $input) {
+                if (isset($input['type'])) {
+                    $types[] = $input['type'];
+                }
+            }
+        }
+        if (count($types) !== count($params)) {
+            throw new InvalidArgumentException('encodeParameters number of types must equal to number of params.');
+        }
+        $typesLength = count($types);
+        $solidityTypes = $this->getSolidityTypes($types);
+
+        foreach ($types as $key => $type) {
+            $match = [];
+
+            if (preg_match('/^([a-zA-Z]+)/', $type, $match) === 1) {
+                if (isset($this->types[$match[0]])) {
+                    $className = $this->types[$match[0]];
+
+                    if (call_user_func([$this->types[$match[0]], 'isType'], $type) === false) {
+                        throw new InvalidArgumentException('Unsupport solidity parameter type: ' . $type);
+                    }
+                    $solidityTypes[$key] = $className;
+                }
+            }
+        }
+        $encodes = array_fill(0, $typesLength, '');
+
+        foreach ($solidityTypes as $key => $type) {
+            $encodes[$key] = call_user_func([$type, 'encode'], $params[$key], $types[$key]);
+        }
+        $dynamicOffset = 0;
+
+        foreach ($solidityTypes as $key => $type) {
+            $staticPartLength = $type->staticPartLength($types[$key]);
+            $roundedStaticPartLength = floor(($staticPartLength + 31) / 32) * 32;
+
+            if ($type->isDynamicType($types[$key]) || $type->isDynamicArray($types[$key])) {
+                $dynamicOffset += 32;
+            } else {
+                $dynamicOffset += $roundedStaticPartLength;
+            }
+        }
+        return '0x' . $this->encodeMultiWithOffset($types, $solidityTypes, $encodes, $dynamicOffset);
+    }
+
+    /**
+     * decodeParameter
+     * 
+     * @param string $type
+     * @param mixed $param
+     * @return string
+     */
+    public function decodeParameter($type, $param)
+    {
+        if (!is_string($type)) {
+            throw new InvalidArgumentException('The type to decodeParameter must be string.');
+        }
+        return $this->decodeParameters([$type], $param)[0];
+    }
+
+    /**
+     * decodeParameters
+     * 
+     * @param stdClass|array $type
+     * @param string $param
+     * @return string
+     */
+    public function decodeParameters($types, $param)
+    {
+        if (!is_string($param)) {
+            throw new InvalidArgumentException('The type or param to decodeParameters must be string.');
+        }
+
+        // change json to array
+        if ($types instanceof stdClass && isset($types->outputs)) {
+            $types = Utils::jsonToArray($types, 2);
+        }
+        if (is_array($types) && isset($types['outputs'])) {
+            $outputTypes = $types;
+            $types = [];
+
+            foreach ($outputTypes['outputs'] as $output) {
+                if (isset($output['type'])) {
+                    $types[] = $output['type'];
+                }
+            }
+        }
+        $typesLength = count($types);
+        $solidityTypes = $this->getSolidityTypes($types);
+        $offsets = array_fill(0, $typesLength, 0);
+
+        for ($i=0; $i<$typesLength; $i++) {
+            $offsets[$i] = $solidityTypes[$i]->staticPartLength($types[$i]);
+        }
+        for ($i=1; $i<$typesLength; $i++) {
+            $offsets[$i] += $offsets[$i - 1];
+        }
+        for ($i=0; $i<$typesLength; $i++) {
+            $offsets[$i] -= $solidityTypes[$i]->staticPartLength($types[$i]);
+        }
+        $result = [];
+        $param = mb_strtolower(Utils::stripZero($param));
+
+        for ($i=0; $i<$typesLength; $i++) {
+            if (isset($outputTypes['outputs'][$i]['name']) && empty($outputTypes['outputs'][$i]['name']) === false) {
+                $result[$outputTypes['outputs'][$i]['name']] = $solidityTypes[$i]->decode($param, $offsets[$i], $types[$i]);
+            } else {
+                $result[$i] = $solidityTypes[$i]->decode($param, $offsets[$i], $types[$i]);
+            }
+        }
+
+        return $result;
+    }
+
+    /**
+     * getSolidityTypes
+     * 
+     * @param array $types
+     * @return array
+     */
+    protected function getSolidityTypes($types)
+    {
+        if (!is_array($types)) {
+            throw new InvalidArgumentException('Types must be array');
+        }
+        $solidityTypes = array_fill(0, count($types), 0);
+
+        foreach ($types as $key => $type) {
+            $match = [];
+
+            if (preg_match('/^([a-zA-Z]+)/', $type, $match) === 1) {
+                if (isset($this->types[$match[0]])) {
+                    $className = $this->types[$match[0]];
+
+                    if (call_user_func([$this->types[$match[0]], 'isType'], $type) === false) {
+                        // check dynamic bytes
+                        if ($match[0] === 'bytes') {
+                            $className = $this->types['dynamicBytes'];
+                        } else {
+                            throw new InvalidArgumentException('Unsupport solidity parameter type: ' . $type);
+                        }
+                    }
+                    $solidityTypes[$key] = $className;
+                }
+            }
+        }
+        return $solidityTypes;
+    }
+
+    /**
+     * encodeWithOffset
+     * 
+     * @param string $type
+     * @param \qiniu\services\blockchain\bsc\src\Contracts\SolidityType $solidityType
+     * @param mixed $encode
+     * @param int $offset
+     * @return string
+     */
+    protected function encodeWithOffset($type, $solidityType, $encoded, $offset)
+    {
+        if ($solidityType->isDynamicArray($type)) {
+            $nestedName = $solidityType->nestedName($type);
+            $nestedStaticPartLength = $solidityType->staticPartLength($type);
+            $result = $encoded[0];
+
+            if ($solidityType->isDynamicArray($nestedName)) {
+                $previousLength = 2;
+
+                for ($i=0; $i<count($encoded); $i++) {
+                    if (isset($encoded[$i - 1])) {
+                        $previousLength += abs($encoded[$i - 1][0]);
+                    }
+                    $result .= IntegerFormatter::format($offset + $i * $nestedStaticPartLength + $previousLength * 32);
+                }
+            }
+            for ($i=0; $i<count($encoded); $i++) {
+                // $bn = Utils::toBn($result);
+                // $divided = $bn->divide(Utils::toBn(2));
+
+                // if (is_array($divided)) {
+                //     $additionalOffset = (int) $divided[0]->toString();
+                // } else {
+                //     $additionalOffset = 0;
+                // }
+                $additionalOffset = floor(mb_strlen($result) / 2);
+                $result .= $this->encodeWithOffset($nestedName, $solidityType, $encoded[$i], $offset + $additionalOffset);
+            }
+            return mb_substr($result, 64);
+        } elseif ($solidityType->isStaticArray($type)) {
+            $nestedName = $solidityType->nestedName($type);
+            $nestedStaticPartLength = $solidityType->staticPartLength($type);
+            $result = '';
+
+            if ($solidityType->isDynamicArray($nestedName)) {
+                $previousLength = 0;
+
+                for ($i=0; $i<count($encoded); $i++) {
+                    if (isset($encoded[$i - 1])) {
+                        $previousLength += abs($encoded[$i - 1])[0];
+                    }
+                    $result .= IntegerFormatter::format($offset + $i * $nestedStaticPartLength + $previousLength * 32);
+                }
+            }
+            for ($i=0; $i<count($encoded); $i++) {
+                // $bn = Utils::toBn($result);
+                // $divided = $bn->divide(Utils::toBn(2));
+
+                // if (is_array($divided)) {
+                //     $additionalOffset = (int) $divided[0]->toString();
+                // } else {
+                //     $additionalOffset = 0;
+                // }
+                $additionalOffset = floor(mb_strlen($result) / 2);
+                $result .= $this->encodeWithOffset($nestedName, $solidityType, $encoded[$i], $offset + $additionalOffset);
+            }
+            return $result;
+        }
+        return $encoded;
+    }
+
+    /**
+     * encodeMultiWithOffset
+     * 
+     * @param array $types
+     * @param array $solidityTypes
+     * @param array $encodes
+     * @param int $dynamicOffset
+     * @return string
+     */
+    protected function encodeMultiWithOffset($types, $solidityTypes, $encodes, $dynamicOffset)
+    {
+        $result = '';
+
+        foreach ($solidityTypes as $key => $type) {
+            if ($type->isDynamicType($types[$key]) || $type->isDynamicArray($types[$key])) {
+                $result .= IntegerFormatter::format($dynamicOffset);
+                $e = $this->encodeWithOffset($types[$key], $type, $encodes[$key], $dynamicOffset);
+                $dynamicOffset += floor(mb_strlen($e) / 2);
+            } else {
+                $result .= $this->encodeWithOffset($types[$key], $type, $encodes[$key], $dynamicOffset);
+            }
+        }
+        foreach ($solidityTypes as $key => $type) {
+            if ($type->isDynamicType($types[$key]) || $type->isDynamicArray($types[$key])) {
+                $e = $this->encodeWithOffset($types[$key], $type, $encodes[$key], $dynamicOffset);
+                // $dynamicOffset += floor(mb_strlen($e) / 2);
+                $result .= $e;
+            }
+        }
+        return $result;
+    }
+}

+ 273 - 0
qiniu/services/blockchain/bsc/src/Contracts/SolidityType.php

@@ -0,0 +1,273 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Contracts;
+
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IntegerFormatter;
+
+class SolidityType
+{
+    /**
+     * construct
+     * 
+     * @return void
+     */
+    // public function  __construct() {}
+
+    /**
+     * get
+     * 
+     * @param string $name
+     * @return mixed
+     */
+    public function __get($name)
+    {
+        $method = 'get' . ucfirst($name);
+
+        if (method_exists($this, $method)) {
+            return call_user_func_array([$this, $method], []);
+        }
+        return false;
+    }
+
+    /**
+     * set
+     * 
+     * @param string $name
+     * @param mixed $value
+     * @return mixed;
+     */
+    public function __set($name, $value)
+    {
+        $method = 'set' . ucfirst($name);
+
+        if (method_exists($this, $method)) {
+            return call_user_func_array([$this, $method], [$value]);
+        }
+        return false;
+    }
+
+    /**
+     * callStatic
+     * 
+     * @param string $name
+     * @param array $arguments
+     * @return void
+     */
+    // public static function __callStatic($name, $arguments) {}
+
+    /**
+     * nestedTypes
+     * 
+     * @param string $name
+     * @return mixed
+     */
+    public function nestedTypes($name)
+    {
+        if (!is_string($name)) {
+            throw new InvalidArgumentException('nestedTypes name must string.');
+        }
+        $matches = [];
+
+        if (preg_match_all('/(\[[0-9]*\])/', $name, $matches, PREG_PATTERN_ORDER) >= 1) {
+            return $matches[0];
+        }
+        return false;
+    }
+
+    /**
+     * nestedName
+     * 
+     * @param string $name
+     * @return string
+     */
+    public function nestedName($name)
+    {
+        if (!is_string($name)) {
+            throw new InvalidArgumentException('nestedName name must string.');
+        }
+        $nestedTypes = $this->nestedTypes($name);
+
+        if ($nestedTypes === false) {
+            return $name;
+        }
+        return mb_substr($name, 0, mb_strlen($name) - mb_strlen($nestedTypes[count($nestedTypes) - 1]));
+    }
+
+    /**
+     * isDynamicArray
+     * 
+     * @param string $name
+     * @return bool
+     */
+    public function isDynamicArray($name)
+    {
+        $nestedTypes = $this->nestedTypes($name);
+
+        return $nestedTypes && preg_match('/[0-9]{1,}/', $nestedTypes[count($nestedTypes) - 1]) !== 1;
+    }
+
+    /**
+     * isStaticArray
+     * 
+     * @param string $name
+     * @return bool
+     */
+    public function isStaticArray($name)
+    {
+        $nestedTypes = $this->nestedTypes($name);
+
+        return $nestedTypes && preg_match('/[0-9]{1,}/', $nestedTypes[count($nestedTypes) - 1]) === 1;
+    }
+
+    /**
+     * staticArrayLength
+     * 
+     * @param string $name
+     * @return int
+     */
+    public function staticArrayLength($name)
+    {
+        $nestedTypes = $this->nestedTypes($name);
+
+        if ($nestedTypes === false) {
+            return 1;
+        }
+        $match = [];
+
+        if (preg_match('/[0-9]{1,}/', $nestedTypes[count($nestedTypes) - 1], $match) === 1) {
+            return (int) $match[0];
+        }
+        return 1;
+    }
+
+    /**
+     * staticPartLength
+     * 
+     * @param string $name
+     * @return int
+     */
+    public function staticPartLength($name)
+    {
+        $nestedTypes = $this->nestedTypes($name);
+
+        if ($nestedTypes === false) {
+            $nestedTypes = ['[1]'];
+        }
+        $count = 32;
+
+        foreach ($nestedTypes as $type) {
+            $num = mb_substr($type, 1, 1);
+
+            if (!is_numeric($num)) {
+                $num = 1;
+            } else {
+                $num = intval($num);
+            }
+            $count *= $num;
+        }
+
+        return $count;
+    }
+
+    /**
+     * isDynamicType
+     * 
+     * @return bool
+     */
+    public function isDynamicType()
+    {
+        return false;
+    }
+
+    /**
+     * encode
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function encode($value, $name)
+    {
+        if ($this->isDynamicArray($name)) {
+            $length = count($value);
+            $nestedName = $this->nestedName($name);
+            $result = [];
+            $result[] = IntegerFormatter::format($length);
+
+            foreach ($value as $val) {
+                $result[] = $this->encode($val, $nestedName);
+            }
+            return $result;
+        } elseif ($this->isStaticArray($name)) {
+            $length = $this->staticArrayLength($name);
+            $nestedName = $this->nestedName($name);
+            $result = [];
+
+            foreach ($value as $val) {
+                $result[] = $this->encode($val, $nestedName);
+            }
+            return $result;
+        }
+        return $this->inputFormat($value, $name);
+    }
+
+    /**
+     * decode
+     * 
+     * @param mixed $value
+     * @param string $offset
+     * @param string $name
+     * @return array
+     */
+    public function decode($value, $offset, $name)
+    {
+        if ($this->isDynamicArray($name)) {
+            $arrayOffset = (int) Utils::toBn('0x' . mb_substr($value, $offset * 2, 64))->toString();
+            $length = (int) Utils::toBn('0x' . mb_substr($value, $arrayOffset * 2, 64))->toString();
+            $arrayStart = $arrayOffset + 32;
+
+            $nestedName = $this->nestedName($name);
+            $nestedStaticPartLength = $this->staticPartLength($nestedName);
+            $roundedNestedStaticPartLength = floor(($nestedStaticPartLength + 31) / 32) * 32;
+            $result = [];
+
+            for ($i=0; $i<$length * $roundedNestedStaticPartLength; $i+=$roundedNestedStaticPartLength) {
+                $result[] = $this->decode($value, $arrayStart + $i, $nestedName);
+            }
+            return $result;
+        } elseif ($this->isStaticArray($name)) {
+            $length = $this->staticArrayLength($name);
+            $arrayStart = $offset;
+
+            $nestedName = $this->nestedName($name);
+            $nestedStaticPartLength = $this->staticPartLength($nestedName);
+            $roundedNestedStaticPartLength = floor(($nestedStaticPartLength + 31) / 32) * 32;
+            $result = [];
+
+            for ($i=0; $i<$length * $roundedNestedStaticPartLength; $i+=$roundedNestedStaticPartLength) {
+                $result[] = $this->decode($value, $arrayStart + $i, $nestedName);
+            }
+            return $result;
+        } elseif ($this->isDynamicType()) {
+            $dynamicOffset = (int) Utils::toBn('0x' . mb_substr($value, $offset * 2, 64))->toString();
+            $length = (int) Utils::toBn('0x' . mb_substr($value, $dynamicOffset * 2, 64))->toString();
+            $roundedLength = floor(($length + 31) / 32);
+            $param = mb_substr($value, $dynamicOffset * 2, ( 1 + $roundedLength) * 64);
+            return $this->outputFormat($param, $name);
+        }
+        $length = $this->staticPartLength($name);
+        $param = mb_substr($value, $offset * 2, $length * 2);
+
+        return $this->outputFormat($param, $name);
+    }
+}

+ 86 - 0
qiniu/services/blockchain/bsc/src/Contracts/Types/Address.php

@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Contracts\Types;
+
+use qiniu\services\blockchain\bsc\src\Contracts\SolidityType;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IntegerFormatter;
+
+class Address extends SolidityType implements IType
+{
+    /**
+     * construct
+     * 
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * isType
+     * 
+     * @param string $name
+     * @return bool
+     */
+    public function isType($name)
+    {
+        return (preg_match('/^address(\[([0-9]*)\])*$/', $name) === 1);
+    }
+
+    /**
+     * isDynamicType
+     * 
+     * @return bool
+     */
+    public function isDynamicType()
+    {
+        return false;
+    }
+
+    /**
+     * inputFormat
+     * to do: iban
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function inputFormat($value, $name)
+    {
+        $value = (string) $value;
+
+        if (Utils::isAddress($value)) {
+            $value = mb_strtolower($value);
+
+            if (Utils::isZeroPrefixed($value)) {
+                $value = Utils::stripZero($value);
+            }
+        }
+        $value = IntegerFormatter::format($value);
+
+        return $value;
+    }
+
+    /**
+     * outputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function outputFormat($value, $name)
+    {
+        return '0x' . mb_substr($value, 24, 40);
+    }
+}

+ 81 - 0
qiniu/services/blockchain/bsc/src/Contracts/Types/Boolean.php

@@ -0,0 +1,81 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Contracts\Types;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Contracts\SolidityType;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\IType;
+
+class Boolean extends SolidityType implements IType
+{
+    /**
+     * construct
+     * 
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * isType
+     * 
+     * @param string $name
+     * @return bool
+     */
+    public function isType($name)
+    {
+        return (preg_match('/^bool(\[([0-9]*)\])*$/', $name) === 1);
+    }
+
+    /**
+     * isDynamicType
+     * 
+     * @return bool
+     */
+    public function isDynamicType()
+    {
+        return false;
+    }
+
+    /**
+     * inputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function inputFormat($value, $name)
+    {
+        if (!is_bool($value)) {
+            throw new InvalidArgumentException('The value to inputFormat function must be boolean.');
+        }
+        $value = (int) $value;
+
+        return '000000000000000000000000000000000000000000000000000000000000000' . $value;
+    }
+
+    /**
+     * outputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function outputFormat($value, $name)
+    {
+        $value = (int) mb_substr($value, 63, 1);
+
+        return (bool) $value;
+    }
+}

+ 100 - 0
qiniu/services/blockchain/bsc/src/Contracts/Types/Bytes.php

@@ -0,0 +1,100 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Contracts\Types;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Contracts\SolidityType;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\IType;
+
+class Bytes extends SolidityType implements IType
+{
+    /**
+     * construct
+     * 
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * isType
+     * 
+     * @param string $name
+     * @return bool
+     */
+    public function isType($name)
+    {
+        return (preg_match('/^bytes([0-9]{1,})(\[([0-9]*)\])*$/', $name) === 1);
+    }
+
+    /**
+     * isDynamicType
+     * 
+     * @return bool
+     */
+    public function isDynamicType()
+    {
+        return false;
+    }
+
+    /**
+     * inputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function inputFormat($value, $name)
+    {
+        if (!Utils::isHex($value)) {
+            throw new InvalidArgumentException('The value to inputFormat must be hex bytes.');
+        }
+        $value = Utils::stripZero($value);
+
+        // if (mb_strlen($value) % 2 !== 0) {
+        //     throw new InvalidArgumentException('The value to inputFormat has invalid length. Value: ' . $value);
+        // }
+
+        if (mb_strlen($value) > 64) {
+            throw new InvalidArgumentException('The value to inputFormat is too long.');
+        }
+        $l = floor((mb_strlen($value) + 63) / 64);
+        $padding = (($l * 64 - mb_strlen($value) + 1) >= 0) ? $l * 64 - mb_strlen($value) : 0;
+
+        return $value . implode('', array_fill(0, $padding, '0'));
+    }
+
+    /**
+     * outputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function outputFormat($value, $name)
+    {
+        $checkZero = str_replace('0', '', $value);
+
+        if (empty($checkZero)) {
+            return '0';
+        }
+        if (preg_match('/^bytes([0-9]*)/', $name, $match) === 1) {
+            $size = intval($match[1]);
+            $length = 2 * $size;
+            $value = mb_substr($value, 0, $length);
+        }
+        return '0x' . $value;
+    }
+}

+ 97 - 0
qiniu/services/blockchain/bsc/src/Contracts/Types/DynamicBytes.php

@@ -0,0 +1,97 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Contracts\Types;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Contracts\SolidityType;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\IType;
+
+class DynamicBytes extends SolidityType implements IType
+{
+    /**
+     * construct
+     * 
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * isType
+     * 
+     * @param string $name
+     * @return bool
+     */
+    public function isType($name)
+    {
+        return (preg_match('/^bytes(\[([0-9]*)\])*$/', $name) === 1);
+    }
+
+    /**
+     * isDynamicType
+     * 
+     * @return bool
+     */
+    public function isDynamicType()
+    {
+        return true;
+    }
+
+    /**
+     * inputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function inputFormat($value, $name)
+    {
+        if (!Utils::isHex($value)) {
+            throw new InvalidArgumentException('The value to inputFormat must be hex bytes.');
+        }
+        $value = Utils::stripZero($value);
+
+        // if (mb_strlen($value) % 2 !== 0) {
+        //     throw new InvalidArgumentException('The value to inputFormat has invalid length.');
+        // }
+        $bn = Utils::toBn(mb_strlen($value) / 2);
+        $bnHex = $bn->toHex(true);
+        $padded = mb_substr($bnHex, 0, 1);
+        $l = floor((mb_strlen($value) + 63) / 64);
+        $padding = (($l * 64 - mb_strlen($value) + 1) >= 0) ? $l * 64 - mb_strlen($value) : 0;
+
+        return implode('', array_fill(0, 64-mb_strlen($bnHex), $padded)) . $bnHex . $value . implode('', array_fill(0, $padding, '0'));
+    }
+
+    /**
+     * outputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function outputFormat($value, $name)
+    {
+        $checkZero = str_replace('0', '', $value);
+
+        if (empty($checkZero)) {
+            return '0';
+        }
+        $size = intval(Utils::toBn(mb_substr($value, 0, 64))->toString());
+        $length = 2 * $size;
+        
+        return '0x' . mb_substr($value, 64, $length);
+    }
+}

+ 39 - 0
qiniu/services/blockchain/bsc/src/Contracts/Types/IType.php

@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Contracts\Types;
+
+interface IType
+{
+    /**
+     * isType
+     * 
+     * @param string $name
+     * @return bool
+     */
+    public function isType($name);
+
+    /**
+     * isDynamicType
+     * 
+     * @return bool
+     */
+    public function isDynamicType();
+
+    /**
+     * inputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function inputFormat($value, $name);
+}

+ 82 - 0
qiniu/services/blockchain/bsc/src/Contracts/Types/Integer.php

@@ -0,0 +1,82 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Contracts\Types;
+
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Contracts\SolidityType;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\IType;
+use qiniu\services\blockchain\bsc\src\Formatters\IntegerFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class Integer extends SolidityType implements IType
+{
+    /**
+     * construct
+     * 
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * isType
+     * 
+     * @param string $name
+     * @return bool
+     */
+    public function isType($name)
+    {
+        return (preg_match('/^int([0-9]{1,})?(\[([0-9]*)\])*$/', $name) === 1);
+    }
+
+    /**
+     * isDynamicType
+     * 
+     * @return bool
+     */
+    public function isDynamicType()
+    {
+        return false;
+    }
+
+    /**
+     * inputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function inputFormat($value, $name)
+    {
+        return IntegerFormatter::format($value);
+    }
+
+    /**
+     * outputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function outputFormat($value, $name)
+    {
+        $match = [];
+
+        if (preg_match('/^[0]+([a-f0-9]+)$/', $value, $match) === 1) {
+            // due to value without 0x prefix, we will parse as decimal
+            $value = '0x' . $match[1];
+        }
+        return BigNumberFormatter::format($value);
+    }
+}

+ 90 - 0
qiniu/services/blockchain/bsc/src/Contracts/Types/Str.php

@@ -0,0 +1,90 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Contracts\Types;
+
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Contracts\SolidityType;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\IType;
+use qiniu\services\blockchain\bsc\src\Formatters\IntegerFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class Str extends SolidityType implements IType
+{
+    /**
+     * construct
+     * 
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * isType
+     * 
+     * @param string $name
+     * @return bool
+     */
+    public function isType($name)
+    {
+        return (preg_match('/^string(\[([0-9]*)\])*$/', $name) === 1);
+    }
+
+    /**
+     * isDynamicType
+     * 
+     * @return bool
+     */
+    public function isDynamicType()
+    {
+        return true;
+    }
+
+    /**
+     * inputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function inputFormat($value, $name)
+    {
+        $value = Utils::toHex($value);
+        $prefix = IntegerFormatter::format(mb_strlen($value) / 2);
+        $l = floor((mb_strlen($value) + 63) / 64);
+        $padding = (($l * 64 - mb_strlen($value) + 1) >= 0) ? $l * 64 - mb_strlen($value) : 0;
+
+        return $prefix . $value . implode('', array_fill(0, $padding, '0'));
+    }
+
+    /**
+     * outputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function outputFormat($value, $name)
+    {
+        $strLen = mb_substr($value, 0, 64);
+        $strValue = mb_substr($value, 64);
+        $match = [];
+
+        if (preg_match('/^[0]+([a-f0-9]+)$/', $strLen, $match) === 1) {
+            $strLen = BigNumberFormatter::format('0x' . $match[1])->toString();
+        }
+        $strValue = mb_substr($strValue, 0, (int) $strLen * 2);
+
+        return Utils::hexToBin($strValue);
+    }
+}

+ 82 - 0
qiniu/services/blockchain/bsc/src/Contracts/Types/Uinteger.php

@@ -0,0 +1,82 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Contracts\Types;
+
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Contracts\SolidityType;
+use qiniu\services\blockchain\bsc\src\Contracts\Types\IType;
+use qiniu\services\blockchain\bsc\src\Formatters\IntegerFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class Uinteger extends SolidityType implements IType
+{
+    /**
+     * construct
+     * 
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * isType
+     * 
+     * @param string $name
+     * @return bool
+     */
+    public function isType($name)
+    {
+        return (preg_match('/^uint([0-9]{1,})?(\[([0-9]*)\])*$/', $name) === 1);
+    }
+
+    /**
+     * isDynamicType
+     * 
+     * @return bool
+     */
+    public function isDynamicType()
+    {
+        return false;
+    }
+
+    /**
+     * inputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function inputFormat($value, $name)
+    {
+        return IntegerFormatter::format($value);
+    }
+
+    /**
+     * outputFormat
+     * 
+     * @param mixed $value
+     * @param string $name
+     * @return string
+     */
+    public function outputFormat($value, $name)
+    {
+        $match = [];
+
+        if (preg_match('/^[0]+([a-f0-9]+)$/', $value, $match) === 1) {
+            // due to value without 0x prefix, we will parse as decimal
+            $value = '0x' . $match[1];
+        }
+        return BigNumberFormatter::format($value);
+    }
+}

+ 180 - 0
qiniu/services/blockchain/bsc/src/Eth.php

@@ -0,0 +1,180 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ *
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ *
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src;
+
+use qiniu\services\blockchain\bsc\src\Providers\Provider;
+use qiniu\services\blockchain\bsc\src\Providers\HttpProvider;
+use qiniu\services\blockchain\bsc\src\RequestManagers\RequestManager;
+use qiniu\services\blockchain\bsc\src\RequestManagers\HttpRequestManager;
+
+class Eth
+{
+    /**
+     * provider
+     *
+     * @var \qiniu\services\blockchain\bsc\src\Providers\Provider
+     */
+    protected $provider;
+
+    /**
+     * methods
+     *
+     * @var array
+     */
+    private $methods = [];
+
+    /**
+     * allowedMethods
+     *
+     * @var array
+     */
+    private $allowedMethods = [
+        'eth_protocolVersion', 'eth_syncing', 'eth_coinbase', 'eth_mining', 'eth_hashrate', 'eth_gasPrice', 'eth_accounts', 'eth_blockNumber', 'eth_getBalance', 'eth_getStorageAt', 'eth_getTransactionCount', 'eth_getBlockTransactionCountByHash', 'eth_getBlockTransactionCountByNumber', 'eth_getUncleCountByBlockHash', 'eth_getUncleCountByBlockNumber', 'eth_getUncleByBlockHashAndIndex', 'eth_getUncleByBlockNumberAndIndex', 'eth_getCode', 'eth_sign', 'eth_sendTransaction', 'eth_sendRawTransaction', 'eth_call', 'eth_estimateGas', 'eth_getBlockByHash', 'eth_getBlockByNumber', 'eth_getTransactionByHash', 'eth_getTransactionByBlockHashAndIndex', 'eth_getTransactionByBlockNumberAndIndex', 'eth_getTransactionReceipt', 'eth_getCompilers', 'eth_compileSolidity', 'eth_compileLLL', 'eth_compileSerpent', 'eth_getWork', 'eth_newFilter', 'eth_newBlockFilter', 'eth_newPendingTransactionFilter', 'eth_uninstallFilter', 'eth_getFilterChanges', 'eth_getFilterLogs', 'eth_getLogs', 'eth_submitWork', 'eth_submitHashrate'
+    ];
+
+    /**
+     * construct
+     *
+     * @param string|\qiniu\services\blockchain\bsc\src\Providers\Provider $provider
+     * @return void
+     */
+    public function __construct($provider)
+    {
+        if (is_string($provider) && (filter_var($provider, FILTER_VALIDATE_URL) !== false)) {
+            // check the uri schema
+            if (preg_match('/^https?:\/\//', $provider) === 1) {
+                $requestManager = new HttpRequestManager($provider);
+
+                $this->provider = new HttpProvider($requestManager);
+            }
+        } else if ($provider instanceof Provider) {
+            $this->provider = $provider;
+        }
+    }
+
+    /**
+     * call
+     *
+     * @param string $name
+     * @param array $arguments
+     * @return void
+     */
+    public function __call($name, $arguments)
+    {
+        if (empty($this->provider)) {
+            throw new \RuntimeException('Please set provider first.');
+        }
+
+        $class = explode('\\', get_class());
+
+        if (preg_match('/^[a-zA-Z0-9]+$/', $name) === 1) {
+            $method = strtolower($class[count($class) - 1]) . '_' . $name;
+
+            if (!in_array($method, $this->allowedMethods)) {
+                throw new \RuntimeException('Unallowed rpc method: ' . $method);
+            }
+            if ($this->provider->isBatch) {
+                $callback = null;
+            } else {
+                $callback = array_pop($arguments);
+
+                if (is_callable($callback) !== true) {
+                    throw new \InvalidArgumentException('The last param must be callback function.');
+                }
+            }
+            if (!array_key_exists($method, $this->methods)) {
+                // new the method
+                $methodClass = sprintf("\qiniu\services\blockchain\bsc\src\Methods\%s\%s", ucfirst($class[count($class) - 1]), ucfirst($name));
+                $methodObject = new $methodClass($method, $arguments);
+                $this->methods[$method] = $methodObject;
+            } else {
+                $methodObject = $this->methods[$method];
+            }
+            if ($methodObject->validate($arguments)) {
+                $inputs = $methodObject->transform($arguments, $methodObject->inputFormatters);
+                $methodObject->arguments = $inputs;
+                $this->provider->send($methodObject, $callback);
+            }
+        }
+    }
+
+    /**
+     * get
+     *
+     * @param string $name
+     * @return mixed
+     */
+    public function __get($name)
+    {
+        $method = 'get' . ucfirst($name);
+
+        if (method_exists($this, $method)) {
+            return call_user_func_array([$this, $method], []);
+        }
+        return false;
+    }
+
+    /**
+     * set
+     *
+     * @param string $name
+     * @param mixed $value
+     * @return mixed
+     */
+    public function __set($name, $value)
+    {
+        $method = 'set' . ucfirst($name);
+
+        if (method_exists($this, $method)) {
+            return call_user_func_array([$this, $method], [$value]);
+        }
+        return false;
+    }
+
+    /**
+     * getProvider
+     *
+     * @return \qiniu\services\blockchain\bsc\src\Providers\Provider
+     */
+    public function getProvider()
+    {
+        return $this->provider;
+    }
+
+    /**
+     * setProvider
+     *
+     * @param \qiniu\services\blockchain\bsc\src\Providers\Provider $provider
+     * @return bool
+     */
+    public function setProvider($provider)
+    {
+        if ($provider instanceof Provider) {
+            $this->provider = $provider;
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * batch
+     *
+     * @param bool $status
+     * @return void
+     */
+    public function batch($status)
+    {
+        $status = is_bool($status);
+
+        $this->provider->batch($status);
+    }
+}

+ 44 - 0
qiniu/services/blockchain/bsc/src/Formatters/AddressFormatter.php

@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Formatters;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\IntegerFormatter;
+
+class AddressFormatter implements IFormatter
+{
+    /**
+     * format
+     * to do: iban
+     * 
+     * @param mixed $value
+     * @return string
+     */
+    public static function format($value)
+    {
+        $value = (string) $value;
+
+        if (Utils::isAddress($value)) {
+            $value = mb_strtolower($value);
+
+            if (Utils::isZeroPrefixed($value)) {
+                return $value;
+            }
+            return '0x' . $value;
+        }
+        $value = IntegerFormatter::format($value, 40);
+
+        return '0x' . $value;
+    }
+}

+ 33 - 0
qiniu/services/blockchain/bsc/src/Formatters/BigNumberFormatter.php

@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Formatters;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IFormatter;
+
+class BigNumberFormatter implements IFormatter
+{
+    /**
+     * format
+     * 
+     * @param mixed $value
+     * @return string
+     */
+    public static function format($value)
+    {
+        $value = Utils::toString($value);
+        $bn = Utils::toBn($value);
+
+        return $bn;
+    }
+}

+ 30 - 0
qiniu/services/blockchain/bsc/src/Formatters/BooleanFormatter.php

@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Formatters;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IFormatter;
+
+class BooleanFormatter implements IFormatter
+{
+    /**
+     * format
+     * 
+     * @param mixed $value
+     * @return bool
+     */
+    public static function format($value)
+    {
+        return (bool) $value;
+    }
+}

+ 38 - 0
qiniu/services/blockchain/bsc/src/Formatters/HexFormatter.php

@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Formatters;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IFormatter;
+
+class HexFormatter implements IFormatter
+{
+    /**
+     * format
+     * 
+     * @param mixed $value
+     * @return string
+     */
+    public static function format($value)
+    {
+        $value = Utils::toString($value);
+        $value = mb_strtolower($value);
+
+        if (Utils::isZeroPrefixed($value)) {
+            return $value;
+        } else {
+            $value = Utils::toHex($value, true);
+        }
+        return $value;
+    }
+}

+ 23 - 0
qiniu/services/blockchain/bsc/src/Formatters/IFormatter.php

@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Formatters;
+
+interface IFormatter
+{
+    /**
+     * format
+     * 
+     * @param mixed $value
+     * @return string
+     */
+    public static function format($value);
+}

+ 44 - 0
qiniu/services/blockchain/bsc/src/Formatters/IntegerFormatter.php

@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Formatters;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IFormatter;
+
+class IntegerFormatter implements IFormatter
+{
+    /**
+     * format
+     * 
+     * @param mixed $value
+     * @return string
+     */
+    public static function format($value)
+    {
+        $value = (string) $value;
+        $arguments = func_get_args();
+        $digit = 64;
+
+        if (isset($arguments[1]) && is_numeric($arguments[1])) {
+            $digit = intval($arguments[1]);
+        }
+        $bn = Utils::toBn($value);
+        $bnHex = $bn->toHex(true);
+        $padded = mb_substr($bnHex, 0, 1);
+
+        if ($padded !== 'f') {
+            $padded = '0';
+        }        
+        return implode('', array_fill(0, $digit-mb_strlen($bnHex), $padded)) . $bnHex;
+    }
+}

+ 34 - 0
qiniu/services/blockchain/bsc/src/Formatters/NumberFormatter.php

@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Formatters;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IFormatter;
+
+class NumberFormatter implements IFormatter
+{
+    /**
+     * format
+     * 
+     * @param mixed $value
+     * @return int
+     */
+    public static function format($value)
+    {
+        $value = Utils::toString($value);
+        $bn = Utils::toBn($value);
+        $int = (int) $bn->toString();
+
+        return $int;
+    }
+}

+ 35 - 0
qiniu/services/blockchain/bsc/src/Formatters/OptionalQuantityFormatter.php

@@ -0,0 +1,35 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Formatters;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IFormatter;
+use qiniu\services\blockchain\bsc\src\Validators\TagValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class OptionalQuantityFormatter implements IFormatter
+{
+    /**
+     * format
+     * 
+     * @param mixed $value
+     * @return string
+     */
+    public static function format($value)
+    {
+        if (TagValidator::validate($value)) {
+            return $value;
+        }
+        return QuantityFormatter::format($value);
+    }
+}

+ 37 - 0
qiniu/services/blockchain/bsc/src/Formatters/PostFormatter.php

@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Formatters;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class PostFormatter implements IFormatter
+{
+    /**
+     * format
+     * 
+     * @param mixed $value
+     * @return string
+     */
+    public static function format($value)
+    {
+        if (isset($value['priority'])) {
+            $value['priority'] = QuantityFormatter::format($value['priority']);
+        }
+        if (isset($value['ttl'])) {
+            $value['ttl'] = QuantityFormatter::format($value['ttl']);
+        }
+        return $value;
+    }
+}

+ 47 - 0
qiniu/services/blockchain/bsc/src/Formatters/QuantityFormatter.php

@@ -0,0 +1,47 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Formatters;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IFormatter;
+
+class QuantityFormatter implements IFormatter
+{
+    /**
+     * format
+     * 
+     * @param mixed $value
+     * @return string
+     */
+    public static function format($value)
+    {
+        $value = Utils::toString($value);
+
+        if (Utils::isZeroPrefixed($value)) {
+            // test hex with zero ahead, hardcode 0x0
+            if ($value === '0x0' || strpos($value, '0x0') !== 0) {
+                return $value;
+            }
+            $hex = preg_replace('/^0x0+(?!$)/', '', $value);
+        } else {
+            $bn = Utils::toBn($value);
+            $hex = $bn->toHex(true);
+        }
+        if (empty($hex)) {
+            $hex = '0';
+        } else {
+            $hex = preg_replace('/^0+(?!$)/', '', $hex);
+        }
+        return '0x' . $hex;
+    }
+}

+ 30 - 0
qiniu/services/blockchain/bsc/src/Formatters/StringFormatter.php

@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Formatters;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IFormatter;
+
+class StringFormatter implements IFormatter
+{
+    /**
+     * format
+     * 
+     * @param mixed $value
+     * @return string
+     */
+    public static function format($value)
+    {
+        return Utils::toString($value);
+    }
+}

+ 47 - 0
qiniu/services/blockchain/bsc/src/Formatters/TransactionFormatter.php

@@ -0,0 +1,47 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Formatters;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Utils;
+use qiniu\services\blockchain\bsc\src\Formatters\IFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\HexFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class TransactionFormatter implements IFormatter
+{
+    /**
+     * format
+     * 
+     * @param mixed $value
+     * @return string
+     */
+    public static function format($value)
+    {
+        if (isset($value['gas'])) {
+            $value['gas'] = QuantityFormatter::format($value['gas']);
+        }
+        if (isset($value['gasPrice'])) {
+            $value['gasPrice'] = QuantityFormatter::format($value['gasPrice']);
+        }
+        if (isset($value['value'])) {
+            $value['value'] = QuantityFormatter::format($value['value']);
+        }
+        if (isset($value['data'])) {
+            $value['data'] = HexFormatter::format($value['data']);
+        }
+        if (isset($value['nonce'])) {
+            $value['nonce'] = QuantityFormatter::format($value['nonce']);
+        }
+        return $value;
+    }
+}

+ 57 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/Accounts.php

@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+
+class Accounts extends EthMethod
+{
+  /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 60 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/BlockNumber.php

@@ -0,0 +1,60 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class BlockNumber extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [
+        BigNumberFormatter::class
+    ];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 70 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/Call.php

@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\TagValidator;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Validators\CallValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\TransactionFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\OptionalQuantityFormatter;
+
+class Call extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        CallValidator::class, [
+            TagValidator::class, QuantityValidator::class
+        ]
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        TransactionFormatter::class, OptionalQuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [
+        1 => 'latest'
+    ];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 58 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/Coinbase.php

@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+
+class Coinbase extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+    
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/CompileLLL.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\StringValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\StringFormatter;
+
+class CompileLLL extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        StringValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        StringFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/CompileSerpent.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\StringValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\StringFormatter;
+
+class CompileSerpent extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        StringValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        StringFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/CompileSolidity.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\StringValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\StringFormatter;
+
+class CompileSolidity extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        StringValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        StringFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 67 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/EstimateGas.php

@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\TransactionValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\TransactionFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class EstimateGas extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        TransactionValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        TransactionFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [
+        BigNumberFormatter::class
+    ];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 61 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GasPrice.php

@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class GasPrice extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [
+        BigNumberFormatter::class
+    ];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 74 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetBalance.php

@@ -0,0 +1,74 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\TagValidator;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Validators\AddressValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\AddressFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\OptionalQuantityFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class GetBalance extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        AddressValidator::class, [
+            TagValidator::class, QuantityValidator::class
+        ]
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        AddressFormatter::class, OptionalQuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [
+        BigNumberFormatter::class
+    ];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [
+        1 => 'latest'
+    ];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 66 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetBlockByHash.php

@@ -0,0 +1,66 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\BlockHashValidator;
+use qiniu\services\blockchain\bsc\src\Validators\BooleanValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\HexFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\BooleanFormatter;
+
+class GetBlockByHash extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        BlockHashValidator::class, BooleanValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        HexFormatter::class, BooleanFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 71 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetBlockByNumber.php

@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Validators\TagValidator;
+use qiniu\services\blockchain\bsc\src\Validators\BooleanValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\OptionalQuantityFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\BooleanFormatter;
+
+class GetBlockByNumber extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        [
+            QuantityValidator::class, TagValidator::class
+        ], BooleanValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        OptionalQuantityFormatter::class, BooleanFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [
+        0 => 'latest'
+    ];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 67 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetBlockTransactionCountByHash.php

@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\BlockHashValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\HexFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class GetBlockTransactionCountByHash extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        BlockHashValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        HexFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [
+        BignumberFormatter::class
+    ];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 69 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetBlockTransactionCountByNumber.php

@@ -0,0 +1,69 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\OptionalQuantityFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class GetBlockTransactionCountByNumber extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        QuantityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        OptionalQuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [
+        BigNumberFormatter::class
+    ];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [
+        'latest'
+    ];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 71 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetCode.php

@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\TagValidator;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Validators\AddressValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\AddressFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\OptionalQuantityFormatter;
+
+class GetCode extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        AddressValidator::class, [
+            TagValidator::class, QuantityValidator::class
+        ]
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        AddressFormatter::class, OptionalQuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [
+        1 => 'latest'
+    ];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 58 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetCompilers.php

@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+
+class GetCompilers extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetFilterChanges.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class GetFilterChanges extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        QuantityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        QuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetFilterLogs.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class GetFilterLogs extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        QuantityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        QuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 61 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetLogs.php

@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\FilterValidator;
+
+class GetLogs extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        FilterValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 72 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetStorageAt.php

@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\TagValidator;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Validators\AddressValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\AddressFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\OptionalQuantityFormatter;
+
+class GetStorageAt extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        AddressValidator::class, QuantityValidator::class, [
+            TagValidator::class, QuantityValidator::class
+        ]
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        AddressFormatter::class, QuantityFormatter::class, OptionalQuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [
+        2 => 'latest'
+    ];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 66 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetTransactionByBlockHashAndIndex.php

@@ -0,0 +1,66 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\BlockHashValidator;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\HexFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class GetTransactionByBlockHashAndIndex extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        BlockHashValidator::class, QuantityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        HexFormatter::class, QuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 68 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetTransactionByBlockNumberAndIndex.php

@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\TagValidator;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\OptionalQuantityFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class GetTransactionByBlockNumberAndIndex extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        [
+            TagValidator::class, QuantityValidator::class
+        ], QuantityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        OptionalQuantityFormatter::class, QuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetTransactionByHash.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\BlockHashValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\HexFormatter;
+
+class GetTransactionByHash extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        BlockHashValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        HexFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 74 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetTransactionCount.php

@@ -0,0 +1,74 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\TagValidator;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Validators\AddressValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\AddressFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\OptionalQuantityFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class GetTransactionCount extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        AddressValidator::class, [
+            TagValidator::class, QuantityValidator::class
+        ]
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        AddressFormatter::class, OptionalQuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [
+        BigNumberFormatter::class
+    ];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [
+        1 => 'latest'
+    ];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetTransactionReceipt.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\BlockHashValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\HexFormatter;
+
+class GetTransactionReceipt extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        BlockHashValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        HexFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 66 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetUncleByBlockHashAndIndex.php

@@ -0,0 +1,66 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\BlockHashValidator;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\HexFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class GetUncleByBlockHashAndIndex extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        BlockHashValidator::class, QuantityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        HexFormatter::class, QuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 68 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetUncleByBlockNumberAndIndex.php

@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\TagValidator;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\OptionalQuantityFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class GetUncleByBlockNumberAndIndex extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        [
+            TagValidator::class, QuantityValidator::class
+        ], QuantityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        OptionalQuantityFormatter::class, QuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 67 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetUncleCountByBlockHash.php

@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\BlockHashValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\HexFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class GetUncleCountByBlockHash extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        BlockHashValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        HexFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [
+        BigNumberFormatter::class
+    ];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 72 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetUncleCountByBlockNumber.php

@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\TagValidator;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\OptionalQuantityFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class GetUncleCountByBlockNumber extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        [
+            TagValidator::class, QuantityValidator::class
+        ]
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        OptionalQuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [
+        BigNumberFormatter::class
+    ];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [
+        'latest'
+    ];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 58 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/GetWork.php

@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+
+class GetWork extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 61 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/Hashrate.php

@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class Hashrate extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+    
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [
+        BigNumberFormatter::class
+    ];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 58 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/Mining.php

@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+
+class Mining extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+    
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/NewBlockFilter.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class NewBlockFilter extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        QuantityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        QuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 61 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/NewFilter.php

@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\FilterValidator;
+
+class NewFilter extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        FilterValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 58 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/NewPendingTransactionFilter.php

@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+
+class NewPendingTransactionFilter extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 61 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/ProtocolVersion.php

@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class ProtocolVersion extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [
+        BigNumberFormatter::class
+    ];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/SendRawTransaction.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\HexValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\HexFormatter;
+
+class SendRawTransaction extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        HexValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        HexFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/SendTransaction.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\TransactionValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\TransactionFormatter;
+
+class SendTransaction extends EthMethod
+{
+   /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        TransactionValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        TransactionFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 66 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/Sign.php

@@ -0,0 +1,66 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\AddressValidator;
+use qiniu\services\blockchain\bsc\src\Validators\HexValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\AddressFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\HexFormatter;
+
+class Sign extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        AddressValidator::class, HexValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        AddressFormatter::class, HexFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 61 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/SubmitHashrate.php

@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\BlockHashValidator;
+
+class SubmitHashrate extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        BlockHashValidator::class, BlockHashValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 65 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/SubmitWork.php

@@ -0,0 +1,65 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\NonceValidator;
+use qiniu\services\blockchain\bsc\src\Validators\BlockHashValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class SubmitWork extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        NonceValidator::class, BlockHashValidator::class, BlockHashValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        QuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 58 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/Syncing.php

@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+
+class Syncing extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Eth/UninstallFilter.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Eth;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class UninstallFilter extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        QuantityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        QuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 158 - 0
qiniu/services/blockchain/bsc/src/Methods/EthMethod.php

@@ -0,0 +1,158 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods;
+
+use InvalidArgumentException;
+use RuntimeException;
+use qiniu\services\blockchain\bsc\src\Methods\IMethod;
+use qiniu\services\blockchain\bsc\src\Methods\JSONRPC;
+
+class EthMethod extends JSONRPC implements IMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+
+    /**
+     * getInputFormatters
+     * 
+     * @return array
+     */
+    public function getInputFormatters()
+    {
+        return $this->inputFormatters;
+    }
+
+    /**
+     * getOutputFormatters
+     * 
+     * @return array
+     */
+    public function getOutputFormatters()
+    {
+        return $this->outputFormatters;
+    }
+
+    /**
+     * validate
+     * 
+     * @param array $params
+     * @return bool
+     */
+    public function validate(&$params)
+    {
+        if (!is_array($params)) {
+            throw new InvalidArgumentException('Please use array params when call validate.');
+        }
+        $rules = $this->validators;
+
+        if (count($params) < count($rules)) {
+            if (!isset($this->defaultValues) || empty($this->defaultValues)) {
+                throw new InvalidArgumentException('The params are less than validators.');
+            }
+            $defaultValues = $this->defaultValues;
+
+            foreach ($defaultValues as $key => $value) {
+                if (!isset($params[$key])) {
+                    $params[$key] = $value;
+                }
+
+            }
+        } elseif (count($params) > count($rules)) {
+            throw new InvalidArgumentException('The params are more than validators.');
+        }
+        foreach ($rules as $key => $rule) {
+            if (isset($params[$key])) {
+                if (is_array($rule)) {
+                    $isError = true;
+
+                    foreach ($rule as $subRule) {
+                        if (call_user_func([$subRule, 'validate'], $params[$key]) === true) {
+                            $isError = false;
+                            break;
+                        }
+                    }
+                    if ($isError) {
+                        throw new RuntimeException('Wrong type of ' . $this->method . ' method argument ' . $key . '.');
+                    }
+                } else {
+                    if (call_user_func([$rule, 'validate'], $params[$key]) === false) {
+                        throw new RuntimeException('Wrong type of ' . $this->method . ' method argument ' . $key . '.');
+                    }
+                }
+            } else {
+                throw new RuntimeException($this->method . ' method argument ' . $key . ' doesn\'t have default value.');
+            }
+        }
+        return true;
+    }
+
+    /**
+     * transform
+     * 
+     * @param array $params
+     * @param array $rules
+     * @return array
+     */
+    public function transform($params, $rules)
+    {
+        if (!is_array($params)) {
+            throw new InvalidArgumentException('Please use array params when call transform.');
+        }
+        if (!is_array($rules)) {
+            throw new InvalidArgumentException('Please use array rules when call transform.');
+        }
+        foreach ($params as $key => $param) {
+            if (isset($rules[$key])) {
+                $formatted = call_user_func([$rules[$key], 'format'], $param);
+                $params[$key] = $formatted;
+            }
+        }
+        return $params;
+    }
+}

+ 24 - 0
qiniu/services/blockchain/bsc/src/Methods/IMethod.php

@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods;
+
+interface IMethod
+{
+    /**
+     * transform
+     * 
+     * @param array &$data
+     * @param array $rules
+     * @return array
+     */
+    public function transform($data, $rules);
+}

+ 29 - 0
qiniu/services/blockchain/bsc/src/Methods/IRPC.php

@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods;
+
+interface IRPC
+{
+    /**
+     * __toString
+     * 
+     * @return array
+     */
+    public function __toString();
+
+    /**
+     * toPayload
+     * 
+     * @return array
+     */
+    public function toPayload();
+}

+ 215 - 0
qiniu/services/blockchain/bsc/src/Methods/JSONRPC.php

@@ -0,0 +1,215 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\IRPC;
+
+class JSONRPC implements IRPC
+{
+    /**
+     * id
+     * 
+     * @var int
+     */
+    protected $id = 0;
+
+    /**
+     * rpcVersion
+     * 
+     * @var string
+     */
+    protected $rpcVersion = '2.0';
+
+    /**
+     * method
+     * 
+     * @var string
+     */
+    protected $method = '';
+
+    /**
+     * arguments
+     * 
+     * @var array
+     */
+    protected $arguments = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    public function __construct($method, $arguments)
+    {
+        $this->method = $method;
+        $this->arguments = $arguments;
+    }
+
+    /**
+     * get
+     * 
+     * @param string $name
+     * @return mixed
+     */
+    public function __get($name)
+    {
+        $method = 'get' . ucfirst($name);
+
+        if (method_exists($this, $method)) {
+            return call_user_func_array([$this, $method], []);
+        }
+        return false;
+    }
+
+    /**
+     * set
+     * 
+     * @param string $name
+     * @param mixed $value
+     * @return mixed
+     */
+    public function __set($name, $value)
+    {
+        $method = 'set' . ucfirst($name);
+
+        if (method_exists($this, $method)) {
+            return call_user_func_array([$this, $method], [$value]);
+        }
+        return false;
+    }
+
+    /**
+     * __toString
+     * 
+     * @return string
+     */
+    public function __toString()
+    {
+        $payload = $this->toPayload();
+
+        return json_encode($payload);
+    }
+
+    /**
+     * setId
+     * 
+     * @param int $id
+     * @return bool
+     */
+    public function setId($id)
+    {
+        if (!is_int($id)) {
+            throw new InvalidArgumentException('Id must be integer.');
+        }
+        $this->id = $id;
+
+        return true;
+    }
+
+    /**
+     * getId
+     * 
+     * @return int
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * getRpcVersion
+     * 
+     * @return string
+     */
+    public function getRpcVersion()
+    {
+        return $this->rpcVersion;
+    }
+
+    /**
+     * getMethod
+     * 
+     * @return string
+     */
+    public function getMethod()
+    {
+        return $this->method;
+    }
+
+    /**
+     * setArguments
+     * 
+     * @param array $arguments
+     * @return bool
+     */
+    public function setArguments($arguments)
+    {
+        if (!is_array($arguments)) {
+            throw new InvalidArgumentException('Please use array when call setArguments.');
+        }
+        $this->arguments = $arguments;
+
+        return true;
+    }
+
+    /**
+     * getArguments
+     * 
+     * @return array
+     */
+    public function getArguments()
+    {
+        return $this->arguments;
+    }
+
+    /**
+     * toPayload
+     * 
+     * @return array
+     */
+    public function toPayload()
+    {
+        if (empty($this->method) || !is_string($this->method)) {
+            throw new InvalidArgumentException('Please check the method set properly.');
+        }
+        if (empty($this->id)) {
+            $id = rand();
+        } else {
+            $id = $this->id;
+        }
+        $rpc = [
+            'id' => $id,
+            'jsonrpc' => $this->rpcVersion,
+            'method' => $this->method
+        ];
+
+        if (count($this->arguments) > 0) {
+            $rpc['params'] = $this->arguments;
+        }
+        return $rpc;
+    }
+
+    /**
+     * toPayloadString
+     * 
+     * @return string
+     */
+    public function toPayloadString()
+    {
+        $payload = $this->toPayload();
+
+        return json_encode($payload);
+    }
+}

+ 58 - 0
qiniu/services/blockchain/bsc/src/Methods/Net/Listening.php

@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Net;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+
+class Listening extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 61 - 0
qiniu/services/blockchain/bsc/src/Methods/Net/PeerCount.php

@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Net;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Formatters\BigNumberFormatter;
+
+class PeerCount extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [
+        BigNumberFormatter::class
+    ];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 58 - 0
qiniu/services/blockchain/bsc/src/Methods/Net/Version.php

@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Net;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+
+class Version extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 58 - 0
qiniu/services/blockchain/bsc/src/Methods/Personal/ListAccounts.php

@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Personal;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+
+class ListAccounts extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Personal/NewAccount.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Personal;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\StringValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\StringFormatter;
+
+class NewAccount extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        StringValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        StringFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 66 - 0
qiniu/services/blockchain/bsc/src/Methods/Personal/SendTransaction.php

@@ -0,0 +1,66 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Personal;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\TransactionValidator;
+use qiniu\services\blockchain\bsc\src\Validators\StringValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\TransactionFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\StringFormatter;
+
+class SendTransaction extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        TransactionValidator::class, StringValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        TransactionFormatter::class, StringFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 70 - 0
qiniu/services/blockchain/bsc/src/Methods/Personal/UnlockAccount.php

@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Personal;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\AddressValidator;
+use qiniu\services\blockchain\bsc\src\Validators\StringValidator;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\AddressFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\StringFormatter;
+use qiniu\services\blockchain\bsc\src\Formatters\NumberFormatter;
+
+class UnlockAccount extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        AddressValidator::class, StringValidator::class, QuantityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        AddressFormatter::class, StringFormatter::class, NumberFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [
+        2 => 300
+    ];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 61 - 0
qiniu/services/blockchain/bsc/src/Methods/Shh/AddToGroup.php

@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Shh;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\IdentityValidator;
+
+class AddToGroup extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        IdentityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Shh/GetFilterChanges.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Shh;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class GetFilterChanges extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        QuantityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        QuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

+ 64 - 0
qiniu/services/blockchain/bsc/src/Methods/Shh/GetMessages.php

@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * This file is part of web3.php package.
+ * 
+ * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
+ * 
+ * @author Peter Lai <alk03073135@gmail.com>
+ * @license MIT
+ */
+
+namespace qiniu\services\blockchain\bsc\src\Methods\Shh;
+
+use InvalidArgumentException;
+use qiniu\services\blockchain\bsc\src\Methods\EthMethod;
+use qiniu\services\blockchain\bsc\src\Validators\QuantityValidator;
+use qiniu\services\blockchain\bsc\src\Formatters\QuantityFormatter;
+
+class GetMessages extends EthMethod
+{
+    /**
+     * validators
+     * 
+     * @var array
+     */
+    protected $validators = [
+        QuantityValidator::class
+    ];
+
+    /**
+     * inputFormatters
+     * 
+     * @var array
+     */
+    protected $inputFormatters = [
+        QuantityFormatter::class
+    ];
+
+    /**
+     * outputFormatters
+     * 
+     * @var array
+     */
+    protected $outputFormatters = [];
+
+    /**
+     * defaultValues
+     * 
+     * @var array
+     */
+    protected $defaultValues = [];
+
+    /**
+     * construct
+     * 
+     * @param string $method
+     * @param array $arguments
+     * @return void
+     */
+    // public function __construct($method='', $arguments=[])
+    // {
+    //     parent::__construct($method, $arguments);
+    // }
+}

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.