accounts.php 596 B

123456789101112131415161718192021222324
  1. <?php
  2. require('./exampleBase.php');
  3. $eth = $web3->eth;
  4. echo 'Eth Get Account and Balance' . PHP_EOL;
  5. $eth->accounts(function ($err, $accounts) use ($eth) {
  6. if ($err !== null) {
  7. echo 'Error: ' . $err->getMessage();
  8. return;
  9. }
  10. foreach ($accounts as $account) {
  11. echo 'Account: ' . $account . PHP_EOL;
  12. $eth->getBalance($account, function ($err, $balance) {
  13. if ($err !== null) {
  14. echo 'Error: ' . $err->getMessage();
  15. return;
  16. }
  17. echo 'Balance: ' . $balance . PHP_EOL;
  18. });
  19. }
  20. });