#Introduction
This is a PHP client library, used to communicate with the AElf API.
AElf php SDK
In order to install this library via composer run the following command in the console:
$ composer require aelf/aelf-sdk
composer require curl/curl
If you directly clone the sdk You must install composer and execute it in the root directory
"aelf/aelf-sdk": "dev-dev"
1. PHP => 7.0
2. gmp
3. curl
require_once 'vendor/autoload.php';
use AElf\AElf;
$url = '127.0.0.1:8000';
$aelfClient = new AElf($url);
$height = $aelfClient->GetBlockHeight();
You can also see full examples in ./example
;
Interface methods can be easily available by the instance "aelfClient" shown in basic usage. The following is a list of input parameters and output for each method. Check out the Web api reference for detailed Interface description.
public function getBlockHeight();
public function getBlockByHash($blockHash,$includeTransactions = false);
public function getBlockByHeight($blockHeight,$includeTransactions = false);
public function getChainStatus();
public function getContractFileDescriptorSet($address);
public function getCurrentRoundInformationAsync();
public function getTaskQueueStatusAsync();
public function getChainIdAsync();
public function addPeer($address);
public function removePeer($address);
public function getPeers($withMetrics);
public function getNetworkInfo();
public function getTransactionPoolStatus();
public function executeTransaction($input);
public function executeRawTransaction($input);
public function createRawTransaction($input);
public function sendRawTransaction($input);
public function sendTransaction($input);
public function sendTransactions($input);
public function getTransactionResult($transactionId);
public function getTransactionResults($blockHash, $offset = 0, $limit = 10);
public function getMerklePathByTransactionId($transactionId);
public function isConnected();
public function getFormattedAddress($privateKey, $address);
public function getAddressFromPubKey($pubKey) ;
public function getGenesisContractAddress();
public function getContractAddressByName($privateKey, $contractNameHash);
This module contains tests for all services provided by AElf. You can see how to properly use services provided by AElf here.
You need to firstly set necessary parameters to make sure tests can run successfully.
-
Set baseUrl to your target url.
$url = "Http://127.0.0.1:8001";
-
Give a valid privateKey of a node.
$this->privateKey = 'be3abe5c1439899ac2efd0001e15715fd989a3ae11f09e1cb95d320cd4993e2a';
You need to run a local or remote AElf node to run the unit test successfully. If you're not familiar with how to run a node or multiple nodes, please see Running a node / Running multiple nodes for more information.