PHPackages                             done/php-altcoinrpc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. done/php-altcoinrpc

ActiveLibrary[HTTP &amp; Networking](/categories/http)

done/php-altcoinrpc
===================

Altcoin JSON-RPC client based on GuzzleHttp

1.1(4y ago)1551MITPHPPHP &gt;=7.1

Since Apr 26Pushed 4y ago1 watchersCompare

[ Source](https://github.com/acsantanamx/php-altcoinrpc)[ Packagist](https://packagist.org/packages/done/php-altcoinrpc)[ Docs](https://github.com/acsantanamx/php-altcoinrpc)[ RSS](/packages/done-php-altcoinrpc/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Simple Altcoin JSON-RPC client based on GuzzleHttp
==================================================

[](#simple-altcoin-json-rpc-client-based-on-guzzlehttp)

Installation
------------

[](#installation)

Run `php composer.phar require done/php-altcoinrpc` in your project directory or add following lines to composer.json

```
"require": {
    "done/php-altcoinrpc": "^1.0"
}
```

and run `php composer.phar install`.

Requirements
------------

[](#requirements)

PHP 7.1 or higher

Usage
-----

[](#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 DOne\Altcoin\Client as AltcoinClient;

$altcoind = new AltcoinClient('http://rpcuser:rpcpassword@localhost:8332/');
```

or use array to define your altcoind 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 DOne\Altcoin\Client as AltcoinClient;

$altcoind = new AltcoinClient([
    'scheme'        => 'http',                 // optional, default http
    'host'          => 'localhost',            // optional, default localhost
    'port'          => 8332,                   // optional, default 8332
    '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 [Bitcoin Core API Documentation](https://bitcoin.org/en/developer-reference#altcoin-core-apis) with magic:

```
/**
 * Get block info.
 */
$block = $altcoind->getBlock('000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f');

$block('hash')->get();     // 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
$block['height'];          // 0 (array access)
$block->get('tx.0');       // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
$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 = $altcoind->sendToAddress('mmXgiR6KAhZCyQ8ndr2BCfEq1wNG2UnyG6', 0.1);
$txid = $result->get();

/**
 * Get transaction amount.
 */
$result = $altcoind->listSinceBlock();
$altcoin = $result->sum('transactions.*.amount');
$satoshi = \DOne\Altcoin\to_satoshi($altcoin);
```

To send asynchronous request, add Async to method name:

```
$altcoind->getBlockAsync(
    '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
    function ($response) {
        // success
    },
    function ($exception) {
        // error
    }
);
```

You can also send requests using request method:

```
/**
 * Get block info.
 */
$block = $altcoind->request('getBlock', '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f');

$block('hash');            // 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
$block['height'];          // 0 (array access)
$block->get('tx.0');       // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
$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 = $altcoind->request('sendtoaddress', 'mmXgiR6KAhZCyQ8ndr2BCfEq1wNG2UnyG6', 0.06);
$txid = $result->get();
```

or requestAsync method for asynchronous calls:

```
$altcoind->requestAsync(
    'getBlock',
    '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
    function ($response) {
        // success
    },
    function ($exception) {
        // error
    }
);
```

Multi-Wallet RPC
----------------

[](#multi-wallet-rpc)

You can use `wallet($name)` function to do a [Multi-Wallet RPC call](https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#Multi-wallet_RPC_calls):

```
/**
 * Get wallet2.dat balance.
 */
$balance = $altcoind->wallet('walletfilename.dat')->getbalance();

echo $balance->get(); // 0.10000000
```

Exceptions
----------

[](#exceptions)

- `DOne\Altcoin\Exceptions\BadConfigurationException` - thrown on bad client configuration.
- `DOne\Altcoin\Exceptions\BadRemoteCallException` - thrown on getting error message from daemon.
- `DOne\Altcoin\Exceptions\ConnectionException` - thrown on daemon connection errors (e. g. timeouts)

Helpers
-------

[](#helpers)

Package provides following helpers to assist with value handling.

#### `to_altcoin()`

[](#to_altcoin)

Converts value in satoshi to altcoin.

```
echo DOne\Altcoin\to_altcoin(100000); // 0.00100000
```

#### `to_satoshi()`

[](#to_satoshi)

Converts value in altcoin to satoshi.

```
echo DOne\Altcoin\to_satoshi(0.001); // 100000
```

#### `to_ubtc()`

[](#to_ubtc)

Converts value in altcoin to ubtc/bits.

```
echo DOne\Altcoin\to_ubtc(0.001); // 1000.0000
```

#### `to_mbtc()`

[](#to_mbtc)

Converts value in altcoin to mbtc.

```
echo DOne\Altcoin\to_mbtc(0.001); // 1.0000
```

#### `to_fixed()`

[](#to_fixed)

Trims float value to precision without rounding.

```
echo DOne\Altcoin\to_fixed(0.1236, 3); // 0.123
```

License
-------

[](#license)

This product is distributed under MIT license.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1482d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/034ba7e7cc97457047959644edfa38cd8c56d474f192eb692dbf9b92d7dfd9bd?d=identicon)[acsantanamx](/maintainers/acsantanamx)

---

Top Contributors

[![acsantanamx](https://avatars.githubusercontent.com/u/60712262?v=4)](https://github.com/acsantanamx "acsantanamx (5 commits)")

---

Tags

apiGuzzlejsonrpcaltcoin

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/done-php-altcoinrpc/health.svg)

```
[![Health](https://phpackages.com/badges/done-php-altcoinrpc/health.svg)](https://phpackages.com/packages/done-php-altcoinrpc)
```

###  Alternatives

[denpa/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

284217.4k4](/packages/denpa-php-bitcoinrpc)[denpa/laravel-bitcoinrpc

Bitcoin JSON-RPC Service Provider for Laravel

9053.4k](/packages/denpa-laravel-bitcoinrpc)[antoinelemaire/aircall-php

Aircall API client built on top of Guzzle 6

1049.6k](/packages/antoinelemaire-aircall-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
