eiyaro / core-php
处理 EIYARO API 的类集合
v0.1.16
2024-05-07 22:11 UTC
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^7.8
README
处理 EIYARO
的 API
的类集合。
示例
常见代码
include __DIR__ . '/vendor/autoload.php'; $base_uri = 'https://api.eiyaro.com'; $accessToken = null; use EIYARO\API; $api = new API($base_uri, $accessToken);
网络信息
echo "== Net Info ==\n"; $netInfo = $api->getNetInfo(); echo json_encode($netInfo) . "\n"; echo "==============\n\n";
区块计数
echo "== Block Count ==\n"; $blockCount = $api->getBlockCount(); echo "Height: {$blockCount}\n"; echo "=================\n\n";
区块
echo "== Block ==\n"; $block = $api->getBlock($6635); echo "Block({$blockCount}): {$block->hash}\n"; echo "===========\n\n";
交易
echo "== Transaction ==\n"; try { $transaction = $api->getTransaction("fc64be31e56a448879f9984599cafead466ec5b1a985c6ce8e6d45685c55b7d1"); echo json_encode($transaction, JSON_PRETTY_PRINT) . "\n"; } catch (Exception $e) { echo "Error: ". $e->getMessage() ."\n"; } echo "===========\n\n";
列出待处理交易
echo "== List Pending Transactions ==\n"; $transactions = $api->getPendingTransactions(); echo json_encode($transactions, JSON_PRETTY_PRINT)."\n"; echo "===========\n\n";
获取待处理交易
echo "== Get Pending Transaction ==\n"; $transaction = $api->getPendingTransaction("fc64be31e56a448879f9984599cafead466ec5b1a985c6ce8e6d45685c55b7d1"); echo json_encode($transaction, JSON_PRETTY_PRINT)."\n"; echo "===========\n\n";
列出资产
echo "== List Assets ==\n"; $assets = $api->getAssets(); echo json_encode($assets, JSON_PRETTY_PRINT)."\n"; echo "===========\n\n";
获取资产
echo "== Get Asset ==\n"; $asset = $api->getAsset('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); echo json_encode($asset, JSON_PRETTY_PRINT)."\n"; echo "===========\n\n";