Download the PHP package dev404ai/drand-client-php without Composer
On this page you can find all versions of the php package dev404ai/drand-client-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dev404ai/drand-client-php
More information about dev404ai/drand-client-php
Files in dev404ai/drand-client-php
Package drand-client-php
Short Description Minimal-dependency PHP client for the drand randomness beacon. Supports all drand signature schemes and provides fast, verifiable, unbiased public randomness for blockchain, games, lotteries, and any application requiring cryptographically secure randomness.
License MIT
Homepage https://github.com/dev404ai/drand-client-php
Informations about the package drand-client-php
Drand Client for PHP
About
A minimal-dependency PHP client for the drand randomness beacon, providing fast, verifiable, and unbiased public randomness. Supports all drand signature schemes, efficient BLS verification via libblst, and is suitable for blockchain, games, lotteries, and any application requiring cryptographically secure randomness. Easy to install, PSR-4 autoloaded, and fully tested with PHPUnit.
Table of Contents
- Quick Install
- Usage Examples
- Supported Signature Schemes
- Configuration Enums
- Testing
- Contributing
- License
A minimal‑dependency PHP client for the drand randomness beacon.
- Fast BLS‑signature verification via libblst (same core used by Ethereum 2).
- Supports all drand signature schemes: chained, unchained, G1, RFC9380, and BN254 (see below).
- No PECL modules — just enable FFI.
- Composer‑installable, PSR‑4, PHPUnit‑tested.
Use Cases
This library can be used wherever verifiable, unbiased, and public randomness is required, including:
- Random number generation (RNG): Use as a source of entropy for applications needing strong, unpredictable randomness.
- Blockchain and smart contracts: Integrate with on-chain or off-chain systems that require public randomness.
- Games and competitions: Provide fair shuffling, matchmaking, or prize draws.
- Auditable random selection: Any scenario where you need to prove to users that the randomness was not manipulated.
- Betting and gambling platforms: Ensure fair, auditable outcomes for games and bets.
- Online lotteries and raffles: Draw winners transparently and provably at random.
Drand randomness is public, distributed, and cryptographically verifiable, making it suitable for regulated and high-stakes environments.
Supported Signature Schemes
This client supports all major drand signature schemes:
pedersen-bls-chained(default, BLS12-381, chained)pedersen-bls-unchained(BLS12-381, unchained)bls-unchained-on-g1(BLS12-381, G1, legacy)bls-unchained-g1-rfc9380(BLS12-381, G1, RFC9380)bn254-on-g1(BN254, G1, experimental)
Note:
- For G1 and RFC9380 schemes, FFI and libblst are required.
- The client automatically detects and verifies the correct scheme based on chain info.
- BN254 support requires a separate backend (not included by default).
Quick install
1. Install libblst
| Platform | Command |
|---|---|
| Ubuntu / Debian | sudo apt install libblst-dev |
| Arch Linux | sudo pacman -S blst |
| Alpine Linux | apk add blst |
| macOS (Homebrew) | brew install blst |
| Windows | Download blst.dll from the releases and copy it next to php.exe or into %SystemRoot%\System32. |
Important: This project requires the php-ffi extension. Make sure it is installed and enabled in your PHP environment.
On Arch Linux, install it with:
- On other systems, ensure the
ffiextension is enabled in yourphp.ini(see below).You can check if FFI is enabled by running:
If you see
ffiin the output, the extension is enabled.
Alternatively, build from source
2. Enable FFI
Reloading web SAPIs:
CLI picks the change immediately. For PHP‑FPM / Apache reload the service:
3. Install the client via Composer
This pulls the latest tagged release and registers PSR‑4 autoloading.
Verify setup
Usage Examples
Basic Usage
Advanced Configuration
Working with Rounds and Time
Error Handling
Using the Caching Client Directly
Using Multiple Chains
Using the Fastest Node
Selecting Network and Scheme via Configuration
You can use the built-in Networks class for easy selection of mainnet, testnet, or your own custom network:
The chainVerificationParams option ensures you are connecting to the correct network and using the correct signature scheme. The scheme is automatically detected from the chain info.
Advanced Usage Examples
Fetch beacon by time
Get time for a round
Print chain info and signature scheme
Use MultiChainClient and select by beaconID
Use FastestNodeClient
Configuration Enums
This library uses modern PHP 8.2+ enums for configuration:
- Network:
Drand\Client\Network::MAINNET,TESTNET,DEVNET— for selecting network and beaconID. - VerificationMode:
Drand\Client\VerificationMode::ENABLEDorDISABLED— for enabling/disabling beacon signature verification. - CachePolicy:
Drand\Client\CachePolicy::ENABLEDorDISABLED— for enabling/disabling HTTP response caching.
Example: Creating a client with enums
Example: Multi-chain client
Example: Fastest node client
Configuration Files
infection.json.dist: Template for Infection mutation testing configuration. Copy toinfection.jsonto customize locally. Do not commit your localinfection.json.
Contributing
We welcome contributions and pull requests from the community!
For detailed contribution and testing guidelines, see CONTRIBUTING.md.
How to contribute:
- Pull Requests: Pull requests are welcome! Please fork the repository and submit your changes via a PR. Describe your changes and reference any related issues.
- Code style: Follow PSR-12 and the project's existing conventions.
- First-class callables: Use first-class callable syntax (
$obj->method(...)) for passing methods as callables in PHP 8.2+. - Tests: Add or update tests for any new features or bugfixes. Ensure all tests pass.
- Commits: Use clear, descriptive commit messages in English.
- Documentation: Update the README and code comments as needed.
- No unnecessary dependencies: Keep the project minimal and focused.
- Respect security best practices: Never commit secrets or unsafe code.
For major changes, please open an issue first to discuss your proposal.
We appreciate your help in making this project better!
License
This project is dual-licensed under the MIT and Apache 2.0 licenses:
- MIT License (https://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
You may use this project under the terms of either license.
All versions of drand-client-php with dependencies
ext-curl Version *
ext-ffi Version *