Skip to content
This repository was archived by the owner on Sep 4, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,38 @@ try {
$response->getVersion();
```

## Get new address
```php
$client = new \Electrum\Client('http://127.0.0.1', 7777, 0, 'user', 'password');
$wallet = new \Electrum\Request\Method\Payment\AddRequest($client);
$tx = $wallet->execute();
echo $tx->getAddress();
```

## Make a new Payment
```php
$client = new \Electrum\Client('http://127.0.0.1', 7777, 0, 'user', 'password');
$method = new \Electrum\Request\Method\Payment\PayTo($client);
$method->setDestination('BTC4ddress1234'); //Destination parameter is the address where we'll send the btc
$method->setAmount(1); //send 1 BTC = 10k usd

$tx = $method->execute(); //$tx returns the transaction ID of the payment, this is still not sent to the blockchain
/**
* @param array ['password' => '<password>']
* If the Electrum wallet is encrypted with a password use the following execute method instead
* The previous one will return an error of "Password required"
*/
//$tx = $method->execute(['password' => 'myPass123']); //

$broadcast = new Electrum\Request\Method\Payment\Broadcast($client);
$broadcast->setTransaction($tx);
$result = $broadcast->execute(); //broadcasts payment to the blockchain
echo $result;

A payment has been made

```

## Custom Client Configuration
Every Request/Method takes a `Electrum\Client`-instance as parameter which replaces the default one. A custom instance can be usefull if you want to set custom config params like another Hostname or Port.
```php
Expand Down