ftab/php-dogecoinrpc
Composer 安装命令:
composer require ftab/php-dogecoinrpc
包简介
Dogecoin JSON-RPC client based on php-bitcoinrpc
README 文档
README
Installation
Run php composer.phar require ftab/php-dogecoinrpc in your project directory or add following lines to composer.json
"require": { "ftab/php-dogecoinrpc": "^3.0" }
and run php composer.phar install.
Requirements
PHP 7.1 or higher
Usage
Create new object with url as parameter
/** * Don't forget to include composer autoloader by uncommenting line below * if you're not already done it anywhere else in your project. **/ // require 'vendor/autoload.php'; use ftab\Dogecoin\Client as DogecoinClient; $dogecoind = new DogecoinClient('http://rpcuser:rpcpassword@localhost:22555/');
or use array to define your dogecoind settings
/** * Don't forget to include composer autoloader by uncommenting line below * if you're not already done it anywhere else in your project. **/ // require 'vendor/autoload.php'; use ftab\Dogecoin\Client as DogecoinClient; $dogecoind = new DogecoinClient([ 'scheme' => 'http', // optional, default http 'host' => 'localhost', // optional, default localhost 'port' => 22555, // optional, default 22555 'user' => 'rpcuser', // required 'password' => 'rpcpassword', // required 'ca' => '/etc/ssl/ca-cert.pem', // optional, for use with https scheme 'preserve_case' => false, // optional, send method names as defined instead of lowercasing them ]);
Then call methods defined in Dogecoin Core API with magic:
/** * Get block info. */ $block = $dogecoind->getBlock('1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691'); $block('hash')->get(); // 1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691 $block['height']; // 0 (array access) $block->get('tx.0'); // 5b2a3f53f605d62c53e62932dac6925e3d74afa5a4b459745c36d42d0ed26a69 $block->count('tx'); // 1 $block->has('version'); // key must exist and CAN NOT be null $block->exists('version'); // key must exist and CAN be null $block->contains(0); // check if response contains value $block->values(); // array of values $block->keys(); // array of keys $block->random(1, 'tx'); // random block txid $block('tx')->random(2); // two random block txid's $block('tx')->first(); // txid of first transaction $block('tx')->last(); // txid of last transaction /** * Send transaction. */ $result = $dogecoind->sendToAddress('DATfurydmRTZ6vJnBtaibHJYMdx9JYjL4n', 100); $txid = $result->get(); /** * Get transaction amount. */ $result = $dogecoind->listSinceBlock(); $dogecoin = $result->sum('transactions.*.amount'); $dogetoshi = \ftab\Dogecoin\to_dogetoshi($dogecoin);
To send asynchronous request, add Async to method name:
$dogecoind->getBlockAsync( '1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691', function ($response) { // success }, function ($exception) { // error } );
You can also send requests using request method:
/** * Get block info. */ $block = $dogecoind->request('getBlock', '1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691'); $block('hash'); // 1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691 $block['height']; // 0 (array access) $block->get('tx.0'); // 5b2a3f53f605d62c53e62932dac6925e3d74afa5a4b459745c36d42d0ed26a69 $block->count('tx'); // 1 $block->has('version'); // key must exist and CAN NOT be null $block->exists('version'); // key must exist and CAN be null $block->contains(0); // check if response contains value $block->values(); // get response values $block->keys(); // get response keys $block->first('tx'); // get txid of the first transaction $block->last('tx'); // get txid of the last transaction $block->random(1, 'tx'); // get random txid /** * Send transaction. */ $result = $dogecoind->request('sendtoaddress', 'DATfurydmRTZ6vJnBtaibHJYMdx9JYjL4n', 60); $txid = $result->get();
or requestAsync method for asynchronous calls:
$dogecoind->requestAsync( 'getBlock', '1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691', function ($response) { // success }, function ($exception) { // error } );
Exceptions
ftab\Dogecoin\Exceptions\BadConfigurationException- thrown on bad client configuration.ftab\Dogecoin\Exceptions\BadRemoteCallException- thrown on getting error message from daemon.ftab\Dogecoin\Exceptions\ConnectionException- thrown on daemon connection errors (e. g. timeouts)
Helpers
Package provides following helpers to assist with value handling.
to_dogecoin()
Converts value in dogetoshi to dogecoin.
echo ftab\Dogecoin\to_dogecoin('100000'); // '0.00100000'
to_dogetoshi()
Converts value in dogecoin to dogetoshi.
echo ftab\Dogecoin\to_dogetoshi('0.001'); // '100000'
to_fixed()
Trims value to precision without rounding.
echo ftab\Dogecoin\to_fixed('0.1236', 3); // '0.123'
License
This product is distributed under MIT license.
Donations
Let's give some love to Denpa
If you like this project, please consider donating to the original author of php-bitcoinrpc as they did all the work:
BTC: 3L6dqSBNgdpZan78KJtzoXEk9DN3sgEQJu
Bech32: bc1qyj8v6l70c4mjgq7hujywlg6le09kx09nq8d350
❤Thanks for your support!❤
dogecoin fork
I guess I could take a doge or two for making this fork too? Dunno. Feels weird when all I'm doing is diffing and editing.
- DOGE: DATfurydmRTZ6vJnBtaibHJYMdx9JYjL4n
Or check out the game I'm putting it in, and throw your doge at some of the in-game goodies!
ftab/php-dogecoinrpc 适用场景与选型建议
ftab/php-dogecoinrpc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 272 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 02 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「Guzzle」 「jsonrpc」 「dogecoin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ftab/php-dogecoinrpc 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ftab/php-dogecoinrpc 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ftab/php-dogecoinrpc 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Bitcoin JSON-RPC Service Provider for Laravel
A collection of server-side addons that might be of use for development of xml-rpc (and json-rpc) based applications
JsonRpc Client for Laravel
Flexible JSON RPC v2 client for PHP written in object-oriented style
A PSR-7 compatible library for making CRUD API endpoints
Multichain JSON-RPC Client
统计信息
- 总下载量: 272
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-02