Monero daemon and wallet RPC client library written in modern PHP.
- Implements Monero wallet and daemon rpc methods
- Support authentication for the wallet and daemon rpc servers
- Fully strongly typed and strict_types enabled
- Minimal dependencies
- PSR-18 compatible, so different http client libraries can be used
You can install the package with Composer, at this this time minimum-stability has to be set to dev:
composer require refring/monero-rpc-phpWhen your project does not have a http client available yet, you should require one as well.
Different http clients can be used:
composer require guzzlehttp/guzzleOther http clients
composer require symfony/http-client psr/http-client nyholm/psr7composer require kriswallsmith/buzz nyholm/psr7composer php-http/curl-clientFor the wallet rpc client:
$walletClient = (new \RefRing\MoneroRpcPhp\ClientBuilder('http://127.0.0.1:18081/json_rpc'))
->buildWalletClient();
echo $walletClient->getVersion()->version;Daemon rpc client:
$daemonClient = (new \RefRing\MoneroRpcPhp\ClientBuilder('http://127.0.0.1:18081/json_rpc'))
->buildDaemonClient();
echo $daemonClient->getVersion()->version;$daemonClient = (new \RefRing\MoneroRpcPhp\ClientBuilder('http://127.0.0.1:18081/json_rpc'))
->withAuthentication('foo', 'bar')
->buildDaemonClient();
echo $daemonClient->getVersion()->version;Configuring a proxy is specific to the http client library.
Below is a Symfony Http Client example for a socks5 proxy:
$httpClient = new Psr18Client(new CurlHttpClient([
'http_version' => '2.0',
'proxy' => 'socks5://username:password@127.0.0.1:9999',
]));
$daemonClient = (new \RefRing\MoneroRpcPhp\ClientBuilder('http://examplenode/json_rpc'))
->withHttpClient($httpClient)
->buildDaemonClient();The client builder also supports injecting a logger and/or a http client:
$httpClient = new \Symfony\Component\HttpClient\Psr18Client();
$logger = new \Psr\Log\NullLogger();
$daemonClient = (new \RefRing\MoneroRpcPhp\ClientBuilder('http://127.0.0.1:18081/json_rpc'))
->withHttpClient($httpClient)
->withLogger($logger)
->buildDaemonClient();// Try to create a wallet, or open it when it already exists
try{
$walletClient->createWallet('testwallet', 'English', 'password');
} catch (WalletExistsException $e) {
$walletClient->openWallet('testwallet', 'password');
} catch(MoneroRpcException $e) {
echo 'An error occured: '.$e->getMessage();
}
$baseAddressData = $walletClient->getAddress();
$subAddressData = $walletClient->createAddress();
printf("BaseAddress: %s\nSubAddress: %s\n", $baseAddressData->address, $subAddressData->address);
// Create another account
$newAccountData = $walletClient->createAccount('another account');
$newAccountSubAddress = $walletClient->createAddress($newAccountData->accountIndex);
printf("Account %d\nBaseAddress: %s\nSubAddress: %s", $newAccountData->accountIndex, $newAccountData->address, $newAccountSubAddress->address);The project has unit tests and integration tests, the unit tests can be run using composer test:unit
To run the integration tests, you'll need docker and docker compose or you could run monerod and monero-wallet-rpc on your own.
If you have the docker stack installed, go to the tests folder and run docker compose up. Note that the daemon will run on port 18081 and monero-wallet-rpc will run on port 18083.
After that, run composer test:integration to run the integration tests.
Only the latest 3 point releases of Monero are actively supported and covered by integration tests.
See CONTRIBUTING.md
See CHANGELOG.md
The MIT License (MIT). Please see License File for more information.
- monero-rpc-rs - Parts of this project served as inspiration.
- monero-php - Thanks for providing the php ecosystem with a Monero library during all these years!
- Monero - Thanks to everybody involved!
If this library has been valuable to you, please consider donating some XMR to support its continued development.

87EXWd4R8SwDZqx3wdtHoygSX6iEtY5geQxksy7dK6Kb91h3Rb195PbXKqFQcAezP3UbXD5pxPrtQcd2V3t8962U9MFJaWQ