Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0Vu committed Dec 30, 2023
1 parent a7db80f commit db48d4d
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ $web3 = new Web3('http://localhost:8545');
```php
use Web3\Web3;
use Web3\Providers\HttpProvider;
use Web3\RequestManagers\HttpRequestManager;

$web3 = new Web3(new HttpProvider(new HttpRequestManager('http://localhost:8545')));
$web3 = new Web3(new HttpProvider('http://localhost:8545'));

// timeout
$web3 = new Web3(new HttpProvider(new HttpRequestManager('http://localhost:8545', 0.1)));
$web3 = new Web3(new HttpProvider('http://localhost:8545', 0.1));
```

### You can use callback to each rpc call:
Expand All @@ -62,6 +61,43 @@ $web3->clientVersion(function ($err, $version) {
});
```

### Async
```php
use Web3\Web3;
use Web3\Providers\HttpAsyncProvider;

$web3 = new Web3(new HttpAsyncProvider('http://localhost:8545'));

// timeout
$web3 = new Web3(new HttpAsyncProvider('http://localhost:8545', 0.1));

// await
$promise = $web3->clientVersion(function ($err, $version) {
// do somthing
});
Async\await($promise);
```

### Websocket
```php
use Web3\Web3;
use Web3\Providers\WsProvider;

$web3 = new Web3(new WsProvider('ws://localhost:8545'));

// timeout
$web3 = new Web3(new WsProvider('ws://localhost:8545', 0.1));

// await
$promise = $web3->clientVersion(function ($err, $version) {
// do somthing
});
Async\await($promise);

// close connection
$web3->provider->close();
```

### Eth
```php
use Web3\Web3;
Expand Down

0 comments on commit db48d4d

Please sign in to comment.