From 4d589b7870b0ea48341c29a3c2fccd2c9e6888ad Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Wed, 20 Dec 2017 16:02:20 +0800 Subject: [PATCH] accounts example --- examples/accounts.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 examples/accounts.php diff --git a/examples/accounts.php b/examples/accounts.php new file mode 100644 index 0000000..3125d34 --- /dev/null +++ b/examples/accounts.php @@ -0,0 +1,27 @@ +eth; + +echo 'Eth Get Account and Balance' . PHP_EOL; +$eth->accounts(function ($err, $accounts) use ($eth) { + if ($err !== null) { + echo 'Error: ' . $err->getMessage(); + return; + } + foreach ($accounts->result as $account) { + echo 'Account: ' . $account . PHP_EOL; + + $eth->getBalance($account, function ($err, $balance) { + if ($err !== null) { + echo 'Error: ' . $err->getMessage(); + return; + } + echo 'Balance: ' . $balance->result . PHP_EOL; + }); + } +}); \ No newline at end of file