Skip to content
This repository has been archived by the owner on Nov 14, 2022. It is now read-only.

Commit

Permalink
wallets-cli example
Browse files Browse the repository at this point in the history
  • Loading branch information
xboston committed Jul 26, 2019
1 parent ad8111b commit 6dd1ba0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions examples/wallets-cli.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php declare(strict_types=1);

require __DIR__.'/../vendor/autoload.php';

use Metahash\MetaHash;

$crypto = new MetaHash();

$wallets = [
'0x00fa2a5279f8f0fd2f0f9d3280ad70403f01f9d62f52373833' => '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);

0 comments on commit 6dd1ba0

Please sign in to comment.