Skip to content

Commit

Permalink
Updated transaction doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemilano committed Jun 25, 2018
1 parent e9a4a67 commit ebc7d0c
Showing 1 changed file with 55 additions and 49 deletions.
104 changes: 55 additions & 49 deletions docs/Transactions.md
Expand Up @@ -58,6 +58,56 @@ $txParams = [
$transaction = new \FOXRP\Rippled\Api\Transaction($txParams, $client);
```

## Submitting a Transaction

Building on from the examples above, it is now time to submit a transaction.

By default, the second argument to submit, `signLocal`, is set to true.

### Sign local and submit

Note: `xrpsign-cli` is required for local signing.

```php
$secret = 'sxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$response = $transaction->submit($secret);
```

### Submit to sign remotely

```php
$secret = 'sxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$response = $transaction->submit($secret, false);
```

## Submitted Transaction Response

If successful, `$response->getResult()` will contain something similar to the output below:

```
(
[engine_result] => tesSUCCESS
[engine_result_code] => 0
[engine_result_message] => The transaction was applied. Only final in a validated ledger.
[status] => success
[tx_blob] => 120000228000000024000000016140000000000F424068400000000000000A732102F9637154C55935861AF4DF4FF1D0E9A21351D8436DD4C7792356DB2BA55B93E474473045022100E8E2012E2421AAB69E30F96A0FDBD408164F471F6C533DAB207F933C8ABC2716022072496D12ACB698E8C977E23F85923FB2F68667E067C0B650D63B04E4902DBA4E8114FE32962E71441A81FB4FD80EE33E288A84FF5AB0831430643C3E4CCE37DD18F8AE238B7756A8CEC83FC5
[tx_json] => Array
(
[Account] => rQBnNY5w5cALHbMaue2VefSzuBfxafwqp9
[Amount] => 1000000
[Destination] => rnQ1WgToG2RL9Fjmofif9ixYVgJTi6BLas
[Fee] => 10
[Flags] => 2147483648
[Sequence] => 1
[SigningPubKey] => 02F9637154C55935861AF4DF4FF1D0E9A21351D8436DD4C7792356DB2BA55B93E4
[TransactionType] => Payment
[TxnSignature] => 3045022100E8E2012E2421AAB69E30F96A0FDBD408164F471F6C533DAB207F933C8ABC2716022072496D12ACB698E8C977E23F85923FB2F68667E067C0B650D63B04E4902DBA4E
[hash] => 5FFA62DB8A8E630741235B554A9335F938D00A309A0BB1F9714448EAFBDF843B
)
)
```

## Signing Transactions before Submitting (Optional)

As a precaution to avoid unintentional remote signing, local signing must be performed in this separate step.
Expand All @@ -68,6 +118,11 @@ Taking the above section as a starting point, locally signing a transaction is d

### Locally Signing

This is just an example in case you needed to sign in a separate step.

You typically won't need this step as it will be attempted with the `submit()` method. See "Submitting a Transaction"
above.

```php
$secret = 'sxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$transaction->signLocal($secret);
Expand Down Expand Up @@ -100,52 +155,3 @@ $txData = $transaction->getTx();

As mentioned above, remote signing can be done in the next step via the `submit` method. You may only want to use the
`signRemote` method if you need access to the signed transaction before submitting it.

## Submitting a Transaction

Building on from the examples above, it is now time to submit a transaction.

Signed transactions will send with the `Submit-Only` mode of the
[`submit`](https://developers.ripple.com/submit.html) method.

```php
// Submitting a signed transaction
$response = $transaction->submit();
```

Un-signed transactions will send with the `Sign-and-Submit` mode of the
[`submit`](https://developers.ripple.com/submit.html) method.

```php
// Unsigned transaction
$secret = 'sxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$response = $transaction->submit($secret);
```

## Submitted Transaction Response

If successful, `$response->getResult()` will contain something similar to the output below:

```
(
[engine_result] => tesSUCCESS
[engine_result_code] => 0
[engine_result_message] => The transaction was applied. Only final in a validated ledger.
[status] => success
[tx_blob] => 120000228000000024000000016140000000000F424068400000000000000A732102F9637154C55935861AF4DF4FF1D0E9A21351D8436DD4C7792356DB2BA55B93E474473045022100E8E2012E2421AAB69E30F96A0FDBD408164F471F6C533DAB207F933C8ABC2716022072496D12ACB698E8C977E23F85923FB2F68667E067C0B650D63B04E4902DBA4E8114FE32962E71441A81FB4FD80EE33E288A84FF5AB0831430643C3E4CCE37DD18F8AE238B7756A8CEC83FC5
[tx_json] => Array
(
[Account] => rQBnNY5w5cALHbMaue2VefSzuBfxafwqp9
[Amount] => 1000000
[Destination] => rnQ1WgToG2RL9Fjmofif9ixYVgJTi6BLas
[Fee] => 10
[Flags] => 2147483648
[Sequence] => 1
[SigningPubKey] => 02F9637154C55935861AF4DF4FF1D0E9A21351D8436DD4C7792356DB2BA55B93E4
[TransactionType] => Payment
[TxnSignature] => 3045022100E8E2012E2421AAB69E30F96A0FDBD408164F471F6C533DAB207F933C8ABC2716022072496D12ACB698E8C977E23F85923FB2F68667E067C0B650D63B04E4902DBA4E
[hash] => 5FFA62DB8A8E630741235B554A9335F938D00A309A0BB1F9714448EAFBDF843B
)
)
```

0 comments on commit ebc7d0c

Please sign in to comment.