Ejemplo n.º 1
0
<?php

// # Get Block With Paging
// By default, we only return the 20 first transactions. This method allows you to retrieve next 20 transactions.
//
// API called: '/v1/btc/main/blocks/0000...0000c504bdea...44328?txstart=20&limit=20'
require __DIR__ . '/../bootstrap.php';
$blockClient = new \BlockCypher\Client\BlockClient();
// TX list begins at 'txstart' and we only get 'limit' transactions at once
$params = array('txstart' => 1, 'limit' => 1);
try {
    $block = $blockClient->get('0000000000000000c504bdea36e531d8089d324f2d936c86e3274f97f8a44328', $params, $apiContexts['BTC.main']);
} catch (Exception $ex) {
    ResultPrinter::printError("Get Block With Paging", "Block", '0000000000000000c504bdea36e531d8089d324f2d936c86e3274f97f8a44328', null, $ex);
    exit(1);
}
ResultPrinter::printResult("Get Block With Paging", "Block", $block->getHash(), null, $block);
return $block;
Ejemplo n.º 2
0
<?php

// # Get Multiple Blocks
// This method allows you to retrieve details about multiple blocks at once.
//
// API called: '/v1/btc/main/blocks/5;6;7'
//
// You can use height or hash and mix them in the same $blockList
require __DIR__ . '/../bootstrap.php';
$blockClient = new \BlockCypher\Client\BlockClient();
$blockList = array('5', '6', '7');
try {
    $blocks = $blockClient->getMultiple($blockList, array(), $apiContexts['BTC.main']);
} catch (Exception $ex) {
    ResultPrinter::printError("Get Multiple Blocks", "Blocks", implode(",", $blockList), null, $ex);
    exit(1);
}
ResultPrinter::printResult("Get Multiple Blocks", "Blocks", implode(",", $blockList), null, $blocks);
return $blocks;
Ejemplo n.º 3
0
<?php

// # Get Block By Height
// The Block resource allows you to retrieve details about a Block.
//
// API called: '/v1/btc/main/blocks/293000'
require __DIR__ . '/../bootstrap.php';
$blockClient = new \BlockCypher\Client\BlockClient();
try {
    $block = $blockClient->get('293000', array(), $apiContexts['BTC.main']);
} catch (Exception $ex) {
    ResultPrinter::printError("Get Block By Height", "Block", '293000', null, $ex);
    exit(1);
}
ResultPrinter::printResult("Get Block By Height", "Block", $block->getHeight(), null, $block);
return $block;
Ejemplo n.º 4
0
<?php

// # Get Block
// The Block resource allows you to retrieve details about a Block.
//
// API called: '/v1/btc/main/blocks/0000000000000...f97f8a44328'
require __DIR__ . '/../bootstrap.php';
$blockClient = new \BlockCypher\Client\BlockClient($apiContexts['BTC.main']);
try {
    $block = $blockClient->get('0000000000000000c504bdea36e531d8089d324f2d936c86e3274f97f8a44328');
} catch (Exception $ex) {
    ResultPrinter::printError("Get Block", "Block", '0000000000000000c504bdea36e531d8089d324f2d936c86e3274f97f8a44328', null, $ex);
    exit(1);
}
ResultPrinter::printResult("Get Block", "Block", $block->getHash(), null, $block);
return $block;