12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- require('./exampleBase.php');
- $personal = $web3->personal;
- $newAccount = '';
- echo 'Personal Create Account and Unlock Account' . PHP_EOL;
- // create account
- $personal->newAccount('123456', function ($err, $account) use (&$newAccount) {
- if ($err !== null) {
- echo 'Error: ' . $err->getMessage();
- return;
- }
- $newAccount = $account;
- echo 'New account: ' . $account . PHP_EOL;
- });
- $personal->unlockAccount($newAccount, '123456', function ($err, $unlocked) {
- if ($err !== null) {
- echo 'Error: ' . $err->getMessage();
- return;
- }
- if ($unlocked) {
- echo 'New account is unlocked!' . PHP_EOL;
- } else {
- echo 'New account isn\'t unlocked' . PHP_EOL;
- }
- });
- // get balance
- $web3->eth->getBalance($newAccount, function ($err, $balance) {
- if ($err !== null) {
- echo 'Error: ' . $err->getMessage();
- return;
- }
- echo 'Balance: ' . $balance->toString() . PHP_EOL;
- });
|