PHPackages                             majestic/php-litecoinrpc - 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. majestic/php-litecoinrpc

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

majestic/php-litecoinrpc
========================

Litecoin JSON-RPC client based on GuzzleHttp

v2.0.2(8y ago)68.3k83MITPHPPHP &gt;=5.6.0

Since Jan 20Pushed 7y ago2 watchersCompare

[ Source](https://github.com/majestic84/php-litecoinrpc)[ Packagist](https://packagist.org/packages/majestic/php-litecoinrpc)[ Docs](https://github.com/majestic84/php-litecoinrpc)[ RSS](/packages/majestic-php-litecoinrpc/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)Dependencies (3)Versions (15)Used By (3)

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

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

About
-----

[](#about)

This project is based on [php-bitcoinrpc](https://github.com/denpamusic/php-bitcoinrpc) project - fully unit-tested Litecoin JSON-RPC client powered by GuzzleHttp.

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

[](#installation)

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

```
"require": {
    "majestic/php-litecoinrpc": "^2.0"
}
```

and run `php composer.phar update`.

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

[](#requirements)

PHP 7.0 or higher (should also work on 5.6, but this is unsupported)

Usage
-----

[](#usage)

Create new object with url as parameter

```
use Majestic\Litecoin\Client as LitecoinClient;

$litecoind = new LitecoinClient('http://rpcuser:rpcpassword@localhost:9332/');
```

or use array to define your litecoind settings

```
use Majestic\Litecoin\Client as LitecoinClient;

$litecoind = new LitecoinClient([
    'scheme' => 'http',                 // optional, default http
    'host'   => 'localhost',            // optional, default localhost
    'port'   => 9332,                   // optional, default 9332
    'user'   => 'rpcuser',              // required
    'pass'   => 'rpcpassword',          // required
    'ca'     => '/etc/ssl/ca-cert.pem'  // optional, for use with https scheme
]);
```

Then call methods defined in [Litecoin Core API Documentation](https://litecoin.info/Litecoin_API) with magic:

```
/**
 * Get block info.
 */
$block = $litecoind->getBlock('9d4d9fd2f4dee46d5918861b7bbff81f52c581c3b935ad186fe4c5b6dc58d2f8');

$block('hash')->get();     // 9d4d9fd2f4dee46d5918861b7bbff81f52c581c3b935ad186fe4c5b6dc58d2f8
$block['height'];          // 1298009 (array access)
$block->get('tx.0');       // a8971eaf8dfda3ee5dd20b3de3fb6c22e936339bbb53f8fa0f2379941ac5ff3f
$block->count('tx');       // 26
$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 = $litecoind->sendToAddress('LKdsQGCwBbgJNdXSQtAvVbFMpwgwThtsSY', 0.1);
$txid = $result->get();

/**
 * Get transaction amount.
 */
$result = $litecoind->listSinceBlock();
$totalAmount = $result->sum('transactions.*.amount');
$totalSatoshi = LitecoinClient::toSatoshi($totalAmount);
```

To send asynchronous request, add Async to method name:

```
use Majestic\Litecoin\LitecoindResponse;

$promise = $litecoind->getBlockAsync(
    '9d4d9fd2f4dee46d5918861b7bbff81f52c581c3b935ad186fe4c5b6dc58d2f8',
    function (LitecoindResponse $success) {
        //
    },
    function (\Exception $exception) {
        //
    }
);

$promise->wait();
```

You can also send requests using request method:

```
/**
 * Get block info.
 */
$block = $litecoind->request('getBlock', '9d4d9fd2f4dee46d5918861b7bbff81f52c581c3b935ad186fe4c5b6dc58d2f8');

$block('hash');            // 9d4d9fd2f4dee46d5918861b7bbff81f52c581c3b935ad186fe4c5b6dc58d2f8
$block['height'];          // 1298009 (array access)
$block->get('tx.0');       // a8971eaf8dfda3ee5dd20b3de3fb6c22e936339bbb53f8fa0f2379941ac5ff3f
$block->count('tx');       // 26
$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->random(1, 'tx');   // get random txid

/**
 * Send transaction.
 */
$result = $BTC->request('sendtoaddress', ['LKdsQGCwBbgJNdXSQtAvVbFMpwgwThtsSY', 0.06]);
$txid = $result->get();
```

or requestAsync method for asynchronous calls:

```
use Majestic\Litecoin\LitecoindResponse;

$promise = $litecoind->requestAsync(
    'getBlock',
    '9d4d9fd2f4dee46d5918861b7bbff81f52c581c3b935ad186fe4c5b6dc58d2f8',
    function (LitecoindResponse $success) {
        //
    },
    function (\Exception $exception) {
        //
    }
);

$promise->wait();
```

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

[](#multi-wallet-rpc)

You can use `wallet($name)` function to do a [Multi-Wallet RPC call](https://github.com/litecoin-project/litecoin/blob/v0.15.0.1rc1/doc/release-notes-litecoin.md#multi-wallet-support):

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

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

License
-------

[](#license)

This product is distributed under MIT license.

Donations
---------

[](#donations)

If you like this project, you can donate Litecoins to LKdsQGCwBbgJNdXSQtAvVbFMpwgwThtsSY.

Thanks for your support!

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 96% 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 ~21 days

Total

14

Last Release

3133d ago

Major Versions

v1.0.8 → v2.0.0beta12017-08-14

PHP version history (2 changes)v1.0.0PHP &gt;=5.4.0

v1.0.2PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf5ad0ea7d79585eb3dd38feadfa72a8ae80504db8ea59c3bc5fdc0a2ad0653c?d=identicon)[majestic84](/maintainers/majestic84)

---

Top Contributors

[![denpamusic](https://avatars.githubusercontent.com/u/16575433?v=4)](https://github.com/denpamusic "denpamusic (95 commits)")[![majestic84](https://avatars.githubusercontent.com/u/18451224?v=4)](https://github.com/majestic84 "majestic84 (2 commits)")[![gdespirito](https://avatars.githubusercontent.com/u/1103494?v=4)](https://github.com/gdespirito "gdespirito (1 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")

---

Tags

apiGuzzlejsonrpclitecoin

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/majestic-php-litecoinrpc/health.svg)

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

###  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)
