accounts example
This commit is contained in:
parent
11ffbf93d6
commit
4d589b7870
27
examples/accounts.php
Normal file
27
examples/accounts.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
require('../vendor/autoload.php');
|
||||
|
||||
use Web3\Web3;
|
||||
|
||||
$web3 = new Web3('http://192.168.99.100:8545');
|
||||
$eth = $web3->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;
|
||||
});
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user