PHP code example of make-software / casper-php-sdk

1. Go to this page and download the library: Download make-software/casper-php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

make-software / casper-php-sdk example snippets


$nodeUrl = 'http://127.0.0.1:7777';
$headers = array('Authorization' => 'Bearer 6ae6c8b31f09df244019ffef60c274e4'); // Optional

$client = new Casper\Rpc\RpcClient($nodeUrl, $headers);

$deploy = $client->getDeploy('fa815fc43c38da30f6ab4e5a6c8a1b31f09df2bf4b344019ffef60c1270d4e49');

$deployHeader = $deploy->getHeader();
$creationTime = $deployHeader->getTimestamp();

$auctionState = $client->getAuctionState();

$stateRootHash = $auctionState->getStateRootHash();
$blockHeight = $auctionState->getBlockHeight();

$peers = $client->getPeers();

foreach ($peers as $peer) {
    ...
}

$latestBlock = $client->getLatestBlock();
$latestBlockHash = $latestBlock->getHash();
shell
export CASPER_PHP_SDK_TEST_NODE_URL="http://127.0.0.1:7777" && php vendor/bin/phpunit tests