From 6dd1ba018ef775b438bea3b1d7bd84463ebdba86 Mon Sep 17 00:00:00 2001 From: boston Date: Fri, 26 Jul 2019 14:18:11 +0300 Subject: [PATCH] wallets-cli example --- examples/wallets-cli.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 examples/wallets-cli.php diff --git a/examples/wallets-cli.php b/examples/wallets-cli.php new file mode 100644 index 0000000..3c91de2 --- /dev/null +++ b/examples/wallets-cli.php @@ -0,0 +1,32 @@ + 'MetaWat.ch', + '0x00333170c3c1d908a1c4918ef3cff4a831eb69581adb42e9ce' => 'MHAG-iTorrent-03', + '0x00760dd55ca9a10fcef7ae4f71ef53356ba8f2bd0fa0efe911' => 'Wallet ICO', +]; + +$balances = $crypto->fetchBalances(\array_keys($wallets)); + +$results = []; +$fullBalance = 0; +$fullDelegated = 0; + +foreach ($balances['result'] as $balanceData) { + $balance = $balanceData['received'] - $balanceData['spent']; + $delegated = isset($balanceData['delegate']) ? $balanceData['delegate'] - $balanceData['undelegate'] : 0; + + $results[] = [ + 'address' => $balanceData['address'], + 'balance' => $balance / 1e6, + 'delegated' => $delegated / 1e6, + ]; +} + +\print_r($results); \ No newline at end of file