https://github.com/sephynox/phpblock
A lightweight asynchronous PHP server/client for blockchain networks.
https://github.com/sephynox/phpblock
async blockchain ethereum jsonrpc php react rest
Last synced: about 1 year ago
JSON representation
A lightweight asynchronous PHP server/client for blockchain networks.
- Host: GitHub
- URL: https://github.com/sephynox/phpblock
- Owner: sephynox
- License: mit
- Created: 2021-03-07T16:57:54.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-24T20:44:33.000Z (about 5 years ago)
- Last Synced: 2025-04-11T02:05:35.400Z (about 1 year ago)
- Topics: async, blockchain, ethereum, jsonrpc, php, react, rest
- Language: PHP
- Homepage:
- Size: 289 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# PHPBlock
A lightweight asynchronous `PHP` server/client for blockchain networks.
[](https://github.com/sephynox/phpblock/actions/workflows/php.yml)
> Currently in development. Not all endpoints are available. Help welcome!
Table of Contents
-----------------
- [Supported Platforms](#supported-platforms)
- [Future Platforms](#future-platforms)
- [Documentation](#documentation)
- [Quick Start Example](#quick-start-example)
- [Promises Example](#promises-example)
- [Install](#install)
- [Testing](#testing)
- [License](#license)
- [Donate](#donate)
TODO
## Supported Platforms
* Ethereum
### Future Platforms
* Cardano
### Quick Start Example
Call the Ethereum `eth_protocolversion` endpoint.
```php
ethProtocolVersion()
->then(function (string $version) {
echo "The protocol version is: " . $version . "\n";
});
$Ethereum->run();
```
### Promises Example
You can chain calls and pass along additional information to next the link in
the promise chain.
```php
ethSendTransaction($sendTransaction)
->then(function (Hash32 $hash32) use ($Ethereum) {
# Pass additional values easily similar to a tuple.
return pass($Ethereum->ethGetTransactionByHash($hash32), $hash32);
})->then(function (array $data) {
[$receiveTransaction, $hash32] = $data;
if ($receiveTransaction->hash == $hash32) {
echo "The hashes match!";
}
});
$Ethereum->run();
```
## Install
Get started quickly [using Composer](https://getcomposer.org).
```
$ composer require phpblock/core
```
## Testing
In order to run tests, you must first clone this repo and then install the
dependencies [through Composer](https://getcomposer.org):
```bash
$ composer install
```
You can then use the
[geth client](https://geth.ethereum.org/docs/install-and-build/installing-geth)
or [ganache-cli](https://github.com/trufflesuite/ganache-cli) to test
Ethereum RPC calls. You can also install the
[ganache client on Windows](https://www.trufflesuite.com/ganache).
```bash
#Using geth (Ubuntu):
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
#Using geth (OS X & brew):
brew tap ethereum/ethereum
brew install ethereum
brew install ethereum --devel
#Using ganache-cli (npm)
npm install -g ganache-cli
ganache-cli
```
This project uses PHPUnit and PHPBench. To run the test suite, enter the
project root and run:
```bash
$ composer run-script check
```
## License
MIT, see [LICENSE file](LICENSE).
## Donate
**BTC**: bc1qkqsfuaptqcslwmxh5lz2utxls4pe7wnjhepa2s
**ETH**: 0x00E069d105F61564530859A35FE0D007C3536a35
**ADA**: addr1qywvljkfnyyey38te86tshjscn6yw25c069lf82jfjgv57m3txy8f0nf4wnjwcr8uxmlg9wk7lt6uu7g5w9x077v8lwqgsulw6
**DOGE**: D949UWaLauvKyhX6PNuXGavmMNS6uFcjfS