PHPackages                             jeankassio/electrumphp - 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. [API Development](/categories/api)
4. /
5. jeankassio/electrumphp

ActiveLibrary[API Development](/categories/api)

jeankassio/electrumphp
======================

PHP library to connect in Electrum JSON-RPC

1.0.7(9mo ago)230↓100%MITPHPPHP &gt;=8.0

Since Oct 2Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/jeankassio/ElectrumPHP)[ Packagist](https://packagist.org/packages/jeankassio/electrumphp)[ RSS](/packages/jeankassio-electrumphp/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)DependenciesVersions (16)Used By (0)

ElectrumPHP
===========

[](#electrumphp)

ElectrumPHP is a PHP library designed to interact with the Electrum wallet through RPC calls. With this library, you can manage wallets, generate addresses, check balances, make Bitcoin payments and much more using the Electrum daemon.

Update: You can also calculate the ideal estimated fee for your transaction before you make it.

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

[](#requirements)

- PHP 8 or higher
- Curl enabled
- putenv enabled
- exec enabled (to start Electrum)
- Electrum installed and configured on your server

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

[](#installation)

### The package can be installed using Composer

[](#the-package-can-be-installed-using-composer)

```
  composer require jeankassio/electrumphp
```

Usage
-----

[](#usage)

### Instantiate the ElectrumPHP Class

[](#instantiate-the-electrumphp-class)

```
require_once(dirname(__FILE__) . "/path/to/autoload.php");

use JeanKassio\ElectrumPHP;

$walletPath = dirname(__FILE__) . "/wallet/walletfile";
$walletPass = "0123456789";
$rpcUser = "user";
$rpcPass = "9876543210";
$rpcPort = 7777;
$rpcHost = "127.0.0.1";
$binary = false; //if false, the code find automatically the binary of Electrum

$electrum = new ElectrumPHP($walletPath, $walletPass, $rpcUser, $rpcPass, $rpcPort, $rpcHost, $binary);
```

Tips
----

[](#tips)

The recommendation is that you start it even if you know that the daemon is already running, as the "start" function checks whether the daemon is running and communicating correctly before trying to execute the code to start the daemon.

Methods
-------

[](#methods)

### Start the Electrum Daemon (if you need)

[](#start-the-electrum-daemon-if-you-need)

```
$electrum->start();
```

### Stop the Electrum Daemon (if you need)

[](#stop-the-electrum-daemon-if-you-need)

```
$electrum->stop();
```

### Check if Daemon is Running

[](#check-if-daemon-is-running)

```
if($electrum->isRunning()){
    echo "Electrum daemon is running.";
}
```

### Validate a Bitcoin Address

[](#validate-a-bitcoin-address)

```
$address = "1PuJjnF476W3zXfVYmJfGnouzFDAXakkL4";
$valid = $electrum->validate($address);
echo "The Bitcoin address is " . ($valid ? "valid" : "invalid");
```

### Create a New Wallet and receive Seed

[](#create-a-new-wallet-and-receive-seed)

```
$walletPath = dirname(__FILE__) . "/wallet/walletfile";
$seed = false;
$password = "0123456789";
$encrypt = true;
$segwit = true;
$language = "english";
$entropy = 256;
$response = $electrum->createWallet($walletPath, $password, $seed, $encrypt, $segwit, $language, $entropy);
echo "Seed: " . $response['seed'];
```

### Create a New Wallet with your seed

[](#create-a-new-wallet-with-your-seed)

```
$walletPath = dirname(__FILE__) . "/wallet/walletfile";
$seed = "excess title assist very badge rain pet purchase device narrow awesome recall";
$password = NULL;
$encrypt = false;
$segwit = false;
$response = $electrum->createWallet($walletPath, $password, $seed, $encrypt, $segwit);
echo "Seed: " . $response['seed'];
```

### Create a New Address

[](#create-a-new-address)

```
$address = $electrum->createAddress();
echo "New address: " . $address;
```

### Get Address Balance

[](#get-address-balance)

```
$address = "1PuJjnF476W3zXfVYmJfGnouzFDAXakkL4";
$balance = $electrum->getAddressBalance($address);
echo "Confirmed: " . $balance['confirmed'];
echo "Unconfirmed: " . $balance['unconfirmed'];
```

### Get Wallet Balance

[](#get-wallet-balance)

```
$balance = $electrum->getWalletBalance();
if(isset($balance['confirmed'])){
  echo "Confirmed: " . $balance['confirmed'];
}

if(isset($balance['unconfirmed'])){
  echo "Unconfirmed: " . $balance['unconfirmed'];
}

if(isset($balance['unmatured'])){
  echo "Unmatured: " . $balance['unmatured'];
}
```

### Get Transaction Details

[](#get-transaction-details)

```
$txid = "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";
$transaction = $electrum->getTransaction($txid);
echo "Transaction details: " . json_encode($transaction);
```

### Get Number of Confirmations

[](#get-number-of-confirmations)

```
$txid = "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";
$confirmations = $electrum->getConfirmations($txid); //return int
echo "Number of confirmations: {$confirmations}";
```

### Pay to a Bitcoin Address

[](#pay-to-a-bitcoin-address)

```
$address = "bc1qlaee57ehqfe2388muudvrf7wvuw2p3lwz0kzh4";
$amount = 0.001;
$fee = 0.00001;
$feerate = NULL;
$fromAddr = "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";
$fromCoins = NULL;
$change = "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";
$nocheck = false;
$unsigned = false;
$replaceByFee = true;

$response = $electrum->pay($address, $amount, $fee, $feerate, $fromAddr, $fromCoins, $change, $nocheck, $unsigned, $replaceByFee);
echo "TXID: " . json_encode($response);
```

### Pay to Multiple Addresses

[](#pay-to-multiple-addresses)

```
$outputs = [
  [
    "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
    0.002
  ],
  [
    "bc1qlaee57ehqfe2388muudvrf7wvuw2p3lwz0kzh4",
    0.0015
  ],
  [
    "bc1qj5nd9hj43wg4t08ynkykt40n3lerg2pt9598q4",
    5.9216
  ]
];
$fee = 0.0009;
$feerate = NULL;
$fromAddr = "bc1plgjpn3cr5khxfee0k40py8njx0qcejrqldldnedqrshvut64jlvs467hnr";
$fromCoins = NULL;
$change = "bc1pqys8mqkneumdyncyz42ljd5zl9gqw4pryd9xsj9gnx5cw6rlvn0sjhdlhy";
$nocheck = false;
$unsigned = false;
$replaceByFee = false;

$response = $electrum->payToMany($outputs, $fee, $feerate, $fromAddr, $fromCoins, $change, $nocheck, $unsigned, $replaceByFee);
echo "TXID: " . json_encode($response);
```

### Load a Wallet

[](#load-a-wallet)

```
//Load the wallet instantiated
$electrum->loadWallet();
```

### Get Wallets Currently Open

[](#get-wallets-currently-open)

```
$wallets = $electrum->getWalletsOpen();
echo "Open wallets: " . json_encode($wallets);
```

### Notify of Address Changes (Webhooks) \[Not recommended, could fail\]

[](#notify-of-address-changes-webhooks-not-recommended-could-fail)

```
$address = "bc1pce8yk5epjlqrpnnavelul54ed6663tjqv6taz3gq9cte979624uqjjrv55";
$yourUrl = "https://your-webhook-url";
$response = $electrum->notify($address, $yourUrl);
echo "Notify response: " . json_encode($response);
```

### Delete Address Notification

[](#delete-address-notification)

```
$address = "bc1pce8yk5epjlqrpnnavelul54ed6663tjqv6taz3gq9cte979624uqjjrv55";
$response = $electrum->deleteNotify($address);
echo "Notification deleted: " . json_encode($response);
```

### Get Private Key of Address in wallet

[](#get-private-key-of-address-in-wallet)

```
$address = "bc1pce8yk5epjlqrpnnavelul54jjrv55";
$privateKey = $electrum->getPrivateKeys($address);
echo "Private key: " . $privateKey;
```

### Get Seed of the Wallet

[](#get-seed-of-the-wallet)

```
$seed = $electrum->getSeed();
echo "Wallet seed: " . $seed;
```

### If the method you need doesn't exist, make a custom call.

[](#if-the-method-you-need-doesnt-exist-make-a-custom-call)

```
$method = "getaddressunspent";
$params = [
  'address' => "bc1pce8yk5epjlqrpnnavelul54ed6663tjqv6taz3gq9cte979624uqjjrv55"
];
$response = $electrum->custom($method, $params);
echo "Response: " . $response;
```

### Get estimate fee, bests inputs and suggest change address.

[](#get-estimate-fee-bests-inputs-and-suggest-change-address)

```
$outputs = [
	[
		"bc1qq4khfcyhnds27zqc8wldxu97lzr7u233t8n3e3",
		0.00010604
	],
	[
		"bc1qrdzwvaj84lwlkclp6ruz6y4c6ac7whqltjl6w9",
		0.00010000
	]
];

$checkBalance = true;

$infos = $electrum->getInfosBeforeTransaction($outputs, $checkBalance);
echo json_encode($infos);
```

#### And result are:

[](#and-result-are)

```
{
   "error":false,
   "msg":"Success",
   "data":{
      "inputs":"bc1pce8yk5epjlqrpnnavelul54ed6663tjqv6txxx,bc1pce8yk5epjlqrpnnavelul54ed6663tjqv6taz3",
      "outputs":[
         [
            "bc1qq4khfcyhnds27zqc8wldxu97lzr7u233t8n3e3",
            0.00010604
         ],
         [
            "bc1qrdzwvaj84lwlkclp6ruz6y4c6ac7whqltjl6w9",
            0.0001
         ]
      ],
      "num_inputs":2,
      "num_outputs":2,
      "suggest_change":"bc1qlaee57ehqfe2388muudvrf7wvuw2p3lwz0kzh4",
      "estimated_fee":"0.00000327"
   }
}
```

Error Handling
--------------

[](#error-handling)

### Every RPC call that fails will throw an exception.

[](#every-rpc-call-that-fails-will-throw-an-exception)

### You can handle these exceptions using simple try-catch blocks:

[](#you-can-handle-these-exceptions-using-simple-try-catch-blocks)

```
try{
    $electrum->start();
}catch(Exception $e){
    echo "Error: " . $e->getMessage();
}
```

Contribution:
-------------

[](#contribution)

Contributions are welcome! If you find a bug or have suggestions for improvements.

Feel free to open an [issue](https://github.com/jeankassio/ElectrumPHP/issues) or submit a [Pull Request](https://github.com/jeankassio/ElectrumPHP/pulls).

License:
--------

[](#license)

This project is licensed under the [MIT License](https://github.com/jeankassio/ElectrumPHP/blob/main/LICENSE) - see the LICENSE.md file for details.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance57

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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 ~22 days

Recently: every ~67 days

Total

15

Last Release

285d ago

Major Versions

0.99 → 1.0.12024-11-11

PHP version history (2 changes)0.22PHP &gt;=7.4

0.96PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b2796e8c233678ec7c8fb3317aa075d1da548ca7198ddd280ab9aefd944055f?d=identicon)[jeankassio](/maintainers/jeankassio)

---

Top Contributors

[![jeankassio](https://avatars.githubusercontent.com/u/26697873?v=4)](https://github.com/jeankassio "jeankassio (30 commits)")

---

Tags

apibitcoinbitcoin-apibitcoin-walletelectrumelectrum-serverelectrum-walletelectrumphpjson-rpcjsonrpcphp

### Embed Badge

![Health badge](/badges/jeankassio-electrumphp/health.svg)

```
[![Health](https://phpackages.com/badges/jeankassio-electrumphp/health.svg)](https://phpackages.com/packages/jeankassio-electrumphp)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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