mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-12-06 17:27:57 +00:00
Remove some old Escrow tutorials and rewrite conditional escrow tutorial in new format
This commit is contained in:
@@ -1,173 +0,0 @@
|
|||||||
---
|
|
||||||
html: send-a-conditionally-held-escrow.html
|
|
||||||
parent: use-escrows.html
|
|
||||||
seo:
|
|
||||||
description: 満たされた条件に基づいてリリースとなるEscrowを作成します。
|
|
||||||
labels:
|
|
||||||
- Escrow
|
|
||||||
- スマートコントラクト
|
|
||||||
---
|
|
||||||
# 条件に基づくEscrowの送信
|
|
||||||
|
|
||||||
## 1.条件とフルフィルメントの生成
|
|
||||||
|
|
||||||
XRP Ledger EscrowにはPREIMAGE-SHA-256 [Crypto-Conditions](https://tools.ietf.org/html/draft-thomas-crypto-conditions-03)が必要です。条件とフルフィルメントを適切なフォーマットで計算するには、[five-bells-condition](https://github.com/interledgerjs/five-bells-condition)などのCrypto-conditionsライブラリを使用する必要があります。フルフィルメントについては、以下のフルフィルメントを生成するためのメソッドのいずれかを使用することが推奨されます。
|
|
||||||
|
|
||||||
- 暗号論的に安全な乱数ソースを使用して、32バイト以上のランダムバイトを生成します。
|
|
||||||
- Interledger Protocolの[PSK仕様](https://github.com/interledger/rfcs/blob/master/deprecated/0016-pre-shared-key/0016-pre-shared-key.md)に従い、ILPパケットのHMAC-SHA-256をフルフィルメントとして使用します。
|
|
||||||
|
|
||||||
ランダムなフルフィルメントと条件のJavaScriptコードの例:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const cc = require('five-bells-condition')
|
|
||||||
const crypto = require('crypto')
|
|
||||||
|
|
||||||
const preimageData = crypto.randomBytes(32)
|
|
||||||
const myFulfillment = new cc.PreimageSha256()
|
|
||||||
myFulfillment.setPreimage(preimageData)
|
|
||||||
|
|
||||||
const condition = myFulfillment.getConditionBinary().toString('hex').toUpperCase()
|
|
||||||
console.log('Condition:', condition)
|
|
||||||
// (Random hexadecimal, 72 chars in length)
|
|
||||||
|
|
||||||
// keep secret until you want to finish executing the held payment:
|
|
||||||
const fulfillment = myFulfillment.serializeBinary().toString('hex').toUpperCase()
|
|
||||||
console.log('Fulfillment:', fulfillment)
|
|
||||||
// (Random hexadecimal, 78 chars in length)
|
|
||||||
```
|
|
||||||
|
|
||||||
後で使用できるように条件とフルフィルメントを保存します。保留中の支払いの実行が完了するまでは、フルフィルメントを公開しないでください。フルフィルメントを知っていれば誰でもEscrowを終了でき、保留中の資金を指定された送金先にリリースできます。
|
|
||||||
|
|
||||||
|
|
||||||
## 2.リリース時刻または取消し時刻の計算
|
|
||||||
|
|
||||||
条件付き`Escrow`トランザクションには、`CancelAfter`フィールドと`FinishAfter`フィールドのいずれか、または両方が含まれている必要があります。`CancelAfter`フィールドを使用すると、指定の時刻までに条件を満たすことができなかった場合に送金元へXRPを返金できます。`FinishAfter`フィールドに指定される時刻より前の時間は、正しいフルフィルメントが送信されてもEscrowを実行できません。いずれのフィールドでも、将来の時刻を指定する必要があります。
|
|
||||||
|
|
||||||
`CancelAfter`の時刻を24時間先に設定する例:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="JavaScript" %}
|
|
||||||
```js
|
|
||||||
const rippleOffset = 946684800
|
|
||||||
const CancelAfter = Math.floor(Date.now() / 1000) + (24*60*60) - rippleOffset
|
|
||||||
console.log(CancelAfter)
|
|
||||||
// Example:556927412
|
|
||||||
```
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% tab label="Python 2/3" %}
|
|
||||||
```python
|
|
||||||
from time import time
|
|
||||||
ripple_offset = 946684800
|
|
||||||
cancel_after = int(time()) + (24*60*60) - 946684800
|
|
||||||
print(cancel_after)
|
|
||||||
# Example: 556927412
|
|
||||||
```
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
{% admonition type="danger" name="警告" %}XRP Ledgerでは、時刻を**Rippleエポック(2000-01-01T00:00:00Z)以降の経過秒数**として指定する必要があります。`CancelAfter`または`FinishAfter`フィールドで、UNIX時刻を同等のRipple時刻に変換せずに使用すると、ロック解除時刻が**30年**先に設定されることになります。{% /admonition %}
|
|
||||||
|
|
||||||
## 3.EscrowCreateトランザクションの送信
|
|
||||||
|
|
||||||
[EscrowCreateトランザクション][]に[署名して送信](../../../../concepts/transactions/index.md#トランザクションへの署名とトランザクションの送信)します。トランザクションの`Condition`フィールドを、保留中の支払いがリリースされる時刻に設定します。`Destination`を受取人に設定します。受取人と送金元のアドレスは同じでもかまいません。前の手順で算出した`CancelAfter`または`FinishAfter`の時刻も指定します。`Amount`を、Escrowする[XRPのdrop数][]の合計額に設定します。
|
|
||||||
|
|
||||||
{% partial file="/@l10n/ja/docs/_snippets/secret-key-warning.md" /%}
|
|
||||||
|
|
||||||
リクエスト:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-request-escrowcreate-condition.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
レスポンス:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-response-escrowcreate-condition.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
## 4.検証の待機
|
|
||||||
|
|
||||||
{% partial file="/@l10n/ja/docs/_snippets/wait-for-validation.md" /%}
|
|
||||||
|
|
||||||
## 5.Escrowが作成されたことの確認
|
|
||||||
|
|
||||||
トランザクションの識別用ハッシュを指定した[txメソッド][]を使用して、トランザクションの最終ステータスを確認します。特に、[Escrowレジャーオブジェクト](../../../../concepts/payment-types/escrow.md)が作成されたことを示す`CreatedNode`をトランザクションメタデータで探します。
|
|
||||||
|
|
||||||
リクエスト:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-request-escrowcreate-condition.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
レスポンス:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-response-escrowcreate-condition.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
## 6.EscrowFinishトランザクションの送信
|
|
||||||
|
|
||||||
`FinishAfter`の時刻が経過した後で資金のリリースを実行する[EscrowFinishトランザクション][]に[署名して送信](../../../../concepts/transactions/index.md#トランザクションへの署名とトランザクションの送信)します。トランザクションの`Owner`フィールドにEscrowCreateトランザクションの`Account`アドレスを設定し、`OfferSequence` にEscrowCreateトランザクションの`Sequence`番号を設定します。`Condition`フィールドと`Fulfillment`フィールドに、ステップ1で生成した条件値とフルフィルメント値をそれぞれ16進数で設定します。フルフィルメントのサイズ(バイト数)に基づいて`Fee`([トランザクションコスト](../../../../concepts/transactions/transaction-cost.md))の値を設定します。条件付きEscrowFinishでは、少なくとも330 drop(XRP)と、フルフィルメントのサイズで16バイトごとに10 dropが必要です。
|
|
||||||
|
|
||||||
{% admonition type="info" name="注記" %}EscrowCreateトランザクションに`FinishAfter`フィールドが含まれている場合、Escrowの条件として正しいフルフィルメントを指定しても、この時刻よりも前の時点ではこのトランザクションを実行できません。前に閉鎖されたレジャーの閉鎖時刻が`FinishAfter`の時刻よりも前である場合、EscrowFinishトランザクションは[結果コード](../../../../references/protocol/transactions/transaction-results/index.md)`tecNO_PERMISSION`で失敗します。{% /admonition %}
|
|
||||||
|
|
||||||
Escrowが有効期限切れの場合は、[Escrowの取消し](cancel-an-expired-escrow.md)だけが可能です。
|
|
||||||
|
|
||||||
{% partial file="/@l10n/ja/docs/_snippets/secret-key-warning.md" /%}
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-request-escrowfinish-condition.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
レスポンス:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-response-escrowfinish-condition.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
トランザクションの識別用`hash`値をメモしておきます。これにより、検証済みレジャーバージョンに記録されるときにその最終ステータスを確認できます。
|
|
||||||
|
|
||||||
## 7.検証の待機
|
|
||||||
|
|
||||||
{% partial file="/@l10n/ja/docs/_snippets/wait-for-validation.md" /%}
|
|
||||||
|
|
||||||
## 8.最終結果の確認
|
|
||||||
|
|
||||||
EscrowFinishトランザクションの識別用ハッシュを指定した[txメソッド][]を使用して、トランザクションの最終ステータスを確認します。特にトランザクションメタデータ内で、エスクローに預託された支払いの送金先の`ModifiedNode`(タイプが`AccountRoot`)を確認します。オブジェクトの`FinalFields`に、`Balance`フィールドのXRP返金額の増分が表示されている必要があります。
|
|
||||||
|
|
||||||
リクエスト:
|
|
||||||
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-request-escrowfinish-condition.json" language="json" /%}
|
|
||||||
|
|
||||||
レスポンス:
|
|
||||||
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-response-escrowfinish-condition.json" language="json" /%}
|
|
||||||
|
|
||||||
{% raw-partial file="/@l10n/ja/docs/_snippets/common-links.md" /%}
|
|
||||||
@@ -1,188 +0,0 @@
|
|||||||
---
|
|
||||||
html: send-a-time-held-escrow.html
|
|
||||||
parent: use-escrows.html
|
|
||||||
seo:
|
|
||||||
description: 指定した時間が経過することがリリースの唯一の条件であるEscrowを作成します。
|
|
||||||
labels:
|
|
||||||
- Escrow
|
|
||||||
- スマートコントラクト
|
|
||||||
---
|
|
||||||
# 時間に基づくEscrowの送信
|
|
||||||
|
|
||||||
[EscrowCreateトランザクション][]タイプでは、リリースの唯一の条件が特定時刻を経過することであるEscrowを作成できます。このためには、`FinishAfter`フィールドを使用し、`Condition`フィールドを省略します。
|
|
||||||
|
|
||||||
## 1.リリース時刻の計算
|
|
||||||
|
|
||||||
時刻を **[Rippleエポック以降の経過秒数][]** として指定する必要があります。Rippleエポックは、UNIXエポックの946684800秒後です。たとえば、2017年11月13日の午前0時(UTC)に資金をリリースする場合、以下のようになります。
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="JavaScript" %}
|
|
||||||
```js
|
|
||||||
// JavaScript Date() is natively expressed in milliseconds; convert to seconds
|
|
||||||
const release_date_unix = Math.floor( new Date("2017-11-13T00:00:00Z") / 1000 );
|
|
||||||
const release_date_ripple = release_date_unix - 946684800;
|
|
||||||
console.log(release_date_ripple);
|
|
||||||
// 563846400
|
|
||||||
```
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% tab label="Python 3" %}
|
|
||||||
```python
|
|
||||||
import datetime
|
|
||||||
release_date_utc = datetime.datetime(2017,11,13,0,0,0,tzinfo=datetime.timezone.utc)
|
|
||||||
release_date_ripple = int(release_date_utc.timestamp()) - 946684800
|
|
||||||
print(release_date_ripple)
|
|
||||||
# 563846400
|
|
||||||
```
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
{% admonition type="danger" name="警告" %}`FinishAfter`フィールドで、UNIX時刻を同等のRipple時刻に変換せずに使用すると、ロック解除時刻が30年先に設定されることになります。{% /admonition %}
|
|
||||||
|
|
||||||
## 2.EscrowCreateトランザクションの送信
|
|
||||||
|
|
||||||
[EscrowCreateトランザクション][]に[署名して送信](../../../../concepts/transactions/index.md#トランザクションへの署名とトランザクションの送信)します。トランザクションの`FinishAfter`フィールドを、保留中の支払いがリリースされる時刻に設定します。`Condition`フィールドを省略して、時刻を保留中の支払いをリリースする唯一の条件とします。`Destination`を受取人に設定します。受取人と送金元のアドレスは同じでもかまいません。`Amount`を、Escrowする[XRPのdrop数][]の合計額に設定します。
|
|
||||||
|
|
||||||
{% partial file="/@l10n/ja/docs/_snippets/secret-key-warning.md" /%}
|
|
||||||
|
|
||||||
リクエスト:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-request-escrowcreate-time.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
レスポンス:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-response-escrowcreate-time.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
|
|
||||||
トランザクションの識別用`hash`値をメモしておきます。これにより、検証済みレジャーバージョンに記録されるときにその最終ステータスを確認できます。
|
|
||||||
|
|
||||||
## 3.検証の待機
|
|
||||||
|
|
||||||
{% partial file="/@l10n/ja/docs/_snippets/wait-for-validation.md" /%}
|
|
||||||
|
|
||||||
## 4.Escrowが作成されたことの確認
|
|
||||||
|
|
||||||
トランザクションの識別用ハッシュを指定した[txメソッド][]を使用して、トランザクションの最終ステータスを確認します。[Escrowレジャーオブジェクト](../../../../concepts/payment-types/escrow.md)が作成されたことを示す`CreatedNode`をトランザクションメタデータで探します。
|
|
||||||
|
|
||||||
リクエスト:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-request-escrowcreate-time.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
レスポンス:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-response-escrowcreate-time.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
## 5.リリース時刻までの待機
|
|
||||||
|
|
||||||
`FinishAfter`時刻が指定されている保留中の支払いは、Escrowノードの`FinishAfter`時刻よりも後の[`close_time`ヘッダーフィールド](../../../../references/protocol/ledger-data/ledger-header.md)の時刻でレジャーが閉鎖するまでは完了できません。
|
|
||||||
|
|
||||||
最新の検証済みレジャーの閉鎖時刻は、[ledgerメソッド][]を使用して検索できます。
|
|
||||||
|
|
||||||
リクエスト:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/ledger-request.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
レスポンス:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/ledger-response.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
|
|
||||||
## 6.EscrowFinishトランザクションの送信
|
|
||||||
|
|
||||||
`FinishAfter`の時刻が経過した後で資金のリリースを実行する[EscrowFinishトランザクション][]に[署名して送信](../../../../concepts/transactions/index.md#トランザクションへの署名とトランザクションの送信)します。トランザクションの`Owner`フィールドにEscrowCreateトランザクションの`Account`アドレスを設定し、`OfferSequence` にEscrowCreateトランザクションの`Sequence`番号を設定します。時刻のみに基づいて保留されているEscrowの場合は、`Condition`フィールドと`Fulfillment`フィールドを省略します。
|
|
||||||
|
|
||||||
{% admonition type="success" name="ヒント" %}XRP Ledgerの状態はトランザクションでしか変更できないため、EscrowFinishトランザクションが必要です。このトランザクションの送信者は、Escrowの受取人、Escrowの元としての送金人、またはその他のXRP Ledgerアドレスのいずれかです。{% /admonition %}
|
|
||||||
|
|
||||||
Escrowが有効期限切れの場合は、[Escrowの取消し](cancel-an-expired-escrow.md)だけが可能です。
|
|
||||||
|
|
||||||
{% partial file="/@l10n/ja/docs/_snippets/secret-key-warning.md" /%}
|
|
||||||
|
|
||||||
リクエスト:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-request-escrowfinish-time.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
レスポンス:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-response-escrowfinish-time.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
トランザクションの識別用`hash`値をメモしておきます。これにより、検証済みレジャーバージョンに記録されるときにその最終ステータスを確認できます。
|
|
||||||
|
|
||||||
## 7.検証の待機
|
|
||||||
|
|
||||||
{% partial file="/@l10n/ja/docs/_snippets/wait-for-validation.md" /%}
|
|
||||||
|
|
||||||
## 8.最終結果の確認
|
|
||||||
|
|
||||||
EscrowFinishトランザクションの識別用ハッシュを指定した[txメソッド][]を使用して、トランザクションの最終ステータスを確認します。特にトランザクションメタデータ内で、エスクローに預託された支払いの送金先の`ModifiedNode`(タイプが`AccountRoot`)を確認します。オブジェクトの`FinalFields`に、`Balance`フィールドのXRP返金額の増分が表示されている必要があります。
|
|
||||||
|
|
||||||
リクエスト:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-request-escrowfinish-time.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
レスポンス:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-response-escrowfinish-time.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
{% raw-partial file="/@l10n/ja/docs/_snippets/common-links.md" /%}
|
|
||||||
@@ -37,7 +37,7 @@ XRP Ledger上のスマートコントラクトは、条件付きで保有する
|
|||||||
|
|
||||||
オラクルのプログラムが条件を満たしたことを検知した後、エスクローの受取人にfulfillmentの16進数値を渡します。この時点以降、オラクルはエスクローを終了させるなど、何も行いません。エスクローの受取人は、ほとんどの場合、エスクローを終了することになります。
|
オラクルのプログラムが条件を満たしたことを検知した後、エスクローの受取人にfulfillmentの16進数値を渡します。この時点以降、オラクルはエスクローを終了させるなど、何も行いません。エスクローの受取人は、ほとんどの場合、エスクローを終了することになります。
|
||||||
|
|
||||||
[conditionとfulfillmentの生成](../../tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-conditionally-held-escrow.md#1-generate-condition-and-fulfillment)をご覧ください。
|
[条件に基づくEscrowの送信](../../tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-conditional-escrow.md)をご覧ください。
|
||||||
|
|
||||||
## 例
|
## 例
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 4,
|
|
||||||
"command": "ledger",
|
|
||||||
"ledger_index": "validated"
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 4,
|
|
||||||
"status": "success",
|
|
||||||
"type": "response",
|
|
||||||
"result": {
|
|
||||||
"ledger": {
|
|
||||||
"accepted": true,
|
|
||||||
"account_hash": "3B5A8FF5334F94F4D3D09F236F9D1B4C028FCAE30948ACC986D461DDEE1D886B",
|
|
||||||
"close_flags": 0,
|
|
||||||
"close_time": 557256670,
|
|
||||||
"close_time_human": "2017-Aug-28 17:31:10",
|
|
||||||
"close_time_resolution": 10,
|
|
||||||
"closed": true,
|
|
||||||
"hash": "A999223A80174A7CB39D766B625C9E476F24AD2F15860A712CD029EE5ED1C320",
|
|
||||||
"ledger_hash": "A999223A80174A7CB39D766B625C9E476F24AD2F15860A712CD029EE5ED1C320",
|
|
||||||
"ledger_index": "1908253",
|
|
||||||
"parent_close_time": 557256663,
|
|
||||||
"parent_hash": "6A70C5336ACFDA05760D827776079F7A544D2361CFD5B21BD55A92AA20477A61",
|
|
||||||
"seqNum": "1908253",
|
|
||||||
"totalCoins": "99997280690562728",
|
|
||||||
"total_coins": "99997280690562728",
|
|
||||||
"transaction_hash": "49A51DFB1CAB2F134D93D5D1C5FF55A15B12DA36DAF9F5862B17C47EE966647D"
|
|
||||||
},
|
|
||||||
"ledger_hash": "A999223A80174A7CB39D766B625C9E476F24AD2F15860A712CD029EE5ED1C320",
|
|
||||||
"ledger_index": 1908253,
|
|
||||||
"validated": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 1,
|
|
||||||
"command": "submit",
|
|
||||||
"secret": "s████████████████████████████",
|
|
||||||
"tx_json": {
|
|
||||||
"Account": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"TransactionType": "EscrowCreate",
|
|
||||||
"Amount": "100000",
|
|
||||||
"Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
|
||||||
"Condition": "A0258020E24D9E1473D4DF774F6D8E089067282034E4FA7ECACA2AD2E547953B2C113CBD810120",
|
|
||||||
"CancelAfter": 556927412
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 2,
|
|
||||||
"command": "submit",
|
|
||||||
"secret": "s████████████████████████████",
|
|
||||||
"tx_json": {
|
|
||||||
"Account": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"TransactionType": "EscrowCreate",
|
|
||||||
"Amount": "10000",
|
|
||||||
"Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
|
||||||
"FinishAfter": 557020800
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 4,
|
|
||||||
"command": "submit",
|
|
||||||
"secret": "s████████████████████████████",
|
|
||||||
"tx_json": {
|
|
||||||
"Account": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"TransactionType": "EscrowFinish",
|
|
||||||
"Owner": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"OfferSequence": 5,
|
|
||||||
"Condition": "A0258020E24D9E1473D4DF774F6D8E089067282034E4FA7ECACA2AD2E547953B2C113CBD810120",
|
|
||||||
"Fulfillment": "A0228020D280D1A02BAD0D2EBC0528B92E9BF37AC3E2530832C2C52620307135156F1048",
|
|
||||||
"Fee": "500"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 5,
|
|
||||||
"command": "submit",
|
|
||||||
"secret": "s████████████████████████████",
|
|
||||||
"tx_json": {
|
|
||||||
"Account": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"TransactionType": "EscrowFinish",
|
|
||||||
"Owner": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"OfferSequence": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 1,
|
|
||||||
"status": "success",
|
|
||||||
"type": "response",
|
|
||||||
"result": {
|
|
||||||
"engine_result": "tesSUCCESS",
|
|
||||||
"engine_result_code": 0,
|
|
||||||
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
|
|
||||||
"tx_blob": "120001228000000024000000052024213209B46140000000000186A068400000000000000A732103E498E35BC1E109C5995BD3AB0A6D4FFAB61B853C8F6010FABC5DABAF34478B61744730450221008AC8BDC2151D5EF956197F0E6E89A4F49DEADC1AC38367870E444B1EA8D88D97022075E31427B455DFF87F0F22B849C71FC3987A91C19D63B6D0242E808347EC8A8F701127A0258020E24D9E1473D4DF774F6D8E089067282034E4FA7ECACA2AD2E547953B2C113CBD81012081149A2AA667E1517EFA8A6B552AB2EDB859A99F26B283144B4E9C06F24296074F7BC48F92A97916C6DC5EA9",
|
|
||||||
"tx_json": {
|
|
||||||
"Account": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"Amount": "100000",
|
|
||||||
"CancelAfter": 556927412,
|
|
||||||
"Condition": "A0258020E24D9E1473D4DF774F6D8E089067282034E4FA7ECACA2AD2E547953B2C113CBD810120",
|
|
||||||
"Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
|
||||||
"Fee": "10",
|
|
||||||
"Flags": 2147483648,
|
|
||||||
"Sequence": 5,
|
|
||||||
"SigningPubKey": "03E498E35BC1E109C5995BD3AB0A6D4FFAB61B853C8F6010FABC5DABAF34478B61",
|
|
||||||
"TransactionType": "EscrowCreate",
|
|
||||||
"TxnSignature": "30450221008AC8BDC2151D5EF956197F0E6E89A4F49DEADC1AC38367870E444B1EA8D88D97022075E31427B455DFF87F0F22B849C71FC3987A91C19D63B6D0242E808347EC8A8F",
|
|
||||||
"hash": "E22D1F6EB006CAD35E0DBD3B4F3748427055E4C143EBE95AA6603823AEEAD324"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 2,
|
|
||||||
"status": "success",
|
|
||||||
"type": "response",
|
|
||||||
"result": {
|
|
||||||
"engine_result": "tesSUCCESS",
|
|
||||||
"engine_result_code": 0,
|
|
||||||
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
|
|
||||||
"tx_blob": "1200012280000000240000000120252133768061400000000000271068400000000000000A732103C3555B7339FFDDB43495A8371A3A87B4C66B67D49D06CB9BA1FDBFEEB57B6E437446304402203C9AA4C21E1A1A7427D41583283E7A513DDBDD967B246CADD3B2705D858A7A8E02201BEA7B923B18910EEB9F306F6DE3B3F53549BBFAD46335B62B4C34A6DCB4A47681143EEB46C355B04EE8D08E8EED00F422895C79EA6A83144B4E9C06F24296074F7BC48F92A97916C6DC5EA9",
|
|
||||||
"tx_json": {
|
|
||||||
"Account": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"Amount": "10000",
|
|
||||||
"Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
|
||||||
"Fee": "10",
|
|
||||||
"FinishAfter": 557020800,
|
|
||||||
"Flags": 2147483648,
|
|
||||||
"Sequence": 1,
|
|
||||||
"SigningPubKey": "03C3555B7339FFDDB43495A8371A3A87B4C66B67D49D06CB9BA1FDBFEEB57B6E43",
|
|
||||||
"TransactionType": "EscrowCreate",
|
|
||||||
"TxnSignature": "304402203C9AA4C21E1A1A7427D41583283E7A513DDBDD967B246CADD3B2705D858A7A8E02201BEA7B923B18910EEB9F306F6DE3B3F53549BBFAD46335B62B4C34A6DCB4A476",
|
|
||||||
"hash": "55B2057332F8999208C43BA1E7091B423A16E5ED2736C06300B4076085205263"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 4,
|
|
||||||
"status": "success",
|
|
||||||
"type": "response",
|
|
||||||
"result": {
|
|
||||||
"engine_result": "tesSUCCESS",
|
|
||||||
"engine_result_code": 0,
|
|
||||||
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
|
|
||||||
"tx_blob": "120002228000000024000000062019000000056840000000000001F4732103E498E35BC1E109C5995BD3AB0A6D4FFAB61B853C8F6010FABC5DABAF34478B617446304402207DE4EA9C8655E75BA01F96345B3F62074313EB42C15D9C4871E30F02202D2BA50220070E52AD308A31AC71E33BA342F31B68D1D1B2A7A3A3ED6E8552CA3DCF14FBB2701024A0228020D280D1A02BAD0D2EBC0528B92E9BF37AC3E2530832C2C52620307135156F1048701127A0258020E24D9E1473D4DF774F6D8E089067282034E4FA7ECACA2AD2E547953B2C113CBD81012081149A2AA667E1517EFA8A6B552AB2EDB859A99F26B282149A2AA667E1517EFA8A6B552AB2EDB859A99F26B2",
|
|
||||||
"tx_json": {
|
|
||||||
"Account": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"Condition": "A0258020E24D9E1473D4DF774F6D8E089067282034E4FA7ECACA2AD2E547953B2C113CBD810120",
|
|
||||||
"Fee": "500",
|
|
||||||
"Flags": 2147483648,
|
|
||||||
"Fulfillment": "A0228020D280D1A02BAD0D2EBC0528B92E9BF37AC3E2530832C2C52620307135156F1048",
|
|
||||||
"OfferSequence": 5,
|
|
||||||
"Owner": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"Sequence": 6,
|
|
||||||
"SigningPubKey": "03E498E35BC1E109C5995BD3AB0A6D4FFAB61B853C8F6010FABC5DABAF34478B61",
|
|
||||||
"TransactionType": "EscrowFinish",
|
|
||||||
"TxnSignature": "304402207DE4EA9C8655E75BA01F96345B3F62074313EB42C15D9C4871E30F02202D2BA50220070E52AD308A31AC71E33BA342F31B68D1D1B2A7A3A3ED6E8552CA3DCF14FBB2",
|
|
||||||
"hash": "0E88368CAFC69A722ED829FAE6E2DD3575AE9C192691E60B5ACDF706E219B2BF"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 5,
|
|
||||||
"status": "success",
|
|
||||||
"type": "response",
|
|
||||||
"result": {
|
|
||||||
"engine_result": "tesSUCCESS",
|
|
||||||
"engine_result_code": 0,
|
|
||||||
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
|
|
||||||
"tx_blob": "1200022280000000240000000220190000000168400000000000000A732103C3555B7339FFDDB43495A8371A3A87B4C66B67D49D06CB9BA1FDBFEEB57B6E4374473045022100923B91BA4FD6450813F5335D71C64BA9EB81304A86859A631F2AD8571424A46502200CCE660D36781B84634C5F23619EB6CFCCF942709F54DCCF27CF6F499AE78C9B81143EEB46C355B04EE8D08E8EED00F422895C79EA6A82143EEB46C355B04EE8D08E8EED00F422895C79EA6A",
|
|
||||||
"tx_json": {
|
|
||||||
"Account": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"Fee": "10",
|
|
||||||
"Flags": 2147483648,
|
|
||||||
"OfferSequence": 1,
|
|
||||||
"Owner": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"Sequence": 2,
|
|
||||||
"SigningPubKey": "03C3555B7339FFDDB43495A8371A3A87B4C66B67D49D06CB9BA1FDBFEEB57B6E43",
|
|
||||||
"TransactionType": "EscrowFinish",
|
|
||||||
"TxnSignature": "3045022100923B91BA4FD6450813F5335D71C64BA9EB81304A86859A631F2AD8571424A46502200CCE660D36781B84634C5F23619EB6CFCCF942709F54DCCF27CF6F499AE78C9B",
|
|
||||||
"hash": "41856A742B3CAF307E7B4D0B850F302101F0F415B785454F7501E9960A2A1F6B"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 3,
|
|
||||||
"command": "tx",
|
|
||||||
"transaction": "E22D1F6EB006CAD35E0DBD3B4F3748427055E4C143EBE95AA6603823AEEAD324"
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 3,
|
|
||||||
"command": "tx",
|
|
||||||
"transaction": "55B2057332F8999208C43BA1E7091B423A16E5ED2736C06300B4076085205263"
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 20,
|
|
||||||
"command": "tx",
|
|
||||||
"transaction": "0E88368CAFC69A722ED829FAE6E2DD3575AE9C192691E60B5ACDF706E219B2BF"
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 21,
|
|
||||||
"command": "tx",
|
|
||||||
"transaction": "41856A742B3CAF307E7B4D0B850F302101F0F415B785454F7501E9960A2A1F6B"
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 3,
|
|
||||||
"status": "success",
|
|
||||||
"type": "response",
|
|
||||||
"result": {
|
|
||||||
"Account": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"Amount": "100000",
|
|
||||||
"CancelAfter": 556927412,
|
|
||||||
"Condition": "A0258020E24D9E1473D4DF774F6D8E089067282034E4FA7ECACA2AD2E547953B2C113CBD810120",
|
|
||||||
"Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
|
||||||
"Fee": "10",
|
|
||||||
"Flags": 2147483648,
|
|
||||||
"Sequence": 5,
|
|
||||||
"SigningPubKey": "03E498E35BC1E109C5995BD3AB0A6D4FFAB61B853C8F6010FABC5DABAF34478B61",
|
|
||||||
"TransactionType": "EscrowCreate",
|
|
||||||
"TxnSignature": "30450221008AC8BDC2151D5EF956197F0E6E89A4F49DEADC1AC38367870E444B1EA8D88D97022075E31427B455DFF87F0F22B849C71FC3987A91C19D63B6D0242E808347EC8A8F",
|
|
||||||
"date": 556841101,
|
|
||||||
"hash": "E22D1F6EB006CAD35E0DBD3B4F3748427055E4C143EBE95AA6603823AEEAD324",
|
|
||||||
"inLedger": 1772019,
|
|
||||||
"ledger_index": 1772019,
|
|
||||||
"meta": {
|
|
||||||
"AffectedNodes": [
|
|
||||||
{
|
|
||||||
"ModifiedNode": {
|
|
||||||
"LedgerEntryType": "AccountRoot",
|
|
||||||
"LedgerIndex": "13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8",
|
|
||||||
"PreviousTxnID": "52C4F626FE6F33699B6BE8ADF362836DDCE9B0B1294BFAA15D65D61501350BE6",
|
|
||||||
"PreviousTxnLgrSeq": 1771204
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ModifiedNode": {
|
|
||||||
"FinalFields": {
|
|
||||||
"Flags": 0,
|
|
||||||
"Owner": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"RootIndex": "4B4EBB6D8563075813D47491CC325865DFD3DC2E94889F0F39D59D9C059DD81F"
|
|
||||||
},
|
|
||||||
"LedgerEntryType": "DirectoryNode",
|
|
||||||
"LedgerIndex": "4B4EBB6D8563075813D47491CC325865DFD3DC2E94889F0F39D59D9C059DD81F"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ModifiedNode": {
|
|
||||||
"FinalFields": {
|
|
||||||
"Account": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"Balance": "9999798970",
|
|
||||||
"Flags": 0,
|
|
||||||
"OwnerCount": 1,
|
|
||||||
"Sequence": 6
|
|
||||||
},
|
|
||||||
"LedgerEntryType": "AccountRoot",
|
|
||||||
"LedgerIndex": "5F3B7107F4B524367A173A2B0EAB66E8CC4D2178C1B0C0528CB2F73A8B6BF254",
|
|
||||||
"PreviousFields": {
|
|
||||||
"Balance": "9999898980",
|
|
||||||
"OwnerCount": 0,
|
|
||||||
"Sequence": 5
|
|
||||||
},
|
|
||||||
"PreviousTxnID": "52C4F626FE6F33699B6BE8ADF362836DDCE9B0B1294BFAA15D65D61501350BE6",
|
|
||||||
"PreviousTxnLgrSeq": 1771204
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"CreatedNode": {
|
|
||||||
"LedgerEntryType": "Escrow",
|
|
||||||
"LedgerIndex": "E2CF730A31FD419382350C9DBD8DB7CD775BA5AA9B97A9BE9AB07304AA217A75",
|
|
||||||
"NewFields": {
|
|
||||||
"Account": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"Amount": "100000",
|
|
||||||
"CancelAfter": 556927412,
|
|
||||||
"Condition": "A0258020E24D9E1473D4DF774F6D8E089067282034E4FA7ECACA2AD2E547953B2C113CBD810120",
|
|
||||||
"Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"TransactionIndex": 0,
|
|
||||||
"TransactionResult": "tesSUCCESS"
|
|
||||||
},
|
|
||||||
"validated": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 3,
|
|
||||||
"status": "success",
|
|
||||||
"type": "response",
|
|
||||||
"result": {
|
|
||||||
"Account": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"Amount": "10000",
|
|
||||||
"Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
|
||||||
"Fee": "10",
|
|
||||||
"FinishAfter": 557020800,
|
|
||||||
"Flags": 2147483648,
|
|
||||||
"Sequence": 1,
|
|
||||||
"SigningPubKey": "03C3555B7339FFDDB43495A8371A3A87B4C66B67D49D06CB9BA1FDBFEEB57B6E43",
|
|
||||||
"TransactionType": "EscrowCreate",
|
|
||||||
"TxnSignature": "304402203C9AA4C21E1A1A7427D41583283E7A513DDBDD967B246CADD3B2705D858A7A8E02201BEA7B923B18910EEB9F306F6DE3B3F53549BBFAD46335B62B4C34A6DCB4A476",
|
|
||||||
"date": 557014081,
|
|
||||||
"hash": "55B2057332F8999208C43BA1E7091B423A16E5ED2736C06300B4076085205263",
|
|
||||||
"inLedger": 1828796,
|
|
||||||
"ledger_index": 1828796,
|
|
||||||
"meta": {
|
|
||||||
"AffectedNodes": [
|
|
||||||
{
|
|
||||||
"ModifiedNode": {
|
|
||||||
"LedgerEntryType": "AccountRoot",
|
|
||||||
"LedgerIndex": "13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8",
|
|
||||||
"PreviousTxnID": "613B28E0890FC975F2CBA3D700F75116F623B1E3FE48CB7CB2EB216EAD6F097D",
|
|
||||||
"PreviousTxnLgrSeq": 1799920
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"CreatedNode": {
|
|
||||||
"LedgerEntryType": "Escrow",
|
|
||||||
"LedgerIndex": "2B9845CB9DF686B9615BF04F3EC66095A334D985E03E71B893B90FCF6D4DC9E6",
|
|
||||||
"NewFields": {
|
|
||||||
"Account": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"Amount": "10000",
|
|
||||||
"Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
|
||||||
"FinishAfter": 557020800
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ModifiedNode": {
|
|
||||||
"FinalFields": {
|
|
||||||
"Account": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"Balance": "9999989990",
|
|
||||||
"Flags": 0,
|
|
||||||
"OwnerCount": 1,
|
|
||||||
"Sequence": 2
|
|
||||||
},
|
|
||||||
"LedgerEntryType": "AccountRoot",
|
|
||||||
"LedgerIndex": "AE5AB6584A76C37C7382B6880609FC7792D90CDA36FF362AF412EB914C1715D3",
|
|
||||||
"PreviousFields": {
|
|
||||||
"Balance": "10000000000",
|
|
||||||
"OwnerCount": 0,
|
|
||||||
"Sequence": 1
|
|
||||||
},
|
|
||||||
"PreviousTxnID": "F181D45FD094A7417926F791D9DF958B84CE4B7B3D92CC9DDCACB1D5EC59AAAA",
|
|
||||||
"PreviousTxnLgrSeq": 1828732
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"CreatedNode": {
|
|
||||||
"LedgerEntryType": "DirectoryNode",
|
|
||||||
"LedgerIndex": "D623EBEEEE701D4323D0ADA5320AF35EA8CC6520EBBEF69343354CD593DABC88",
|
|
||||||
"NewFields": {
|
|
||||||
"Owner": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"RootIndex": "D623EBEEEE701D4323D0ADA5320AF35EA8CC6520EBBEF69343354CD593DABC88"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"TransactionIndex": 3,
|
|
||||||
"TransactionResult": "tesSUCCESS"
|
|
||||||
},
|
|
||||||
"validated": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 20,
|
|
||||||
"status": "success",
|
|
||||||
"type": "response",
|
|
||||||
"result": {
|
|
||||||
"Account": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"Condition": "A0258020E24D9E1473D4DF774F6D8E089067282034E4FA7ECACA2AD2E547953B2C113CBD810120",
|
|
||||||
"Fee": "500",
|
|
||||||
"Flags": 2147483648,
|
|
||||||
"Fulfillment": "A0228020D280D1A02BAD0D2EBC0528B92E9BF37AC3E2530832C2C52620307135156F1048",
|
|
||||||
"OfferSequence": 2,
|
|
||||||
"Owner": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"Sequence": 4,
|
|
||||||
"SigningPubKey": "03E498E35BC1E109C5995BD3AB0A6D4FFAB61B853C8F6010FABC5DABAF34478B61",
|
|
||||||
"TransactionType": "EscrowFinish",
|
|
||||||
"TxnSignature": "3045022100925FEBE21C2E57F81C472A4E5869CAB1D0164C472A46532F39F6F9F7ED6846D002202CF9D9063ADC4CC0ADF4C4692B7EE165C5D124CAA855649389E245D993F41D4D",
|
|
||||||
"date": 556838610,
|
|
||||||
"hash": "0E88368CAFC69A722ED829FAE6E2DD3575AE9C192691E60B5ACDF706E219B2BF",
|
|
||||||
"inLedger": 1771204,
|
|
||||||
"ledger_index": 1771204,
|
|
||||||
"meta": {
|
|
||||||
"AffectedNodes": [
|
|
||||||
{
|
|
||||||
"ModifiedNode": {
|
|
||||||
"FinalFields": {
|
|
||||||
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
|
||||||
"Balance": "400100000",
|
|
||||||
"Flags": 0,
|
|
||||||
"OwnerCount": 0,
|
|
||||||
"Sequence": 1
|
|
||||||
},
|
|
||||||
"LedgerEntryType": "AccountRoot",
|
|
||||||
"LedgerIndex": "13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8",
|
|
||||||
"PreviousFields": {
|
|
||||||
"Balance": "400000000"
|
|
||||||
},
|
|
||||||
"PreviousTxnID": "795CBC8AFAAB9DC7BD9944C7FAEABF9BB0802A84520BC649213AD6A2C3256C95",
|
|
||||||
"PreviousTxnLgrSeq": 1770775
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ModifiedNode": {
|
|
||||||
"FinalFields": {
|
|
||||||
"Flags": 0,
|
|
||||||
"Owner": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"RootIndex": "4B4EBB6D8563075813D47491CC325865DFD3DC2E94889F0F39D59D9C059DD81F"
|
|
||||||
},
|
|
||||||
"LedgerEntryType": "DirectoryNode",
|
|
||||||
"LedgerIndex": "4B4EBB6D8563075813D47491CC325865DFD3DC2E94889F0F39D59D9C059DD81F"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ModifiedNode": {
|
|
||||||
"FinalFields": {
|
|
||||||
"Account": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"Balance": "9999898980",
|
|
||||||
"Flags": 0,
|
|
||||||
"OwnerCount": 0,
|
|
||||||
"Sequence": 5
|
|
||||||
},
|
|
||||||
"LedgerEntryType": "AccountRoot",
|
|
||||||
"LedgerIndex": "5F3B7107F4B524367A173A2B0EAB66E8CC4D2178C1B0C0528CB2F73A8B6BF254",
|
|
||||||
"PreviousFields": {
|
|
||||||
"Balance": "9999899480",
|
|
||||||
"OwnerCount": 1,
|
|
||||||
"Sequence": 4
|
|
||||||
},
|
|
||||||
"PreviousTxnID": "5C2A1E7B209A7404D3722A010D331A8C1C853109A47DDF620DE5E3D59F026581",
|
|
||||||
"PreviousTxnLgrSeq": 1771042
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"DeletedNode": {
|
|
||||||
"FinalFields": {
|
|
||||||
"Account": "rEhw9vD98ZrkY4tZPvkZst5H18RysqFdaB",
|
|
||||||
"Amount": "100000",
|
|
||||||
"Condition": "A0258020E24D9E1473D4DF774F6D8E089067282034E4FA7ECACA2AD2E547953B2C113CBD810120",
|
|
||||||
"Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
|
||||||
"FinishAfter": 556838185,
|
|
||||||
"Flags": 0,
|
|
||||||
"OwnerNode": "0000000000000000",
|
|
||||||
"PreviousTxnID": "795CBC8AFAAB9DC7BD9944C7FAEABF9BB0802A84520BC649213AD6A2C3256C95",
|
|
||||||
"PreviousTxnLgrSeq": 1770775
|
|
||||||
},
|
|
||||||
"LedgerEntryType": "Escrow",
|
|
||||||
"LedgerIndex": "DC524D17B3F650E7A215B332F418E54AE59B0DFC5392E74958B0037AFDFE8C8D"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"TransactionIndex": 1,
|
|
||||||
"TransactionResult": "tesSUCCESS"
|
|
||||||
},
|
|
||||||
"validated": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 21,
|
|
||||||
"status": "success",
|
|
||||||
"type": "response",
|
|
||||||
"result": {
|
|
||||||
"Account": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"Fee": "10",
|
|
||||||
"Flags": 2147483648,
|
|
||||||
"OfferSequence": 1,
|
|
||||||
"Owner": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"Sequence": 2,
|
|
||||||
"SigningPubKey": "03C3555B7339FFDDB43495A8371A3A87B4C66B67D49D06CB9BA1FDBFEEB57B6E43",
|
|
||||||
"TransactionType": "EscrowFinish",
|
|
||||||
"TxnSignature": "3045022100923B91BA4FD6450813F5335D71C64BA9EB81304A86859A631F2AD8571424A46502200CCE660D36781B84634C5F23619EB6CFCCF942709F54DCCF27CF6F499AE78C9B",
|
|
||||||
"date": 557256681,
|
|
||||||
"hash": "41856A742B3CAF307E7B4D0B850F302101F0F415B785454F7501E9960A2A1F6B",
|
|
||||||
"inLedger": 1908257,
|
|
||||||
"ledger_index": 1908257,
|
|
||||||
"meta": {
|
|
||||||
"AffectedNodes": [
|
|
||||||
{
|
|
||||||
"ModifiedNode": {
|
|
||||||
"FinalFields": {
|
|
||||||
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
|
||||||
"Balance": "400210000",
|
|
||||||
"Flags": 0,
|
|
||||||
"OwnerCount": 0,
|
|
||||||
"Sequence": 1
|
|
||||||
},
|
|
||||||
"LedgerEntryType": "AccountRoot",
|
|
||||||
"LedgerIndex": "13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8",
|
|
||||||
"PreviousFields": {
|
|
||||||
"Balance": "400200000"
|
|
||||||
},
|
|
||||||
"PreviousTxnID": "55B2057332F8999208C43BA1E7091B423A16E5ED2736C06300B4076085205263",
|
|
||||||
"PreviousTxnLgrSeq": 1828796
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"DeletedNode": {
|
|
||||||
"FinalFields": {
|
|
||||||
"Account": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"Amount": "10000",
|
|
||||||
"Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
|
||||||
"FinishAfter": 557020800,
|
|
||||||
"Flags": 0,
|
|
||||||
"OwnerNode": "0000000000000000",
|
|
||||||
"PreviousTxnID": "55B2057332F8999208C43BA1E7091B423A16E5ED2736C06300B4076085205263",
|
|
||||||
"PreviousTxnLgrSeq": 1828796
|
|
||||||
},
|
|
||||||
"LedgerEntryType": "Escrow",
|
|
||||||
"LedgerIndex": "2B9845CB9DF686B9615BF04F3EC66095A334D985E03E71B893B90FCF6D4DC9E6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ModifiedNode": {
|
|
||||||
"FinalFields": {
|
|
||||||
"Account": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"Balance": "9999989980",
|
|
||||||
"Flags": 0,
|
|
||||||
"OwnerCount": 0,
|
|
||||||
"Sequence": 3
|
|
||||||
},
|
|
||||||
"LedgerEntryType": "AccountRoot",
|
|
||||||
"LedgerIndex": "AE5AB6584A76C37C7382B6880609FC7792D90CDA36FF362AF412EB914C1715D3",
|
|
||||||
"PreviousFields": {
|
|
||||||
"Balance": "9999989990",
|
|
||||||
"OwnerCount": 1,
|
|
||||||
"Sequence": 2
|
|
||||||
},
|
|
||||||
"PreviousTxnID": "55B2057332F8999208C43BA1E7091B423A16E5ED2736C06300B4076085205263",
|
|
||||||
"PreviousTxnLgrSeq": 1828796
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ModifiedNode": {
|
|
||||||
"FinalFields": {
|
|
||||||
"Flags": 0,
|
|
||||||
"Owner": "rajgkBmMxmz161r8bWYH7CQAFZP5bA9oSG",
|
|
||||||
"RootIndex": "D623EBEEEE701D4323D0ADA5320AF35EA8CC6520EBBEF69343354CD593DABC88"
|
|
||||||
},
|
|
||||||
"LedgerEntryType": "DirectoryNode",
|
|
||||||
"LedgerIndex": "D623EBEEEE701D4323D0ADA5320AF35EA8CC6520EBBEF69343354CD593DABC88"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"TransactionIndex": 2,
|
|
||||||
"TransactionResult": "tesSUCCESS"
|
|
||||||
},
|
|
||||||
"validated": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import random
|
|
||||||
from os import urandom
|
|
||||||
|
|
||||||
from cryptoconditions import PreimageSha256
|
|
||||||
|
|
||||||
# """Generate a condition and fulfillment for escrows"""
|
|
||||||
|
|
||||||
# Generate a random preimage with at least 32 bytes of cryptographically-secure randomness.
|
|
||||||
secret = urandom(32)
|
|
||||||
|
|
||||||
# Generate cryptic image from secret
|
|
||||||
fufill = PreimageSha256(preimage=secret)
|
|
||||||
|
|
||||||
# Parse image and return the condition and fulfillment
|
|
||||||
condition = str.upper(fufill.condition_binary.hex()) # conditon
|
|
||||||
fulfillment = str.upper(fufill.serialize_binary().hex()) # fulfillment
|
|
||||||
|
|
||||||
# Print condition and fulfillment
|
|
||||||
print(f"condition: {condition} \n fulfillment {fulfillment}")
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta, UTC
|
||||||
from os import urandom
|
from os import urandom
|
||||||
|
|
||||||
from cryptoconditions import PreimageSha256
|
from cryptoconditions import PreimageSha256
|
||||||
@@ -28,7 +28,7 @@ print("Fulfillment:", fulfillment_hex)
|
|||||||
|
|
||||||
# Set the escrow expiration -------------------------------------------------
|
# Set the escrow expiration -------------------------------------------------
|
||||||
cancel_delay = 300
|
cancel_delay = 300
|
||||||
cancel_after = datetime.now() + timedelta(seconds=cancel_delay)
|
cancel_after = datetime.now(tz=UTC) + timedelta(seconds=cancel_delay)
|
||||||
print("This escrow will expire after", cancel_after)
|
print("This escrow will expire after", cancel_after)
|
||||||
cancel_after_rippletime = datetime_to_ripple_time(cancel_after)
|
cancel_after_rippletime = datetime_to_ripple_time(cancel_after)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta, UTC
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from os import urandom
|
|
||||||
|
|
||||||
from xrpl.clients import JsonRpcClient
|
from xrpl.clients import JsonRpcClient
|
||||||
from xrpl.models import EscrowCreate, EscrowFinish
|
from xrpl.models import EscrowCreate, EscrowFinish
|
||||||
@@ -21,8 +20,8 @@ destination_address = generate_faucet_wallet(client, debug=True).address
|
|||||||
|
|
||||||
# Set the escrow finish time ------------------------------------------------
|
# Set the escrow finish time ------------------------------------------------
|
||||||
delay = 30
|
delay = 30
|
||||||
finish_after = datetime.now() + timedelta(seconds=delay)
|
finish_after = datetime.now(tz=UTC) + timedelta(seconds=delay)
|
||||||
print("This escrow will expire after", finish_after)
|
print("This escrow will mature after", finish_after)
|
||||||
finish_after_rippletime = datetime_to_ripple_time(finish_after)
|
finish_after_rippletime = datetime_to_ripple_time(finish_after)
|
||||||
|
|
||||||
# Send EscrowCreate transaction ---------------------------------------------
|
# Send EscrowCreate transaction ---------------------------------------------
|
||||||
@@ -45,6 +44,7 @@ if result_code != "tesSUCCESS":
|
|||||||
|
|
||||||
# Save the sequence number so you can identify the escrow later
|
# Save the sequence number so you can identify the escrow later
|
||||||
escrow_seq = response.result["tx_json"]["Sequence"]
|
escrow_seq = response.result["tx_json"]["Sequence"]
|
||||||
|
print(f"Escrow sequence is {escrow_seq}.")
|
||||||
|
|
||||||
# Wait for the escrow to be finishable --------------------------------------
|
# Wait for the escrow to be finishable --------------------------------------
|
||||||
sleep(delay)
|
sleep(delay)
|
||||||
@@ -68,7 +68,7 @@ while not escrow_ready:
|
|||||||
sleep(time_difference)
|
sleep(time_difference)
|
||||||
|
|
||||||
|
|
||||||
# Send the EscrowFinish transaction -----------------------------------------
|
# Send EscrowFinish transaction ---------------------------------------------
|
||||||
escrow_finish = EscrowFinish(
|
escrow_finish = EscrowFinish(
|
||||||
account=wallet.address,
|
account=wallet.address,
|
||||||
owner=wallet.address,
|
owner=wallet.address,
|
||||||
|
|||||||
@@ -0,0 +1,140 @@
|
|||||||
|
---
|
||||||
|
seo:
|
||||||
|
description: Create an escrow whose release is based on a condition being fulfilled.
|
||||||
|
labels:
|
||||||
|
- Escrow
|
||||||
|
---
|
||||||
|
# Send a Conditional Escrow
|
||||||
|
|
||||||
|
This tutorial demonstrates how to send an [escrow](../../../../concepts/payment-types/escrow.md) that can be released when a specific crypto-condition is fulfilled. Essentially, a crypto-condition is like a random password that unlocks the escrow to be sent to its indicated destination. You can use this as part of an app that reveals the fulfillment only when specific actions take place.
|
||||||
|
|
||||||
|
This tutorial shows how to escrow XRP. If the [TokenEscrow amendment][] is enabled, you can also escrow tokens.
|
||||||
|
|
||||||
|
## Goals
|
||||||
|
|
||||||
|
By following this tutorial, you should learn how to:
|
||||||
|
|
||||||
|
- Convert a timestamp into the XRP Ledger's native format.
|
||||||
|
- Create and finish an escrow.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
To complete this tutorial, you should:
|
||||||
|
|
||||||
|
- Have a basic understanding of the XRP Ledger
|
||||||
|
- Have an XRP Ledger client library, such as **xrpl.js**, installed.
|
||||||
|
|
||||||
|
## Source Code
|
||||||
|
|
||||||
|
You can find the complete source code for this tutorial's examples in the {% repo-link path="_code-samples/escrow/" %}code samples section of this website's repository{% /repo-link %}.
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
### 1. Install dependencies
|
||||||
|
|
||||||
|
{% tabs %}
|
||||||
|
{% tab label="JavaScript" %}
|
||||||
|
From the code sample folder, use `npm` to install dependencies:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm i
|
||||||
|
```
|
||||||
|
{% /tab %}
|
||||||
|
|
||||||
|
{% tab label="Python" %}
|
||||||
|
From the code sample folder, set up a virtual environment and use `pip` to install dependencies:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
{% /tab %}
|
||||||
|
{% /tabs %}
|
||||||
|
|
||||||
|
### 2. Set up client and account
|
||||||
|
|
||||||
|
To get started, import the client library and instantiate an API client. For this tutorial, you also need one account, which you can get from the faucet. You also need the address of another account to send the escrow to. You can fund a second account using the faucet, or use the address of an existing account like the faucet.
|
||||||
|
|
||||||
|
{% tabs %}
|
||||||
|
{% tab label="JavaScript" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/js/send-conditional-escrow.js" language="js" before="// Create the crypto-condition" /%}
|
||||||
|
{% /tab %}
|
||||||
|
{% tab label="Python" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/py/send_conditional_escrow.py" language="py" before="# Create the crypto-condition" /%}
|
||||||
|
{% /tab %}
|
||||||
|
{% /tabs %}
|
||||||
|
|
||||||
|
### 3. Create a condition and fulfillment
|
||||||
|
|
||||||
|
Conditional escrows require a fulfillment and its corresponding condition in the format of a PREIMAGE-SHA-256 _crypto-condition_, represented as hexadecimal. To calculate these in the correct format, use a crypto-conditions library. Generally, you want to generate the fulfillment using at least 32 random bytes from a cryptographically secure source of randomness.
|
||||||
|
|
||||||
|
{% tabs %}
|
||||||
|
{% tab label="JavaScript" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/js/send-conditional-escrow.js" language="js" from="// Create the crypto-condition" before="// Set the escrow expiration" /%}
|
||||||
|
{% /tab %}
|
||||||
|
{% tab label="Python" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/py/send_conditional_escrow.py" language="py" from="# Create the crypto-condition" before="# Set the escrow expiration" /%}
|
||||||
|
{% /tab %}
|
||||||
|
{% /tabs %}
|
||||||
|
|
||||||
|
### 4. Calculate the expiration time
|
||||||
|
|
||||||
|
Conditional escrows also need an expiration time, so that the escrow can be canceled if the correct fulfillment isn't provided by the scheduled time. This timestamp must be formatted as [seconds since the Ripple Epoch][]. The sample code calculates an expiration time 30 seconds after the current time.
|
||||||
|
|
||||||
|
{% tabs %}
|
||||||
|
{% tab label="JavaScript" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/js/send-conditional-escrow.js" language="js" from="// Set the escrow expiration" before="// Send EscrowCreate transaction" /%}
|
||||||
|
{% /tab %}
|
||||||
|
{% tab label="Python" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/py/send_conditional_escrow.py" language="py" from="# Set the escrow expiration" before="# Send EscrowCreate transaction" /%}
|
||||||
|
{% /tab %}
|
||||||
|
{% /tabs %}
|
||||||
|
|
||||||
|
### 5. Create the escrow
|
||||||
|
|
||||||
|
To send the escrow, construct an [EscrowCreate transaction][] and then submit it to the network. The fields of this transaction define the properties of the escrow. The sample code uses hard-coded values to send 0.123456 XRP back to the Testnet faucet:
|
||||||
|
|
||||||
|
{% tabs %}
|
||||||
|
{% tab label="JavaScript" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/js/send-conditional-escrow.js" language="js" from="// Send EscrowCreate transaction" before="// Save the sequence number" /%}
|
||||||
|
{% /tab %}
|
||||||
|
|
||||||
|
{% tab label="Python" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/py/send_conditional_escrow.py" language="py" from="# Send EscrowCreate transaction" before="# Save the sequence number" /%}
|
||||||
|
{% /tab %}
|
||||||
|
{% /tabs %}
|
||||||
|
|
||||||
|
### 6. Finish the escrow
|
||||||
|
|
||||||
|
Anyone with the correct fulfillment can immediately finish a conditional escrow (unless it's a timed conditinal escrow with a `FinishAfter` time). To do this, construct an [EscrowFinish transaction][], using the sequence number that you recorded when you created the escrow, and the matching condition and fulfillment for the escrow, then submit it to the network.
|
||||||
|
|
||||||
|
{% admonition type="warning" name="Caution" %}A conditional EscrowFinish requires a [higher than normal transaction cost](../../../../concepts/transactions/transaction-cost.md#special-transaction-costs) based on the size of the fulfillment in bytes. Most libraries should specify an appropriate amount of XRP when autofilling, but you should be mindful of this when specifying the `Fee` field manually.{% /admonition %}
|
||||||
|
|
||||||
|
{% tabs %}
|
||||||
|
{% tab label="JavaScript" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/js/send-conditional-escrow.js" language="js" from="// Send EscrowFinish transaction" /%}
|
||||||
|
{% /tab %}
|
||||||
|
|
||||||
|
{% tab label="Python" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/py/send_conditional_escrow.py" language="py" from="# Send EscrowFinish transaction" /%}
|
||||||
|
{% /tab %}
|
||||||
|
{% /tabs %}
|
||||||
|
|
||||||
|
|
||||||
|
## See Also
|
||||||
|
|
||||||
|
- [Crypto-Conditions Specification][]
|
||||||
|
- **Concepts:**
|
||||||
|
- [Escrow](../../../../concepts/payment-types/escrow.md)
|
||||||
|
- **Tutorials:**
|
||||||
|
- [Send XRP](../../send-xrp.md)
|
||||||
|
- [Look Up Transaction Results](../../../../concepts/transactions/finality-of-results/look-up-transaction-results.md)
|
||||||
|
- [Reliable Transaction Submission](../../../../concepts/transactions/reliable-transaction-submission.md)
|
||||||
|
- **References:**
|
||||||
|
- [EscrowCancel transaction][]
|
||||||
|
- [EscrowCreate transaction][]
|
||||||
|
- [EscrowFinish transaction][]
|
||||||
|
- [Escrow ledger object](../../../../references/protocol/ledger-data/ledger-entry-types/escrow.md)
|
||||||
|
|
||||||
|
{% raw-partial file="/docs/_snippets/common-links.md" /%}
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
---
|
|
||||||
html: send-a-conditionally-held-escrow.html
|
|
||||||
parent: use-escrows.html
|
|
||||||
seo:
|
|
||||||
description: Create an escrow whose release is based on a condition being fulfilled.
|
|
||||||
labels:
|
|
||||||
- Escrow
|
|
||||||
- Smart Contracts
|
|
||||||
---
|
|
||||||
# Send a Conditionally-Held Escrow
|
|
||||||
|
|
||||||
## 1. Generate condition and fulfillment
|
|
||||||
|
|
||||||
XRP Ledger escrows require PREIMAGE-SHA-256 [crypto-conditions][]. To calculate a condition and fulfillment in the proper format, you should use a crypto-conditions library such as [five-bells-condition](https://github.com/interledgerjs/five-bells-condition). To generate the fulfillment:
|
|
||||||
|
|
||||||
- Use a cryptographically secure source of randomness to generate at least 32 random bytes.
|
|
||||||
- Follow Interledger Protocol's [PSK specification](https://github.com/interledger/rfcs/blob/master/deprecated/0016-pre-shared-key/0016-pre-shared-key.md) and use an HMAC-SHA-256 of the ILP packet as the fulfillment. <!-- SPELLING_IGNORE: psk -->
|
|
||||||
|
|
||||||
Example code for a random fulfillment and condition:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="JavaScript" %}
|
|
||||||
```js
|
|
||||||
const cc = require('five-bells-condition')
|
|
||||||
const crypto = require('crypto')
|
|
||||||
|
|
||||||
const preimageData = crypto.randomBytes(32)
|
|
||||||
const fulfillment = new cc.PreimageSha256()
|
|
||||||
fulfillment.setPreimage(preimageData)
|
|
||||||
|
|
||||||
const condition = fulfillment.getConditionBinary().toString('hex').toUpperCase()
|
|
||||||
console.log('Condition:', condition)
|
|
||||||
|
|
||||||
// Keep secret until you want to finish the escrow
|
|
||||||
const fulfillment_hex = fulfillment.serializeBinary().toString('hex').toUpperCase()
|
|
||||||
console.log('Fulfillment:', fulfillment_hex)
|
|
||||||
```
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% tab label="Python" %}
|
|
||||||
```py
|
|
||||||
from os import urandom
|
|
||||||
from cryptoconditions import PreimageSha256
|
|
||||||
|
|
||||||
secret = urandom(32)
|
|
||||||
|
|
||||||
fulfillment = PreimageSha256(preimage=secret)
|
|
||||||
|
|
||||||
print("Condition", fulfillment.condition_binary.hex().upper())
|
|
||||||
|
|
||||||
# Keep secret until you want to finish the escrow
|
|
||||||
print("Fulfillment", fulfillment.serialize_binary().hex().upper())
|
|
||||||
```
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
Save the condition and the fulfillment for later. Be sure to keep the fulfillment secret until you want to finish executing the held payment. Anyone who knows the fulfillment can finish the escrow, releasing the held funds to their intended destination.
|
|
||||||
|
|
||||||
|
|
||||||
## 2. Calculate release or cancel time
|
|
||||||
|
|
||||||
A Conditional `Escrow` transaction must contain either a `CancelAfter` or `FinishAfter` field, or both. The `CancelAfter` field lets the XRP revert to the sender if the condition is not fulfilled before the specified time. The `FinishAfter` field specifies a time before which the escrow cannot execute, even if someone sends the correct fulfillment. Whichever field you provide, the time it specifies must be in the future.
|
|
||||||
|
|
||||||
Example for setting a `CancelAfter` time of 24 hours in the future:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="JavaScript" %}
|
|
||||||
```js
|
|
||||||
const rippleOffset = 946684800
|
|
||||||
const CancelAfter = Math.floor(Date.now() / 1000) + (24*60*60) - rippleOffset
|
|
||||||
console.log(CancelAfter)
|
|
||||||
// Example: 556927412
|
|
||||||
```
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% tab label="Python 2/3" %}
|
|
||||||
```python
|
|
||||||
from time import time
|
|
||||||
ripple_offset = 946684800
|
|
||||||
cancel_after = int(time()) + (24*60*60) - 946684800
|
|
||||||
print(cancel_after)
|
|
||||||
# Example: 556927412
|
|
||||||
```
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
{% admonition type="danger" name="Warning" %}In the XRP Ledger, you must specify time as **[seconds since the Ripple Epoch][]**. If you use a UNIX time in the `CancelAfter` or `FinishAfter` field without converting it, that sets the unlock time to an extra **30 years** in the future!{% /admonition %}
|
|
||||||
|
|
||||||
## 3. Submit EscrowCreate transaction
|
|
||||||
|
|
||||||
[Sign and submit](../../../../concepts/transactions/index.md#signing-and-submitting-transactions) an [EscrowCreate transaction][]. Set the `Condition` field of the transaction to the time when the held payment should be released. Set the `Destination` to the recipient, which can be the same address as the sender. Include the `CancelAfter` or `FinishAfter` time you calculated in the previous step. Set the `Amount` to the total amount of [XRP, in drops][], to escrow.
|
|
||||||
|
|
||||||
{% partial file="/docs/_snippets/secret-key-warning.md" /%}
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
Request:
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-request-escrowcreate-condition.json" language="json" /%}
|
|
||||||
|
|
||||||
Response:
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-response-escrowcreate-condition.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% tab label="Python" %}
|
|
||||||
{% code-snippet file="/_code-samples/escrow/py/create_escrow.py" language="py" from="# Build escrow create" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
<!-- TODO: re-add a working JS example. Removed the old one due to the sample code being refactored -->
|
|
||||||
|
|
||||||
## 4. Wait for validation
|
|
||||||
|
|
||||||
{% raw-partial file="/docs/_snippets/wait-for-validation.md" /%}
|
|
||||||
|
|
||||||
## 5. Confirm that the escrow was created
|
|
||||||
|
|
||||||
Use the [tx method][] with the transaction's identifying hash to check its final status. In particular, look for a `CreatedNode` in the transaction metadata to indicate that it created an [Escrow ledger object](../../../../concepts/payment-types/escrow.md).
|
|
||||||
|
|
||||||
Request:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-request-escrowcreate-condition.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
Response:
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-response-escrowcreate-condition.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
## 6. Submit EscrowFinish transaction
|
|
||||||
|
|
||||||
[Sign and submit](../../../../concepts/transactions/index.md#signing-and-submitting-transactions) an [EscrowFinish transaction][] to execute the release of the funds after the `FinishAfter` time has passed. Set the `Owner` field of the transaction to the `Account` address from the EscrowCreate transaction, and the `OfferSequence` to the `Sequence` number from the EscrowCreate transaction. Set the `Condition` and `Fulfillment` fields to the condition and fulfillment values, in hexadecimal, that you generated in step 1. Set the `Fee` ([transaction cost](../../../../concepts/transactions/transaction-cost.md)) value based on the size of the fulfillment in bytes: a conditional EscrowFinish requires at least 330 drops of XRP plus 10 drops per 16 bytes in the size of the fulfillment.
|
|
||||||
|
|
||||||
{% admonition type="info" name="Note" %}If you included a `FinishAfter` field in the EscrowCreate transaction, you cannot execute it before that time has passed, even if you provide the correct fulfillment for the Escrow's condition. The EscrowFinish transaction fails with the [result code](../../../../references/protocol/transactions/transaction-results/index.md) `tecNO_PERMISSION` if the previously-closed ledger's close time is before the `FinishAfter` time.{% /admonition %}
|
|
||||||
|
|
||||||
If the escrow has expired, you can only [cancel the escrow](cancel-an-expired-escrow.md) instead.
|
|
||||||
|
|
||||||
{% partial file="/docs/_snippets/secret-key-warning.md" /%}
|
|
||||||
|
|
||||||
{% tabs %}
|
|
||||||
|
|
||||||
{% tab label="Websocket" %}
|
|
||||||
Request:
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-request-escrowfinish-condition.json" language="json" /%}
|
|
||||||
|
|
||||||
Response:
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-response-escrowfinish-condition.json" language="json" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% tab label="Javascript" %}
|
|
||||||
{% code-snippet file="/_code-samples/escrow/js/finish-escrow.js" language="js" from="// Prepare EscrowFinish" before="await client.disconnect" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% tab label="Python" %}
|
|
||||||
{% code-snippet file="/_code-samples/escrow/py/finish_escrow.py" language="py" from="# Build escrow finish" /%}
|
|
||||||
{% /tab %}
|
|
||||||
|
|
||||||
{% /tabs %}
|
|
||||||
|
|
||||||
Take note of the transaction's identifying `hash` value so you can check its final status when it is included in a validated ledger version.
|
|
||||||
|
|
||||||
## 7. Wait for validation
|
|
||||||
|
|
||||||
{% raw-partial file="/docs/_snippets/wait-for-validation.md" /%}
|
|
||||||
|
|
||||||
## 8. Confirm final result
|
|
||||||
|
|
||||||
Use the [tx method][] with the EscrowFinish transaction's identifying hash to check its final status. In particular, look in the transaction metadata for a `ModifiedNode` of type `AccountRoot` for the destination of the escrowed payment. The `FinalFields` of the object should show the increase in XRP in the `Balance` field.
|
|
||||||
|
|
||||||
Request:
|
|
||||||
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-request-escrowfinish-condition.json" language="json" /%}
|
|
||||||
|
|
||||||
Response:
|
|
||||||
|
|
||||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-response-escrowfinish-condition.json" language="json" /%}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## See Also
|
|
||||||
|
|
||||||
- [Crypto-Conditions Specification][]
|
|
||||||
- **Concepts:**
|
|
||||||
- [What is XRP?](../../../../introduction/what-is-xrp.md)
|
|
||||||
- [Payment Types](../../../../concepts/payment-types/index.md)
|
|
||||||
- [Escrow](../../../../concepts/payment-types/escrow.md)
|
|
||||||
- **Tutorials:**
|
|
||||||
- [Send XRP](../../send-xrp.md)
|
|
||||||
- [Look Up Transaction Results](../../../../concepts/transactions/finality-of-results/look-up-transaction-results.md)
|
|
||||||
- [Reliable Transaction Submission](../../../../concepts/transactions/reliable-transaction-submission.md)
|
|
||||||
- **References:**
|
|
||||||
- [EscrowCancel transaction][]
|
|
||||||
- [EscrowCreate transaction][]
|
|
||||||
- [EscrowFinish transaction][]
|
|
||||||
- [account_objects method][]
|
|
||||||
- [tx method][]
|
|
||||||
- [Escrow ledger object](../../../../references/protocol/ledger-data/ledger-entry-types/escrow.md)
|
|
||||||
|
|
||||||
{% raw-partial file="/docs/_snippets/common-links.md" /%}
|
|
||||||
@@ -26,7 +26,7 @@ To complete this tutorial, you should:
|
|||||||
|
|
||||||
## Source Code
|
## Source Code
|
||||||
|
|
||||||
You can find the complete source code for this tutorial's examples in the {% repo-link path="_code-samples/escrow/send-timed-escrow.js" %}code samples section of this website's repository{% /repo-link %}.
|
You can find the complete source code for this tutorial's examples in the {% repo-link path="_code-samples/escrow/" %}code samples section of this website's repository{% /repo-link %}.
|
||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
|
|
||||||
@@ -34,22 +34,35 @@ You can find the complete source code for this tutorial's examples in the {% rep
|
|||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab label="JavaScript" %}
|
{% tab label="JavaScript" %}
|
||||||
From the code sample folder, use npm to install dependencies:
|
From the code sample folder, use `npm` to install dependencies:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm i
|
npm i
|
||||||
```
|
```
|
||||||
{% /tab %}
|
{% /tab %}
|
||||||
|
|
||||||
|
{% tab label="Python" %}
|
||||||
|
From the code sample folder, set up a virtual environment and use `pip` to install dependencies:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
{% /tab %}
|
||||||
{% /tabs %}
|
{% /tabs %}
|
||||||
|
|
||||||
### 2. Set up client and account
|
### 2. Set up client and account
|
||||||
|
|
||||||
To get started, import the client library and instantiate an API client. For this tutorial, you also need one account, which you can get from the faucet.
|
To get started, import the client library and instantiate an API client. For this tutorial, you also need one account, which you can get from the faucet. You also need the address of another account to send the escrow to. You can fund a second account using the faucet, or use the address of an existing account like the faucet.
|
||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab label="JavaScript" %}
|
{% tab label="JavaScript" %}
|
||||||
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" before="// Set the escrow finish time" /%}
|
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" before="// Set the escrow finish time" /%}
|
||||||
{% /tab %}
|
{% /tab %}
|
||||||
|
{% tab label="Python" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/py/send_timed_escrow.py" language="py" before="# Set the escrow finish time" /%}
|
||||||
|
{% /tab %}
|
||||||
{% /tabs %}
|
{% /tabs %}
|
||||||
|
|
||||||
### 3. Calculate the finish time
|
### 3. Calculate the finish time
|
||||||
@@ -60,6 +73,10 @@ To make a timed escrow, you need to set the maturity time of the escrow, which i
|
|||||||
{% tab label="JavaScript" %}
|
{% tab label="JavaScript" %}
|
||||||
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" from="// Set the escrow finish time" before="// Send EscrowCreate transaction" /%}
|
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" from="// Set the escrow finish time" before="// Send EscrowCreate transaction" /%}
|
||||||
{% /tab %}
|
{% /tab %}
|
||||||
|
|
||||||
|
{% tab label="Python" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/py/send_timed_escrow.py" language="py" from="# Set the escrow finish time" before="# Send EscrowCreate transaction" /%}
|
||||||
|
{% /tab %}
|
||||||
{% /tabs %}
|
{% /tabs %}
|
||||||
|
|
||||||
{% admonition type="danger" name="Warning" %}If you use a UNIX time without converting to the equivalent Ripple time first, that sets the maturity time to an extra **30 years** in the future!{% /admonition %}
|
{% admonition type="danger" name="Warning" %}If you use a UNIX time without converting to the equivalent Ripple time first, that sets the maturity time to an extra **30 years** in the future!{% /admonition %}
|
||||||
@@ -73,13 +90,25 @@ To send the escrow, construct an [EscrowCreate transaction][] and then submit it
|
|||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab label="JavaScript" %}
|
{% tab label="JavaScript" %}
|
||||||
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" from="// Send EscrowCreate transaction" before="// Save the sequence number" /%}
|
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" from="// Send EscrowCreate transaction" before="// Save the sequence number" /%}
|
||||||
|
{% /tab %}
|
||||||
|
|
||||||
|
{% tab label="Python" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/py/send_timed_escrow.py" language="py" from="# Send EscrowCreate transaction" before="# Save the sequence number" /%}
|
||||||
|
{% /tab %}
|
||||||
|
{% /tabs %}
|
||||||
|
|
||||||
{% admonition type="info" name="Note" %}To give the escrow an expiration time, add a `CancelAfter` field to the transaction. An expiration time is optional for timed XRP escrows but required for token escrows. This time must be after the maturity time.{% /admonition %}
|
{% admonition type="info" name="Note" %}To give the escrow an expiration time, add a `CancelAfter` field to the transaction. An expiration time is optional for timed XRP escrows but required for token escrows. This time must be after the maturity time.{% /admonition %}
|
||||||
|
|
||||||
Save the sequence number of the EscrowCreate transaction. (In this example, the sequence number is autofilled.) You need this sequence number to identify the escrow when you want to finish (or cancel) it later.
|
Save the sequence number of the EscrowCreate transaction. (In this example, the sequence number is autofilled.) You need this sequence number to identify the escrow when you want to finish (or cancel) it later.
|
||||||
|
|
||||||
|
{% tabs %}
|
||||||
|
{% tab label="JavaScript" %}
|
||||||
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" from="// Save the sequence number" before="// Wait for the escrow" /%}
|
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" from="// Save the sequence number" before="// Wait for the escrow" /%}
|
||||||
{% /tab %}
|
{% /tab %}
|
||||||
|
|
||||||
|
{% tab label="Python" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/py/send_timed_escrow.py" language="py" from="# Save the sequence number" before="# Wait for the escrow" /%}
|
||||||
|
{% /tab %}
|
||||||
{% /tabs %}
|
{% /tabs %}
|
||||||
|
|
||||||
|
|
||||||
@@ -95,6 +124,10 @@ JavaScript doesn't have a native `sleep(...)` function, but you can implement on
|
|||||||
|
|
||||||
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" from="/* Sleep function" before="// Check if escrow can be finished" /%}
|
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" from="/* Sleep function" before="// Check if escrow can be finished" /%}
|
||||||
{% /tab %}
|
{% /tab %}
|
||||||
|
|
||||||
|
{% tab label="Python" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/py/send_timed_escrow.py" language="py" from="# Wait for the escrow" before="# Check if escrow can be finished" /%}
|
||||||
|
{% /tab %}
|
||||||
{% /tabs %}
|
{% /tabs %}
|
||||||
|
|
||||||
At this point, the escrow should be mature, but that depends on the official close time of the previous ledger. Ledger close times can vary based on the consensus process, and [are rounded](../../../../concepts/ledgers/ledger-close-times.md) by up to 10 seconds. To account for this variance, use an approach such as the following:
|
At this point, the escrow should be mature, but that depends on the official close time of the previous ledger. Ledger close times can vary based on the consensus process, and [are rounded](../../../../concepts/ledgers/ledger-close-times.md) by up to 10 seconds. To account for this variance, use an approach such as the following:
|
||||||
@@ -107,6 +140,10 @@ At this point, the escrow should be mature, but that depends on the official clo
|
|||||||
{% tab label="JavaScript" %}
|
{% tab label="JavaScript" %}
|
||||||
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" from="// Check if escrow can be finished" before="// Send EscrowFinish transaction" /%}
|
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" from="// Check if escrow can be finished" before="// Send EscrowFinish transaction" /%}
|
||||||
{% /tab %}
|
{% /tab %}
|
||||||
|
|
||||||
|
{% tab label="Python" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/py/send_timed_escrow.py" language="py" from="# Check if escrow can be finished" before="# Send EscrowFinish transaction" /%}
|
||||||
|
{% /tab %}
|
||||||
{% /tabs %}
|
{% /tabs %}
|
||||||
|
|
||||||
### 6. Finish the escrow
|
### 6. Finish the escrow
|
||||||
@@ -119,15 +156,17 @@ Now that the escrow is mature, you can finish it. Construct an [EscrowFinish tra
|
|||||||
{% tab label="JavaScript" %}
|
{% tab label="JavaScript" %}
|
||||||
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" from="// Send EscrowFinish transaction" /%}
|
{% code-snippet file="/_code-samples/escrow/js/send-timed-escrow.js" language="js" from="// Send EscrowFinish transaction" /%}
|
||||||
{% /tab %}
|
{% /tab %}
|
||||||
|
|
||||||
|
{% tab label="Python" %}
|
||||||
|
{% code-snippet file="/_code-samples/escrow/py/send_timed_escrow.py" language="py" from="# Send EscrowFinish transaction" /%}
|
||||||
|
{% /tab %}
|
||||||
{% /tabs %}
|
{% /tabs %}
|
||||||
|
|
||||||
|
|
||||||
## See Also
|
## See Also
|
||||||
|
|
||||||
- **Concepts:**
|
- **Concepts:**
|
||||||
- [What is XRP?](../../../../introduction/what-is-xrp.md)
|
- [Escrow](../../../../concepts/payment-types/escrow.md)
|
||||||
- [Payment Types](../../../../concepts/payment-types/index.md)
|
|
||||||
- [Escrow](../../../../concepts/payment-types/escrow.md)
|
|
||||||
- **Tutorials:**
|
- **Tutorials:**
|
||||||
- [Send XRP](../../send-xrp.md)
|
- [Send XRP](../../send-xrp.md)
|
||||||
- [Look Up Transaction Results](../../../../concepts/transactions/finality-of-results/look-up-transaction-results.md)
|
- [Look Up Transaction Results](../../../../concepts/transactions/finality-of-results/look-up-transaction-results.md)
|
||||||
@@ -136,8 +175,6 @@ Now that the escrow is mature, you can finish it. Construct an [EscrowFinish tra
|
|||||||
- [EscrowCancel transaction][]
|
- [EscrowCancel transaction][]
|
||||||
- [EscrowCreate transaction][]
|
- [EscrowCreate transaction][]
|
||||||
- [EscrowFinish transaction][]
|
- [EscrowFinish transaction][]
|
||||||
- [account_objects method][]
|
|
||||||
- [tx method][]
|
|
||||||
- [Escrow ledger object](../../../../references/protocol/ledger-data/ledger-entry-types/escrow.md)
|
- [Escrow ledger object](../../../../references/protocol/ledger-data/ledger-entry-types/escrow.md)
|
||||||
|
|
||||||
{% raw-partial file="/docs/_snippets/common-links.md" /%}
|
{% raw-partial file="/docs/_snippets/common-links.md" /%}
|
||||||
|
|||||||
@@ -1,156 +0,0 @@
|
|||||||
---
|
|
||||||
html: use-an-escrow-as-a-smart-contract.html
|
|
||||||
parent: use-escrows.html
|
|
||||||
seo:
|
|
||||||
description: Use a cryptographic escrow as a smart contract to ensure a recipient gets paid only if they successfully perform a service.
|
|
||||||
labels:
|
|
||||||
- Escrow
|
|
||||||
- Smart Contracts
|
|
||||||
---
|
|
||||||
# Use an Escrow as a Smart Contract
|
|
||||||
|
|
||||||
A smart contract is a blockchain-based program that encodes the conditions and fulfillment of an agreement between two or more parties and automatically fulfills the terms of the agreement once conditions are met. A smart contract can help you exchange anything of value in a transparent, traceable, tamper-resistant, and irreversible way.
|
|
||||||
|
|
||||||
The benefit of encoding a smart contract into a blockchain is that it enables the contract to be securely carried out without traditional third-parties, like financial or legal institutions. Instead, the contract is supervised by the distributed, decentralized network of computers that run the blockchain.
|
|
||||||
|
|
||||||
You can use XRP Ledger escrows as smart contracts that release XRP after a certain time has passed or after a cryptographic condition has been fulfilled. In this case, we'll use an escrow as a smart contract that releases XRP after a cryptographic condition has been fulfilled.
|
|
||||||
|
|
||||||
Let's use this scenario to help illustrate this use case: A party planner uses smart contracts to manage payments from party hosts to party vendors. Specifically, the party planner wants to use a smart contract to have the party host pay the party band 2000 XRP once they are done with their set.
|
|
||||||
|
|
||||||
In this use case, the party host is the sender of the escrow, the party band is the receiver of the escrow, and the party planner is playing the role of an _oracle_. In the context of smart contracts, an oracle is a neutral third-party agent that can verify real-world events to either fulfill or invalidate a smart contract. This use case uses a human oracle for illustrative purposes, but in real-life, a software application would more likely play the role of the oracle.
|
|
||||||
|
|
||||||
Using an XRP Ledger escrow to provide this smart contract is a great arrangement because the party planner, as the third-party oracle, never "holds" the funds as one might in a traditional escrow arrangement, and can't possibly take the funds for themselves.
|
|
||||||
|
|
||||||
Here’s a roadmap to the high-level tasks that these participants need to complete to use an escrow as a smart contract.
|
|
||||||
|
|
||||||
|
|
||||||
## Meet the prerequisites
|
|
||||||
|
|
||||||
The party host (sender) must have:
|
|
||||||
|
|
||||||
- An XRP Ledger [account](../../../../concepts/accounts/index.md#creating-accounts) that holds enough XRP to pay for escrow and any fees incurred.
|
|
||||||
|
|
||||||
- Access to a secure signing environment, which includes having a network connection to a [`rippled` server](../../../../infrastructure/installation/index.md) (any server) that they can submit signed transactions to. <!--#{ once set up secure signing tutorial is available, link to it from here }# -->
|
|
||||||
|
|
||||||
The party band (receiver) must have:
|
|
||||||
|
|
||||||
- An XRP Ledger [account](../../../../concepts/accounts/index.md#creating-accounts) that can receive the XRP paid by the escrow.
|
|
||||||
|
|
||||||
- Access to a [`rippled` server](../../../../infrastructure/installation/index.md) that they can use to look up the details of an XRP Ledger transaction hash and submit the fulfillment value to finish the escrow.
|
|
||||||
|
|
||||||
The party planner (oracle) must have:
|
|
||||||
|
|
||||||
- The ability to generate a condition and a fulfillment.
|
|
||||||
|
|
||||||
- To be able to keep a secret (the fulfillment) until the time is right.
|
|
||||||
|
|
||||||
- A way to communicate the fulfillment publicly or at least to the party band when the time is right.
|
|
||||||
|
|
||||||
- The ability to recognize whether the party band has fulfilled their end of the contract (played at the party).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Define the terms of the smart contract
|
|
||||||
|
|
||||||
To create the escrow as a smart contract, the participants must first define the terms of the contract. In this scenario, the participants need to agree on the following details.
|
|
||||||
|
|
||||||
- **Should the escrow disallow fulfillment until a specific time?**
|
|
||||||
|
|
||||||
```
|
|
||||||
While this is an option, the participants agree that it is unnecessary for their escrow. For conditionally-held escrows, enabling this option doesn't provide any additional security, since whether the escrow can be finished still depends entirely on whether the party planner (oracle) publishes the fulfillment before the expiration.
|
|
||||||
```
|
|
||||||
|
|
||||||
- **Should the escrow expire?**
|
|
||||||
|
|
||||||
```
|
|
||||||
Absolutely yes. The participants agree that the escrow should expire after 12 noon the day after the party. This gives the party band (receiver) enough time to finish the escrow, after the party planner verifies that they fulfilled their end of the contract and publishes the cryptographic fulfillment. After expiration, the locked XRP returns to the party host's (sender's) account.
|
|
||||||
|
|
||||||
If the participants don't allow the escrow to expire and the party planner doesn't release the condition, the XRP stays locked in the escrow forever.
|
|
||||||
```
|
|
||||||
|
|
||||||
- **How much XRP should the escrow lock up and potentially pay?**
|
|
||||||
|
|
||||||
```
|
|
||||||
The participants agree that the escrow should lock up and potentially pay 2000 XRP, which is the party band's fee.
|
|
||||||
```
|
|
||||||
|
|
||||||
- **From which XRP Ledger account should the escrow lock up XRP for potential payment to the party band?**
|
|
||||||
|
|
||||||
```
|
|
||||||
The participants agree that the escrow should lock up and potentially pay XRP out of the party host's XRP Ledger account.
|
|
||||||
```
|
|
||||||
|
|
||||||
- **Which XRP Ledger account should the escrow potentially pay XRP to?**
|
|
||||||
|
|
||||||
```
|
|
||||||
The participants agree that the escrow should potentially pay XRP to the party band's XRP Ledger account.
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Oracle: Generate a condition and a fulfillment
|
|
||||||
|
|
||||||
Because participants want to create a conditionally-held escrow to provide the smart contract, they need a condition value and a fulfillment value. In this scenario, the participant that creates these values is the neutral party planner (oracle).
|
|
||||||
|
|
||||||
The party planner generates the condition and fulfillment values. The party planner provides the condition value to the party host, who creates the escrow. The party planner also provides the condition to the party band so that they know that this is the right condition.
|
|
||||||
|
|
||||||
The party planner must keep the fulfillment value a secret. Anyone can use the condition and fulfillment values to finish the escrow. Most often, the receiver finishes the escrow because they're the ones who are motivated to get paid.
|
|
||||||
|
|
||||||
[Generate a condition and a fulfillment >](send-a-conditionally-held-escrow.md#1-generate-condition-and-fulfillment)
|
|
||||||
|
|
||||||
|
|
||||||
## Sender: Calculate time values needed for the escrow
|
|
||||||
|
|
||||||
Because the participants want the escrow to be eligible for cancellation after 12 noon the day after the party, the party host (sender) must calculate a `CancelAfter` value to include in the escrow definition.
|
|
||||||
|
|
||||||
[Calculate time values needed for the escrow >](send-a-conditionally-held-escrow.md#2-calculate-release-or-cancel-time)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Sender: Create the escrow
|
|
||||||
|
|
||||||
The party host (sender) creates the escrow that provides the smart contract. The party host must create the escrow because they are the only participant that can authorize the lock up and potential payout of XRP from their XRP Ledger account.
|
|
||||||
|
|
||||||
[Create the escrow >](send-a-conditionally-held-escrow.md#3-submit-escrowcreate-transaction)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Sender and Receiver: Wait for validation and confirm escrow creation
|
|
||||||
|
|
||||||
The party host (sender) waits for validation of the ledger that contains the escrow creation transaction and then confirms that the escrow was created.
|
|
||||||
|
|
||||||
[Wait for validation >](send-a-conditionally-held-escrow.md#4-wait-for-validation)
|
|
||||||
|
|
||||||
The party host then provides the escrow transaction's `hash` value to the party band (receiver). The party band can use the `hash` value to look up the escrow transaction on the XRP Ledger to ensure that it was created according to the smart contract terms they agreed to. As part of this step, the party band should confirm that the condition matches the one the party planner (oracle) provided. If the condition is wrong, the fulfillment the party planner provides won't let the party band finish the escrow and get paid.
|
|
||||||
|
|
||||||
[confirm escrow creation >](send-a-conditionally-held-escrow.md#5-confirm-that-the-escrow-was-created)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Receiver: Finish the escrow
|
|
||||||
|
|
||||||
The party band (receiver) shows up and plays their set.
|
|
||||||
|
|
||||||
The party planner (oracle) is present at the party to ensure that everything is going smoothly. The party planner confirms first-hand that the party band has fulfilled their contract and publishes the fulfillment publicly, or at least to the party band.
|
|
||||||
|
|
||||||
The party band must finish the escrow before 12 noon. If they don't, the escrow expires and the party band doesn't get paid.
|
|
||||||
|
|
||||||
If the party planner does not publish the fulfillment (the party band is a no show) or if the party planner publishes the fulfillment, but no one finishes the escrow; after 12 noon the next day, anyone can [cancel the escrow](cancel-an-expired-escrow.md). Cancelling the escrow returns the held XRP to the party host's account.
|
|
||||||
|
|
||||||
[Finish the escrow >](send-a-conditionally-held-escrow.md#6-submit-escrowfinish-transaction)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Receiver and Sender: Wait for validation and confirm final result
|
|
||||||
|
|
||||||
The party band (receiver) waits for validation of the ledger that contains the escrow finish transaction and then confirms that the escrow was finished.
|
|
||||||
|
|
||||||
At this time, the party band provides the transaction's `hash` value to the party host (sender). They can use the `hash` value to look up the escrow transaction on the XRP Ledger to ensure that it is been finished correctly.
|
|
||||||
|
|
||||||
The party band can check their XRP Ledger account balance to ensure that their balance has increased by 2000 XRP. The party host's balance won't change at this step (unless the escrow was canceled) because the escrow creation already debited the locked-up XRP from their account.
|
|
||||||
|
|
||||||
[Wait for validation >](send-a-conditionally-held-escrow.md#7-wait-for-validation)
|
|
||||||
|
|
||||||
[confirm final result >](send-a-conditionally-held-escrow.md#8-confirm-final-result)
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
---
|
---
|
||||||
html: escrow-uc.html
|
|
||||||
parent: payments-uc.html
|
|
||||||
seo:
|
seo:
|
||||||
description: Transactions allow accounts to modify the XRP Ledger.
|
description: Transactions allow accounts to modify the XRP Ledger.
|
||||||
labels:
|
labels:
|
||||||
@@ -45,7 +43,7 @@ The oracle gives the condition hex value to the escrow creator, enabling them to
|
|||||||
|
|
||||||
After the oracle's programming detects the conditions are met, it gives the fulfillment hex value to the escrow recipient. It does nothing else after this point, such as finishing the escrow. The recipient of the escrow would most likely finish the escrow.
|
After the oracle's programming detects the conditions are met, it gives the fulfillment hex value to the escrow recipient. It does nothing else after this point, such as finishing the escrow. The recipient of the escrow would most likely finish the escrow.
|
||||||
|
|
||||||
See: [Generate a condition and fulfillment](../../tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-conditionally-held-escrow.md#1-generate-condition-and-fulfillment).
|
See: [Send a conditional escrow](../../tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-conditional-escrow.md).
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|||||||
@@ -734,7 +734,7 @@ send-a-time-held-escrow.html:
|
|||||||
to: /docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-time-held-escrow
|
to: /docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-time-held-escrow
|
||||||
type: 301
|
type: 301
|
||||||
send-a-conditionally-held-escrow.html:
|
send-a-conditionally-held-escrow.html:
|
||||||
to: /docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-conditionally-held-escrow
|
to: /docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-conditional-escrow
|
||||||
type: 301
|
type: 301
|
||||||
cancel-an-expired-escrow.html:
|
cancel-an-expired-escrow.html:
|
||||||
to: /docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/cancel-an-expired-escrow
|
to: /docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/cancel-an-expired-escrow
|
||||||
@@ -743,7 +743,7 @@ look-up-escrows.html:
|
|||||||
to: /docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/look-up-escrows
|
to: /docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/look-up-escrows
|
||||||
type: 301
|
type: 301
|
||||||
use-an-escrow-as-a-smart-contract.html:
|
use-an-escrow-as-a-smart-contract.html:
|
||||||
to: /docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/use-an-escrow-as-a-smart-contract
|
to: /docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-conditional-escrow
|
||||||
type: 301
|
type: 301
|
||||||
use-payment-channels.html:
|
use-payment-channels.html:
|
||||||
to: /docs/tutorials/how-tos/use-specialized-payment-types/use-payment-channels
|
to: /docs/tutorials/how-tos/use-specialized-payment-types/use-payment-channels
|
||||||
@@ -3062,7 +3062,7 @@ code_of_conduct.ja:
|
|||||||
to: /ja/docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-time-held-escrow
|
to: /ja/docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-time-held-escrow
|
||||||
type: 301
|
type: 301
|
||||||
/ja/send-a-conditionally-held-escrow.html:
|
/ja/send-a-conditionally-held-escrow.html:
|
||||||
to: /ja/docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-conditionally-held-escrow
|
to: /ja/docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-conditional-escrow
|
||||||
type: 301
|
type: 301
|
||||||
/ja/cancel-an-expired-escrow.html:
|
/ja/cancel-an-expired-escrow.html:
|
||||||
to: /ja/docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/cancel-an-expired-escrow
|
to: /ja/docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/cancel-an-expired-escrow
|
||||||
@@ -3071,7 +3071,7 @@ code_of_conduct.ja:
|
|||||||
to: /ja/docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/look-up-escrows
|
to: /ja/docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/look-up-escrows
|
||||||
type: 301
|
type: 301
|
||||||
/ja/use-an-escrow-as-a-smart-contract.html:
|
/ja/use-an-escrow-as-a-smart-contract.html:
|
||||||
to: /ja/docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/use-an-escrow-as-a-smart-contract
|
to: /ja/docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-conditional-escrow
|
||||||
type: 301
|
type: 301
|
||||||
/ja/use-payment-channels.html:
|
/ja/use-payment-channels.html:
|
||||||
to: /ja/docs/tutorials/how-tos/use-specialized-payment-types/use-payment-channels
|
to: /ja/docs/tutorials/how-tos/use-specialized-payment-types/use-payment-channels
|
||||||
|
|||||||
@@ -300,10 +300,9 @@
|
|||||||
expanded: false
|
expanded: false
|
||||||
items:
|
items:
|
||||||
- page: docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-timed-escrow.md
|
- page: docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-timed-escrow.md
|
||||||
- page: docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-conditionally-held-escrow.md
|
- page: docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/send-a-conditional-escrow.md
|
||||||
- page: docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/cancel-an-expired-escrow.md
|
- page: docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/cancel-an-expired-escrow.md
|
||||||
- page: docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/look-up-escrows.md
|
- page: docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/look-up-escrows.md
|
||||||
- page: docs/tutorials/how-tos/use-specialized-payment-types/use-escrows/use-an-escrow-as-a-smart-contract.md
|
|
||||||
- page: docs/tutorials/how-tos/use-specialized-payment-types/use-payment-channels/index.md
|
- page: docs/tutorials/how-tos/use-specialized-payment-types/use-payment-channels/index.md
|
||||||
expanded: false
|
expanded: false
|
||||||
items:
|
items:
|
||||||
|
|||||||
Reference in New Issue
Block a user