brianhenryie / bh-php-monero-explorer
Monero HTTP client.
Package info
github.com/BrianHenryIE/bh-php-monero-explorer
pkg:composer/brianhenryie/bh-php-monero-explorer
Requires
- php: >=8.4
- ext-json: *
- json-mapper/json-mapper: ^2.25
- psr/http-client-implementation: *
- psr/http-factory-implementation: *
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.8
- cweagans/composer-patches: *
- dealerdirect/phpcodesniffer-composer-installer: *
- guzzlehttp/guzzle: ^7.4
- jaschilz/php-coverage-badger: ^2.0
- mockery/mockery: ^1.5
- phpstan/extension-installer: *
- phpunit/phpcov: *
- phpunit/phpunit: ^12
- psr-mock/http: ^1.0
- squizlabs/php_codesniffer: *
This package is auto-updated.
Last update: 2026-07-18 03:11:30 UTC
README
Monero Explorer PHP Client
A thin, strongly typed PHP SDK for Onion Monero Blockchain Explorer instances' HTTP API, e.g. xmrchain.net.
Monero (XMR) is a private, decentralized cryptocurrency, developed with the goals of privacy and security first, ease of use and efficiency second.
Fetching and parsing JSON is very easy with PHP, so this library's value comes from the typed classes and the documentation in PhpDoc. Please contribute clarifications to functions' purposes.
Use
Before v1.0, function signatures are expected to change as they are properly documented.
composer require --fixed brianhenryie/bh-php-monero-explorer@dev
You also need a PSR-7 implementation and a PSR-17 implementation, the most popular being guzzlehttp/guzzle.
ExplorerApi is a direct mapping of API endpoints to PHP functions.
/** @var Psr\Http\Message\RequestFactoryInterface $requestFactory */ $requestFactory = new \GuzzleHttp\Psr7\HttpFactory(); /** @var Psr\Http\Client\ClientInterface $client */ $client = new \GuzzleHttp\Client(); $explorerApi = new \BrianHenryIE\MoneroExplorer\ExplorerApi( $requestFactory, $client ); /** @var \BrianHenryIE\MoneroExplorer\Model\NetworkInfo $networkInfo */ $networkInfo = $explorerApi->getNetworkInfo(); $lastBlockHeight = $networkInfo->height - 1;
Models are final readonly classes with public properties (PHP >= 8.4 is required).
Privacy:
getOutputs()/getOutputsBlocks()send an address and view key to the explorer server, permanently disclosing that wallet's incoming transactions to its operator. Prefer a self-hosted instance — this repository ships one:
make integration-up # monerod (regtest) + monero-wallet-rpc + xmrblocks; first run compiles monerod + xmrblocks from source (~20 min) make integration-seed # deterministic test chain: 131 blocks, two seeded payments composer test-integration make integration-down
ExplorerTools extends ExplorerApi to add convenience functions.
$explorerTools = new \BrianHenryIE\MoneroExplorer\ExplorerTools( $requestFactory, $client ); $lastBlockHeight = $explorerTools->getLastBlockHeight();
Accept a Monero payment
To accept a payment with Monero...
- Share payment address with customer
- Note the blockchain height at that time
- Periodically/progressively check new blocks since then inspecting for payment
See: examples/VerifyingPaymentsReceived.php.
Implementation
Initial class-monero-explorer-tools.php extracted from monero-integrations/monerowp.
Goals:
- Strongly typed: nested objects now map to models; a few responses (raw miner tx, detailed transaction) remain
stdClass/arrays - Unit tested: 100% should be achievable on what is just a thin wrapper
- Use PSR-7 HTTP client & PSR-17 HTTP factory
- PhpDoc
- Short tutorial
Notes
- API is read-only
- API responses are JSON formatted using the JSend convention
Composer
Runtime dependencies are minimal: JsonMapper/JsonMapper (JsonMapper.net) hydrates responses into the typed models, plus a consumer-supplied PSR-7/PSR-17 HTTP implementation. The JSend response envelope is unwrapped directly in ExplorerApi::callApi() — no JSend library is required.