{"id":16719940,"url":"https://github.com/jeankassio/electrumphp","last_synced_at":"2026-01-28T14:33:00.189Z","repository":{"id":257806481,"uuid":"866317272","full_name":"jeankassio/ElectrumPHP","owner":"jeankassio","description":"PHP library to connect in Electrum JSON-RPC","archived":false,"fork":false,"pushed_at":"2024-11-11T18:47:47.000Z","size":55,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T08:42:05.978Z","etag":null,"topics":["api","bitcoin","bitcoin-api","bitcoin-wallet","electrum","electrum-server","electrum-wallet","electrumphp","json-rpc","jsonrpc","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeankassio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-02T03:07:15.000Z","updated_at":"2024-11-11T18:47:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"6d131daa-9b26-4cac-b158-7c9263d6be70","html_url":"https://github.com/jeankassio/ElectrumPHP","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"e680a0f8489c36d06ccdec61d9967de66be9fc32"},"previous_names":["jeankassio/electrumphp"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeankassio%2FElectrumPHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeankassio%2FElectrumPHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeankassio%2FElectrumPHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeankassio%2FElectrumPHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeankassio","download_url":"https://codeload.github.com/jeankassio/ElectrumPHP/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248196363,"owners_count":21063402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","bitcoin","bitcoin-api","bitcoin-wallet","electrum","electrum-server","electrum-wallet","electrumphp","json-rpc","jsonrpc","php"],"created_at":"2024-10-12T22:04:55.914Z","updated_at":"2026-01-28T14:33:00.183Z","avatar_url":"https://github.com/jeankassio.png","language":"PHP","readme":"# ElectrumPHP\nElectrumPHP is a PHP library designed to interact with the Electrum wallet through RPC calls. \nWith this library, you can manage wallets, generate addresses, check balances, make Bitcoin payments and much more using the Electrum daemon.\n\nUpdate: You can also calculate the ideal estimated fee for your transaction before you make it.\n\n## Requirements\n\n- PHP 8 or higher\n- Curl enabled\n- putenv enabled\n- exec enabled (to start Electrum)\n- Electrum installed and configured on your server\n\n## Installation\n\n### The package can be installed using Composer\n\n```bash\n  composer require jeankassio/electrumphp\n```\n\n## Usage\n### Instantiate the ElectrumPHP Class\n\n```php\nrequire_once(dirname(__FILE__) . \"/path/to/autoload.php\");\n\nuse JeanKassio\\ElectrumPHP;\n\n$walletPath = dirname(__FILE__) . \"/wallet/walletfile\";\n$walletPass = \"0123456789\";\n$rpcUser = \"user\";\n$rpcPass = \"9876543210\";\n$rpcPort = 7777;\n$rpcHost = \"127.0.0.1\";\n$binary = false; //if false, the code find automatically the binary of Electrum\n\n$electrum = new ElectrumPHP($walletPath, $walletPass, $rpcUser, $rpcPass, $rpcPort, $rpcHost, $binary);\n\n```\n\n## Tips\n\nThe 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.\n\n## Methods\n### Start the Electrum Daemon (if you need)\n\n```php\n$electrum-\u003estart();\n```\n### Stop the Electrum Daemon (if you need)\n\n```php\n$electrum-\u003estop();\n```\n\n### Check if Daemon is Running\n\n```php\nif($electrum-\u003eisRunning()){\n    echo \"Electrum daemon is running.\";\n}\n```\n\n### Validate a Bitcoin Address\n\n```php\n$address = \"1PuJjnF476W3zXfVYmJfGnouzFDAXakkL4\";\n$valid = $electrum-\u003evalidate($address);\necho \"The Bitcoin address is \" . ($valid ? \"valid\" : \"invalid\");\n```\n\n\n### Create a New Wallet and receive Seed\n\n```php\n$walletPath = dirname(__FILE__) . \"/wallet/walletfile\";\n$seed = false;\n$password = \"0123456789\";\n$encrypt = true;\n$segwit = true;\n$language = \"english\";\n$entropy = 256;\n$response = $electrum-\u003ecreateWallet($walletPath, $password, $seed, $encrypt, $segwit, $language, $entropy);\necho \"Seed: \" . $response['seed'];\n```\n\n### Create a New Wallet with your seed\n\n```php\n$walletPath = dirname(__FILE__) . \"/wallet/walletfile\";\n$seed = \"excess title assist very badge rain pet purchase device narrow awesome recall\";\n$password = NULL;\n$encrypt = false;\n$segwit = false;\n$response = $electrum-\u003ecreateWallet($walletPath, $password, $seed, $encrypt, $segwit);\necho \"Seed: \" . $response['seed'];\n```\n\n### Create a New Address\n\n```php\n$address = $electrum-\u003ecreateAddress();\necho \"New address: \" . $address;\n```\n\n### Get Address Balance\n\n```php\n$address = \"1PuJjnF476W3zXfVYmJfGnouzFDAXakkL4\";\n$balance = $electrum-\u003egetAddressBalance($address);\necho \"Confirmed: \" . $balance['confirmed'];\necho \"Unconfirmed: \" . $balance['unconfirmed'];\n```\n\n### Get Wallet Balance\n\n```php\n$balance = $electrum-\u003egetWalletBalance();\nif(isset($balance['confirmed'])){\n  echo \"Confirmed: \" . $balance['confirmed'];\n}\n\t\t\t\t\nif(isset($balance['unconfirmed'])){\n  echo \"Unconfirmed: \" . $balance['unconfirmed'];\n}\n\t\t\t\t\nif(isset($balance['unmatured'])){\n  echo \"Unmatured: \" . $balance['unmatured'];\n}\n```\n\n### Get Transaction Details\n\n```php\n$txid = \"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b\";\n$transaction = $electrum-\u003egetTransaction($txid);\necho \"Transaction details: \" . json_encode($transaction);\n```\n\n### Get Number of Confirmations\n\n```php\n$txid = \"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b\";\n$confirmations = $electrum-\u003egetConfirmations($txid); //return int\necho \"Number of confirmations: {$confirmations}\";\n```\n\n\n### Pay to a Bitcoin Address\n\n```php\n$address = \"bc1qlaee57ehqfe2388muudvrf7wvuw2p3lwz0kzh4\";\n$amount = 0.001;\n$fee = 0.00001;\n$feerate = NULL;\n$fromAddr = \"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa\";\n$fromCoins = NULL;\n$change = \"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa\";\n$nocheck = false;\n$unsigned = false;\n$replaceByFee = true;\n\n$response = $electrum-\u003epay($address, $amount, $fee, $feerate, $fromAddr, $fromCoins, $change, $nocheck, $unsigned, $replaceByFee);\necho \"TXID: \" . json_encode($response);\n```\n\n### Pay to Multiple Addresses\n\n```php\n$outputs = [\n  [\n    \"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa\",\n    0.002\n  ],\n  [\n    \"bc1qlaee57ehqfe2388muudvrf7wvuw2p3lwz0kzh4\",\n    0.0015\n  ],\n  [\n    \"bc1qj5nd9hj43wg4t08ynkykt40n3lerg2pt9598q4\",\n    5.9216\n  ]\n];\n$fee = 0.0009;\n$feerate = NULL;\n$fromAddr = \"bc1plgjpn3cr5khxfee0k40py8njx0qcejrqldldnedqrshvut64jlvs467hnr\";\n$fromCoins = NULL;\n$change = \"bc1pqys8mqkneumdyncyz42ljd5zl9gqw4pryd9xsj9gnx5cw6rlvn0sjhdlhy\";\n$nocheck = false;\n$unsigned = false;\n$replaceByFee = false;\n\n$response = $electrum-\u003epayToMany($outputs, $fee, $feerate, $fromAddr, $fromCoins, $change, $nocheck, $unsigned, $replaceByFee);\necho \"TXID: \" . json_encode($response);\n```\n\n### Load a Wallet\n\n```php\n//Load the wallet instantiated\n$electrum-\u003eloadWallet();\n```\n\n### Get Wallets Currently Open\n\n```php\n$wallets = $electrum-\u003egetWalletsOpen();\necho \"Open wallets: \" . json_encode($wallets);\n```\n\n### Notify of Address Changes (Webhooks) [Not recommended, could fail]\n\n```php\n$address = \"bc1pce8yk5epjlqrpnnavelul54ed6663tjqv6taz3gq9cte979624uqjjrv55\";\n$yourUrl = \"https://your-webhook-url\";\n$response = $electrum-\u003enotify($address, $yourUrl);\necho \"Notify response: \" . json_encode($response);\n```\n\n### Delete Address Notification\n\n```php\n$address = \"bc1pce8yk5epjlqrpnnavelul54ed6663tjqv6taz3gq9cte979624uqjjrv55\";\n$response = $electrum-\u003edeleteNotify($address);\necho \"Notification deleted: \" . json_encode($response);\n```\n\n### Get Private Key of Address in wallet\n\n```php\n$address = \"bc1pce8yk5epjlqrpnnavelul54jjrv55\";\n$privateKey = $electrum-\u003egetPrivateKeys($address);\necho \"Private key: \" . $privateKey;\n```\n\n### Get Seed of the Wallet\n\n```php\n$seed = $electrum-\u003egetSeed();\necho \"Wallet seed: \" . $seed;\n```\n\n### If the method you need doesn't exist, make a custom call.\n\n```php\n$method = \"getaddressunspent\";\n$params = [\n  'address' =\u003e \"bc1pce8yk5epjlqrpnnavelul54ed6663tjqv6taz3gq9cte979624uqjjrv55\"\n];\n$response = $electrum-\u003ecustom($method, $params);\necho \"Response: \" . $response;\n```\n\n### Get estimate fee, bests inputs and suggest change address.\n\n```php\n\n$outputs = [\n\t[\n\t\t\"bc1qq4khfcyhnds27zqc8wldxu97lzr7u233t8n3e3\",\n\t\t0.00010604\n\t],\n\t[\n\t\t\"bc1qrdzwvaj84lwlkclp6ruz6y4c6ac7whqltjl6w9\",\n\t\t0.00010000\n\t]\n];\n\n$checkBalance = true;\n\n$infos = $electrum-\u003egetInfosBeforeTransaction($outputs, $checkBalance);\necho json_encode($infos);\n\n```\n#### And result are:\n\n```json\n{\n   \"error\":false,\n   \"msg\":\"Success\",\n   \"data\":{\n      \"inputs\":\"bc1pce8yk5epjlqrpnnavelul54ed6663tjqv6txxx,bc1pce8yk5epjlqrpnnavelul54ed6663tjqv6taz3\",\n      \"outputs\":[\n         [\n            \"bc1qq4khfcyhnds27zqc8wldxu97lzr7u233t8n3e3\",\n            0.00010604\n         ],\n         [\n            \"bc1qrdzwvaj84lwlkclp6ruz6y4c6ac7whqltjl6w9\",\n            0.0001\n         ]\n      ],\n      \"num_inputs\":2,\n      \"num_outputs\":2,\n      \"suggest_change\":\"bc1qlaee57ehqfe2388muudvrf7wvuw2p3lwz0kzh4\",\n      \"estimated_fee\":\"0.00000327\"\n   }\n}\n```\n\n## Error Handling\n### Every RPC call that fails will throw an exception. \n### You can handle these exceptions using simple try-catch blocks:\n\n```php\ntry{\n    $electrum-\u003estart();\n}catch(Exception $e){\n    echo \"Error: \" . $e-\u003egetMessage();\n}\n```\n\n\n## Contribution:\nContributions are welcome! If you find a bug or have suggestions for improvements.\n\nFeel free to open an [issue](https://github.com/jeankassio/ElectrumPHP/issues) or submit a [Pull Request](https://github.com/jeankassio/ElectrumPHP/pulls).\n\n## License:\nThis project is licensed under the [MIT License](https://github.com/jeankassio/ElectrumPHP/blob/main/LICENSE) - see the LICENSE.md file for details.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeankassio%2Felectrumphp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeankassio%2Felectrumphp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeankassio%2Felectrumphp/lists"}