-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #331 from web3p/feature/ws-provider
feature: new websocket provider
- Loading branch information
Showing
31 changed files
with
974 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ composer.lock | |
# nodejs | ||
node_modules/ | ||
package-lock.json | ||
package.json | ||
package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
require('./exampleBase.php'); | ||
use React\Async; | ||
use React\Promise; | ||
use Web3\Web3; | ||
|
||
$web3 = new Web3('ws://127.0.0.1:8545'); | ||
|
||
$eth = $web3->eth; | ||
|
||
echo 'Eth Get Account and Balance' . PHP_EOL; | ||
$promises = []; | ||
$promises[] = $eth->accounts(function ($err, $accounts) use ($eth) { | ||
if ($err !== null) { | ||
echo 'Error: ' . $err->getMessage(); | ||
return; | ||
} | ||
|
||
foreach ($accounts as $account) { | ||
echo 'Account: ' . $account . PHP_EOL; | ||
|
||
$promises[] = $eth->getBalance($account, function ($err, $balance) { | ||
if ($err !== null) { | ||
echo 'Error: ' . $err->getMessage(); | ||
return; | ||
} | ||
echo 'Balance: ' . $balance . PHP_EOL; | ||
}); | ||
} | ||
|
||
// wait all promises | ||
Async\await(Promise\all($promises)); | ||
echo 'close connection...' . PHP_EOL; | ||
$eth->provider->close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.