onzcoin / onz-php-api
A php wrapper for the onz api.
v1.0
2018-10-11 15:06 UTC
Requires
- php: >=7.0.0
- tcdent/php-restclient: ^0.1.6
Requires (Dev)
- phpunit/phpunit: 6.2.*
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-10-04 04:51:20 UTC
README
* OnzPhp - A PHP wrapper for the ONZ API
This is php wrapper for ONZ API written in OOP style.
It's supposed to be a full implementation of the API.
Included in here is a CLI Parser which makes it possible to call all actions from command line.
e.g.:
#+BEGIN_SRC bash
php api.php getBlocks --height=111500
#+END_SRC
** API compatibility
Currently supports ONZ API Version 0.94
The following sections from the onz api are available:
- [x] Accounts
- [x] Loader
- [x] Transactions
- [x] Peers
- [x] Blocks
- [x] Signatures
- [x] Delegates
- [x] Apps
- [x] Multi-signature
** Installation
It's a composer based package. \
Installation is as easy as:
#+BEGIN_SRC sh
composer require onzcoin/onz-php-api
#+END_SRC
** Usage:
*** General
To start communicating with a onz server you need to instanciate onz client and specify the servers ip and port.
This would connect to the official onz testnet.
#+BEGIN_SRC php
$client = new \Onz\Client('https://tnode11.onzcoin.com');
#+END_SRC
*** Accounts
**** Get Account Balance
Request the balance of an account.
#+BEGIN_SRC php
$client->getBalance($address);
#+END_SRC
**** Get Public Key
Get the public key of an account. If the account does not exist the API call will return an error.
#+BEGIN_SRC php
$client->getPublicKey($secret);
#+END_SRC
**** Open Account
Request information about an account. If account with secret does not exist, account will be created.
#+BEGIN_SRC php
$client->openAccount($secret);
#+END_SRC
**** Generate Public Key
Returns the public key of the provided secret key.
#+BEGIN_SRC php
$client->generatePublicKey($secret);
#+END_SRC
**** Get Account Information from Address
Returns account information of an address.
#+BEGIN_SRC php
$client->getAccountInfo($address);
#+END_SRC
**** Get Delegates
Returns delegate accounts by address.
#+BEGIN_SRC php
$client->getDelegates($address);
#+END_SRC
**** Vote Delegates
Vote for the selected delegates. Maximum of 33 delegates at once.
(Note: This is currently not working with onz api. Exception: "a.asset.votes.join is not a function")
#+BEGIN_SRC php
$client->voteDelegates($delegates, $secret, $secondSecret = null, $publicKey = null);
#+END_SRC
*** Loader
**** Get Loading Status
#+BEGIN_SRC php
$client->getLoadingStatus();
#+END_SRC
**** Get Synchronization Status
Get the synchronization status of the client.
#+BEGIN_SRC php
$client->getSynchronizationStatus();
#+END_SRC
**** Get Block Receipt Status
Get the status of last received block. Returns true if block was received in the past 120 seconds.
#+BEGIN_SRC php
$client->getBlockStatus();
#+END_SRC
*** Transactions
**** Get List of Transactions
List of transactions matched by provided parameters.
#+BEGIN_SRC php
$client->listTransactions($blockId, $senderId, $recipientId, $limit, $offset, $orderBy);
#+END_SRC
**** Send Transaction
Send transaction to broadcast network.
#+BEGIN_SRC php
$client->sendTransaction($secret, $amount, $recipientId, $publicKey, $secondSecret);
#+END_SRC
**** Get Transaction
Get transaction that matches the provided id.
#+BEGIN_SRC php
$client->getTransaction($id);
#+END_SRC
**** Get Unconfirmed Transaction
Get unconfirmed transaction that matches the provided id.
#+BEGIN_SRC php
$client->getUnconfirmedTransaction($id);
#+END_SRC
**** Get List of Unconfirmed Transactions
Gets a list of unconfirmed transactions.
#+BEGIN_SRC php
$client->listUnconfirmedTransactions();
#+END_SRC
**** Get List of Queued Transactions
Gets a list of queued transactions.
#+BEGIN_SRC php
$client->listQueuedTransactions();
#+END_SRC
**** Get Specific Queued Transaction
Get queued transaction that matches the provided id.
#+BEGIN_SRC php
$client->getQueuedTransaction($id);
#+END_SRC
*** Peers
**** Get Peers List
Gets list of peers from provided filter parameters.
#+BEGIN_SRC php
$client->getPeerList($state, $os, $version, $limit, $offset, $orderBy);
#+END_SRC
**** Get Peer Version/Build Time
Gets a list peer versions and build times
#+BEGIN_SRC php
$client->getPeerVersion();
#+END_SRC
**** Get Peer
Gets peer by IP address and port.
#+BEGIN_SRC php
$client->getPeer($ip, $port);
#+END_SRC
*** Blocks
**** Get Blocks
Gets all blocks by provided filter(s).
#+BEGIN_SRC php
$client->getBlocks($totalFee, $totalAmount, $previousBlock, $height, $generatorPublicKey, $limit, $offset, $orderBy);
#+END_SRC
**** Get Block
Gets block by provided id.
#+BEGIN_SRC php
$client->getBlock($id);
#+END_SRC
**** Get Blockchain Fee
Get transaction fee for sending "normal" transactions.
#+BEGIN_SRC php
$client->getBlockchainFee();
#+END_SRC
**** Get Blockchain Fees Schedule
Get transaction fee for all types of transactions.
#+BEGIN_SRC php
$client->getBlockchainFees();
#+END_SRC
**** Get Blockchain Reward Schedule
Gets the forging reward for blocks.
#+BEGIN_SRC php
$client->getBlockchainReward();
#+END_SRC
**** Get Total Supply of Onz Tokens (ONZ)
Gets the total amount of Onz in circulation
#+BEGIN_SRC php
$client->getTotalSupply();
#+END_SRC
**** Get Blockchain Height
Gets the blockchain height of the client.
#+BEGIN_SRC php
$client->getBlockchainHeight();
#+END_SRC
**** Get Status of Height, Fee, Milestone, Blockreward and Supply
Gets status of height, fee, milestone, blockreward and supply
#+BEGIN_SRC php
$client->getStatusInfos();
#+END_SRC
**** Get Blockchain Nethash
Gets the nethash of the blockchain on a client.
#+BEGIN_SRC php
$client->getBlockchainNethash();
#+END_SRC
**** Get Blockchain Milestone
Gets the milestone of the blockchain on a client.
#+BEGIN_SRC php
$client->getBlockchainMilestone();
#+END_SRC
*** Signatures
**** Get Signature Fees
Gets the second signature status of an account.
#+BEGIN_SRC php
$client->getSignatureFee();
#+END_SRC
**** Add Second Signature
Add a second signature to an account.
#+BEGIN_SRC php
$client->addSecondSignature($secret, $secondSecret, $publicKey);
#+END_SRC
*** Delegates
**** Enable Delegate on Account
Puts request to create a delegate.
#+BEGIN_SRC php
$client->createDelegate($secret, $username, $secondSecret);
#+END_SRC
**** Get Delegates List
Gets list of delegates by provided filter.
#+BEGIN_SRC php
$client->getDelegateList($limit, $offset, $orderBy);
#+END_SRC
**** Get Delegate
Gets delegate by public key or username.
#+BEGIN_SRC php
$client->getDelegate($publicKey, $username);
#+END_SRC
**** Search for Delegates
Search for Delegates by "fuzzy" username.
#+BEGIN_SRC php
$client->searchDelegate($username, $orderBy);
#+END_SRC
**** Get Delegates Count
Get total count of registered delegates.
#+BEGIN_SRC php
$client->getDelegateCount();
#+END_SRC
**** Get votes of account
Get votes by account wallet address.
#+BEGIN_SRC php
$client->getDelegateVotes($address);
#+END_SRC
**** Get Voters
Get voters of delegate.
#+BEGIN_SRC php
$client->getDelegateVoters($publicKey);
#+END_SRC
**** Enable Forging on Delegate
Enables forging for a delegate on the client node.
#+BEGIN_SRC php
$client->enableForging($secret);
#+END_SRC
**** Disable Forging on Delegate
Disables forging for a delegate on the client node.
#+BEGIN_SRC php
$client->disableForging($secret);
#+END_SRC
**** Get Forged by Account
Get amount of Onz forged by an account.
#+BEGIN_SRC php
$client->getForgedByAccount($generatorPublicKey, $start, $end);
#+END_SRC
**** Get Next Forgers
Get next delegate lining up to forge.
#+BEGIN_SRC php
$client->getNextForger($limit);
#+END_SRC
*** Apps
**** Registers Apps
Registers a Blockchain Application.
#+BEGIN_SRC php
$client->registerApp($secret, $category, $name, $type, $link, $secondSecret, $publicKey, $description, $tags, $icon);
#+END_SRC
**** Get Apps
Gets a list of Blockchain Applications registered on the network.
#+BEGIN_SRC php
$client->getApps($category, $name, $appType, $link, $limit, $offset, $orderBy);
#+END_SRC
**** Get App
Gets a specific Blockchain Application by registered id.
#+BEGIN_SRC php
$client->getApp($id);
#+END_SRC
**** Search for Apps
Searches for Blockchain Applications by filter(s) on a node.
#+BEGIN_SRC php
$client->searchApps($q, $category, $installed);
#+END_SRC
**** Install App
Installs a app by id on the node.
#+BEGIN_SRC php
$client->installApp($id);
#+END_SRC
**** Installed Apps
Returns a list of installed apps on the requested node.
#+BEGIN_SRC php
$client->getInstalledApps();
#+END_SRC
**** Installed Apps Ids
Returns a list of installed app ids on the requested node.
#+BEGIN_SRC php
$client->getAllInstalledApps();
#+END_SRC
**** Uninstall Apps
Uninstalls a app by id from the requested node.
#+BEGIN_SRC php
$client->uninstallApp($id);
#+END_SRC
**** Launch App
Launches a app by id on the requested node.
#+BEGIN_SRC php
$client->launchApp($id, $params);
#+END_SRC
**** Installing
Returns a list of app ids currently being installed on the requested node.
#+BEGIN_SRC php
$client->installingApp();
#+END_SRC
**** Uninstalling
Returns a list of app ids currently being uninstalled on the client node.
#+BEGIN_SRC php
$client->uninstallingApp();
#+END_SRC
**** Launched
Returns a list of app ids which are currently launched on the client node.
#+BEGIN_SRC php
$client->launchedApps();
#+END_SRC
**** Categories
Returns a full list of app categories.
#+BEGIN_SRC php
$client->getCategories();
#+END_SRC
**** Stop App
Stops a app by id on the requested node.
#+BEGIN_SRC php
$client->stopApp($id);
#+END_SRC
*** Multi-signature
**** Create Multi-signature Account
Create a multi-signature account.
#+BEGIN_SRC php
$client->createMultiSignatureAccount($secret, $lifetime, $min, $keysgroup, $secondSecret);
#+END_SRC
**** Get Multi-signature Accounts
Gets a list of accounts that belong to a multi-signature account.
#+BEGIN_SRC php
$client->getMultiSignatureAccounts($publicKey);
#+END_SRC
**** Sign Multi-signature Transaction
Signs a transaction that is awaiting signature.
#+BEGIN_SRC php
$client->getPendingTransactions($publicKey);
#+END_SRC
**** Get Pending Multi-signature Transactions
Returns a list of multi-signature transactions that waiting for signature by publicKey.
#+BEGIN_SRC php
$client->signPendingTransaction($secret, $transactionId, $publicKey);
#+END_SRC
*** ToDo:
- [x] [1] complete API
- [ ] [2] complete documentation
- [ ] [3] put package on packagist
- [ ] [...] more
*** Support
If you want to support me please consider voting for my onz delegate
- *pelops* (ONZkXgbtn3UXx9VwVVGAtMmKNxuo5Su7cdYc) on MainNet
- *pelops_testnet* (ONZfnjELpTooW64V6CSXg5puP3v6pHTWA265) on TestNet
** Development
If you want to support the development just create a pull request or fork this project.
I'll try to merge everything into the projects asap.
*** Project Supporters
These people have contributed to this project:
- [[https://github.com/OnzCoin/OnzPHP][onzkan]] - since 9/2018
- [[https://github.com/cb0/LiskPHP][cb0]] - since 10/2017
- [[https://github.com/cb0/LiskPHP][diszad]] - since 10/2017
Thanks you very much!
** License
License under GNU General Public License v3.0
Copyright (c) 2018 OnzCoin <hi@onzcoin.com>
OnzPhp is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OnzPhpis distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OnzPhp. If not, see <http://www.gnu.org/licenses/>.