reactmore/chainshub-api-wrapper
Composer 安装命令:
composer require reactmore/chainshub-api-wrapper
包简介
Make api wrapper chainshub.id
README 文档
README
Installation
composer require reactmore/chainshub-api-wrapper
Coin Api Wrapper
| Coin | Status |
|---|---|
Tron |
OK |
Doge |
Not Yet |
BSC |
Not Yet |
ETC |
Not Yet |
LTC |
Not Yet |
DASH |
Not Yet |
Calling Coin Method
$api->{CoinName}_{{MethodName}}(); ex:
$api->tron_generateAddress(); $api->tron_getBalance(); $api->tron_transfer(); etc....
Example Usage Coin Method
Load package
<?php require 'vendor/autoload.php'; use Reactmore\ChainshubApiWrapper\ChainshubApi; // Load .env if exists if (file_exists(__DIR__ . '/.env')) { $dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->load(); } // Define Your API Key and Merchant Private Key $apiKey = $_ENV['API_KEY'] ?? 'your-api-key-here'; $merchantPrivateKey = $_ENV['MERCHANT_PRIVATE_KEY'] ?? 'your-merchant-private-key'; // Initialize the ChainshubApi class $api = new ChainshubApi($apiKey, $merchantPrivateKey);
Generate Address
$api = new ChainshubApi($apiKey, $merchantPrivateKey); // Generate a new address try { $generateAddressParams = ['network' => 'mainnet']; $generateAddressResponse = $api->tron_generateAddress($generateAddressParams); echo "Generate Address Response:\n"; print_r($generateAddressResponse); } catch (Exception $e) { echo "Error generating address: " . $e->getMessage() . "\n"; }
Check Balance
$api = new ChainshubApi($apiKey, $merchantPrivateKey); // Check balance try { $balanceParams = [ 'network' => 'mainnet', 'address' => 'your-tron-address-here' ]; $balanceResponse = $api->tron_getBalance($balanceParams); echo "Balance Response:\n"; print_r($balanceResponse); } catch (Exception $e) { echo "Error checking balance: " . $e->getMessage() . "\n"; }
Transfer Coin
$api = new ChainshubApi($apiKey, $merchantPrivateKey); // Transfer coins try { $transferParams = [ 'network' => 'mainnet', 'from_address' => 'your-tron-address-here', 'amount' => 5, 'to_address' => 'destination-tron-address-here', 'private_key' => 'your-private-key-here' ]; $transferResponse = $api->tron_transfer($transferParams); echo "Transfer Response:\n"; print_r($transferResponse); } catch (Exception $e) { echo "Error transferring coins: " . $e->getMessage() . "\n"; }
Example Merchant Transactions
Create Invoice:
// Create an invoice try { $invoiceParams = [ 'currency' => 'bsc', 'merchant_ref' => 'INVOICE-001', 'customer_email' => 'customer@gmail.com', 'customer_name' => 'James Bond', 'pair' => 'idr', 'redirect_url' => 'https://yourwebsite.com/callback=success', 'cancel_url' => 'https://yourwebsite.com/callback=failed', 'amount' => '10000' ]; $invoiceResponse = $api->createInvoice($invoiceParams); echo "Create Invoice Response:\n"; print_r($invoiceResponse); } catch (Exception $e) { echo "Error creating invoice: " . $e->getMessage() . "\n"; }
Handle Callback:
// Handle callback try { $postData = file_get_contents('php://input'); $headers = getallheaders(); $callbackResponse = $api->handleCallback($postData, $headers); echo "Callback Response:\n"; print_r($callbackResponse); } catch (Exception $e) { echo "Error handling callback: " . $e->getMessage() . "\n"; }
reactmore/chainshub-api-wrapper 适用场景与选型建议
reactmore/chainshub-api-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 07 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 reactmore/chainshub-api-wrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 reactmore/chainshub-api-wrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-09