PHPackages                             nimiq/utils - 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. nimiq/utils

ActiveLibrary

nimiq/utils
===========

PHP Utilities for Nimiq

0.1.0(6y ago)34Apache-2.0PHPPHP ^7.2

Since Jun 17Pushed 6y ago1 watchersCompare

[ Source](https://github.com/nimiq/php-utils)[ Packagist](https://packagist.org/packages/nimiq/utils)[ Docs](https://github.com/nimiq/php-utils)[ RSS](/packages/nimiq-utils/feed)WikiDiscussions master Synced 2mo ago

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

Nimiq PHP Utilities
===================

[](#nimiq-php-utilities)

This is a collection of utility classes for working with Nimiq primitives in PHP. It is not meant to enable a Nimiq network node in PHP, but rather to verify signatures, derive and validate addresses and to work with serialized primitives in a PHP environment. This collection is planned to grow over time when the need arises or by additions from the community.

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

[](#installation)

The Nimiq PHP Utilities are availabe via the [Packagist package registry](https://packagist.org/packages/nimiq/utils) and can be installed with [Composer](https://getcomposer.org):

```
composer require nimiq/utils
```

*Please note that PHP &gt;= 7.2 with an installed `sodium` extention is required to use these utilities. Please make sure that you have your operating system's equivalent of the `php-sodium` package installed or that you activate the sodium extension in your hosting's PHP settings.*

Usage
-----

[](#usage)

The utility classes are available in the `Nimiq\Utils` namespace:

```
use Nimiq\Utils\AddressUtils;
use Nimiq\Utils\SignatureUtils;
use Nimiq\Utils\RpcUtils;
```

To generate byte-encoded strings from HEX representations, you can use [`sodium_hex2bin()`](https://paragonie.com/book/pecl-libsodium/read/03-utilities-helpers.md#hex2bin), for example:

```
$public_key = sodium_hex2bin('873279e12d5af18c4e899a781e55711f7910ed8ddb85b2179ece38a570253527');
```

### AddressUtils

[](#addressutils)

```
AddressUtils::pubkey2address(string $public_key[, bool $with_spaces = true]): string
```

Convert a public key into a Nimiq userfriendly address.

- `$public_key` A byte-encoded string of length 32 representing a Nimiq public key.
- `$with_spaces` \[optional\] Set to FALSE to output the address without spaces.

### SignatureUtils

[](#signatureutils)

```
SignatureUtils::verify(string $signature, string $data, string $public_key): bool
```

Verify a signature for the given data and public key.

- `$signature` A byte-encoded string representing a Nimiq signature.
- `$data` A byte-encoded string representing the data that the signature should be verified for.
- `$public_key` A byte-encoded string representing the Nimiq public key of the signer.

```
SignatureUtils::verify_message(string $signature, string $message, string $public_key): bool
```

Verify a message signature for the given message and public key.

*Message signatures are different from regular signatures in that the message is prefixed and hashed before being signed. This method applies these same manipulations to the message before verifying the signature.*

- `$signature` A byte-encoded string representing a Nimiq message signature.
- `$message` The plain-text representation of the message that the signature should be verified for.
- `$public_key` A byte-encoded string representing the Nimiq public key of the signer.

### RpcUtils

[](#rpcutils)

```
RpcUtils::prepareRedirectInvocation(string $targetURL, int $id, string $returnURL, string $command, array $args, string $responseMethod): string
```

Generate a redirect URL with the parameters encoded in the URL fragment.

- `$targetURL` The base URL to redirect to, including paths and query parameters (a fragment is discarded).
- `$id` A numeric ID for the RPC request, must be &gt;= 0.
- `$returnURL` The URl to redirect back to, when the requests succeeds or fails.
- `$command` The name of the function that should be called.
- `$args` An array of function arguments to pass to the called function.
- `$responseMethod` How to receive the response: 'message' (postMessage), 'url' (GET redirect), or 'post' (POST redirect)

> **Note:** Binary strings are not yet supported in `$args`!

Development
-----------

[](#development)

The sodium cryptographic methods are best documented in the developer's documentation: .

### Setup

[](#setup)

1. Use PHP &gt;= 7.2
2. [Install the `sodium` extension](https://paragonie.com/book/pecl-libsodium/read/00-intro.md#installing-extension)
3. Verify that you have the sodium extension correctly installed by running `php test/version_check.php` - if it displays the extension's version numbers, everything is good to go

### Testing

[](#testing)

To execute a (minimal) test of these utilities' functionality, run:

```
php test/test.php
```

The expected output is:

```
Is valid: bool(true)
Address:  NQ03 VDL0 TSF5 CFNX VNCL 4MGK 0BX7 150E VMXA

```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

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

Unknown

Total

1

Last Release

2524d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/86f09db8939227f1827dcb6af5aed970dbfc39364f4821e89a9ed7d52464f277?d=identicon)[nimiq](/maintainers/nimiq)

---

Top Contributors

[![sisou](https://avatars.githubusercontent.com/u/1828163?v=4)](https://github.com/sisou "sisou (8 commits)")

---

Tags

nimiqblockchainnimiq

### Embed Badge

![Health badge](/badges/nimiq-utils/health.svg)

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

###  Alternatives

[olifanton/ton

PHP library for The Open Network blockchain

8849.8k2](/packages/olifanton-ton)[nimiq/xpub

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

123.4k](/packages/nimiq-xpub)[rootsoft/algorand-php

Community SDK to interact with the Algorand network, in PHP &amp; Laravel

4314.6k](/packages/rootsoft-algorand-php)[paragonie/blakechain

Hash chain using BLAKE2b

242.9k3](/packages/paragonie-blakechain)[mocking-magician/coinbase-pro-sdk

Library for coinbase pro API calls

223.2k](/packages/mocking-magician-coinbase-pro-sdk)[hardcastle/xrpl_php

PHP SDK / Client for the XRP Ledger

129.7k5](/packages/hardcastle-xrpl-php)

PHPackages © 2026

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