PHPackages                             andkom/php-bitcoin-address - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. andkom/php-bitcoin-address

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

andkom/php-bitcoin-address
==========================

A simple P2PK, P2PKH, P2SH, P2WPKH, P2WSH output script/address generator.

2.0.1(2y ago)2086711[1 PRs](https://github.com/andkom/php-bitcoin-address/pulls)1MITPHPPHP &gt;=7.1

Since Jan 28Pushed 2y ago2 watchersCompare

[ Source](https://github.com/andkom/php-bitcoin-address)[ Packagist](https://packagist.org/packages/andkom/php-bitcoin-address)[ RSS](/packages/andkom-php-bitcoin-address/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (1)

PHP Bitcoin Address
-------------------

[](#php-bitcoin-address)

A simple P2PK, P2PKH, P2SH, P2WPKH, P2WSH, P2TR output script/address parser/generator/validator.

**Supported types:**

- Pay-To-PubKey (P2PK)
- Pay-To-PubKeyHash (P2PKH)
- Pay-To-Multisig (P2MS)
- Pay-To-ScriptHash (P2SH)
- Pay-To-WitnessPubKeyHash (P2WPKH)
- Pay-To-WitnessScriptHash (P2WSH)
- Pay-To-Taproot (P2TR)
- P2WPKH-over-P2SH
- P2WSH-over-P2SH
- any combination

**Supported networks:**

- Bitcoin
- Bitcoin Testnet
- Bitcoin Gold
- Bitcoin Cash
- Litecoin
- Litecoin Testnet
- Dogecoin
- Dogecoin Testnet
- Viacoin
- Viacoin Testnet
- Dash
- Dash Testnet
- Zcash

### Installation

[](#installation)

```
composer require andkom/php-bitcoin-address
```

### Examples

[](#examples)

Generate a P2PK/P2PKH address:

```
$address = OutputFactory::p2pk($pubKey)->address();
$address = OutputFactory::p2pkh($pubKeyHash)->address();
```

Generate a P2MS address:

```
$address = OutputFactory::p2ms(2, [$pubKey1, $pubKey2, $pubKey3])->address();
```

Generate a P2SH address:

```
$factory = new OutputFactory();
$p2ms = $factory->p2ms(2, [$pubKey1, $pubKey2, $pubKey3]);
$address = $factory->p2sh($p2ms)->address();
```

Generate a P2WPKH address:

```
$address = OutputFactory::p2wpkh($pubKeyHash)->address();
```

Generate a P2WSH address:

```
$factory = new OutputFactory();
$p2ms = $factory->p2ms(2, [$pubKey1, $pubKey2, $pubKey3]);
$address = $factory->p2wsh($p2ms)->address();
```

Generate a P2WPKH-over-P2SH address:

```
$factory = new OutputFactory();
$p2wpkh = $factory->p2wpkh($pubKeyHash);
$address = $factory->p2sh($p2wpkh)->address();
```

Generate a P2WSH-over-P2SH address:

```
$factory = new OutputFactory();
$p2ms = $factory->p2ms(2, [$pubKey1, $pubKey2, $pubKey3]);
$p2wsh = $factory->p2wsh($p2ms);
$address = $factory->p2sh($p2wsh)->address();
```

Generate a P2TR address:

```
$taprootPubKey = Taproot::construct($pubKey);
$address = OutputFactory::p2tr($taprootPubKey)->address();
```

Generate an address from an output script:

```
$address = OutputFactory::fromScript($script)->address();
```

Decode a Bitcoin address:

```
$output = NetworkFactory::bitcoin()->decodeAddress('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH');
```

Get a Bitcoin address type:

```
$type = NetworkFactory::bitcoin()->decodeAddress('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH')->type(); // p2pkh
```

Validate a Bitcoin address:

```
NetworkFactory::bitcoin()->validateAddress('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH'); // true
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity50

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

Total

3

Last Release

949d ago

Major Versions

1.0.0 → 2.0.02023-11-15

PHP version history (2 changes)1.0.0PHP ^7.0

2.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/150830?v=4)[andkom](/maintainers/andkom)[@andkom](https://github.com/andkom)

---

Top Contributors

[![andkom](https://avatars.githubusercontent.com/u/150830?v=4)](https://github.com/andkom "andkom (24 commits)")

---

Tags

addressaddress-parseraddress-validationbitcoinbitcoin-addressbitcoin-scriptoutputschnorrschnorr-signaturesscripttaprootaddressgeneratorbitcoin

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/andkom-php-bitcoin-address/health.svg)

```
[![Health](https://phpackages.com/badges/andkom-php-bitcoin-address/health.svg)](https://phpackages.com/packages/andkom-php-bitcoin-address)
```

###  Alternatives

[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k116.2M674](/packages/symfony-maker-bundle)[simplesoftwareio/simple-qrcode

Simple QrCode is a QR code generator made for Laravel.

2.9k29.5M105](/packages/simplesoftwareio-simple-qrcode)[nimiq/xpub

A simple class to derive BTC and ETH extended public keys and addresses without GMP.

113.9k](/packages/nimiq-xpub)

PHPackages © 2026

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