mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2026-02-22 14:52:30 +00:00
Compare commits
107 Commits
prettier
...
add-bitget
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9af8e7849e | ||
|
|
c62d5090d0 | ||
|
|
19ec38e7d8 | ||
|
|
f119214cea | ||
|
|
69d4113536 | ||
|
|
f5988554db | ||
|
|
eecdaccd55 | ||
|
|
260f8afd8b | ||
|
|
f1eab6f8ae | ||
|
|
934d7c3ff8 | ||
|
|
883a6a1d29 | ||
|
|
c5f38c1a07 | ||
|
|
6a11249b3d | ||
|
|
f2200e2a51 | ||
|
|
ff6e5932f6 | ||
|
|
776a4f290e | ||
|
|
821ada37ba | ||
|
|
8d83ddcf63 | ||
|
|
61e700ed2b | ||
|
|
1c35d320d9 | ||
|
|
63bf0b61ec | ||
|
|
0324ff52b6 | ||
|
|
fdb839295d | ||
|
|
22eaf502a5 | ||
|
|
104977125b | ||
|
|
8a1fb62712 | ||
|
|
c59e930061 | ||
|
|
2a088dfcba | ||
|
|
3d877de05a | ||
|
|
8e8e2fc676 | ||
|
|
ade482a349 | ||
|
|
d6c68d6a2d | ||
|
|
5d18b40746 | ||
|
|
a5f8580e0a | ||
|
|
794f588008 | ||
|
|
799a51f528 | ||
|
|
fef973d443 | ||
|
|
04c33adeb8 | ||
|
|
6611b82f5b | ||
|
|
1a5762b36f | ||
|
|
92b0d8b9d3 | ||
|
|
b3ff5bf1a4 | ||
|
|
695007d3db | ||
|
|
f9aebc83b9 | ||
|
|
fb94fed151 | ||
|
|
778c676664 | ||
|
|
2b6971a89d | ||
|
|
47fb4632bd | ||
|
|
e32c12a359 | ||
|
|
ab14511bb4 | ||
|
|
75f861cfed | ||
|
|
b60c72cdf3 | ||
|
|
f73ebc41bd | ||
|
|
ab7d6a09e9 | ||
|
|
1c6ade3aba | ||
|
|
d9d884543b | ||
|
|
6d2259e30a | ||
|
|
900a4f01ba | ||
|
|
94e4173441 | ||
|
|
9dffd66faf | ||
|
|
ec6bbff42f | ||
|
|
1a0310bf90 | ||
|
|
d2c2b91b0a | ||
|
|
baf0f4e819 | ||
|
|
db9dd303ae | ||
|
|
e181ee6e0f | ||
|
|
af79cb6cf2 | ||
|
|
98bea864bc | ||
|
|
804e51b6b1 | ||
|
|
3853484deb | ||
|
|
c9a560441f | ||
|
|
a789936ad2 | ||
|
|
ca245d72ee | ||
|
|
b0f04a34ed | ||
|
|
5455108464 | ||
|
|
2b1216012e | ||
|
|
f7f5a2e6cf | ||
|
|
8f853ffb0b | ||
|
|
ba7a756e39 | ||
|
|
ba4ac4c923 | ||
|
|
12b60d17e2 | ||
|
|
54ccc38d1a | ||
|
|
406741663c | ||
|
|
66652d1dab | ||
|
|
24ba1687f9 | ||
|
|
e4aa7010d9 | ||
|
|
4eeb2d2d49 | ||
|
|
e4cdb7ccea | ||
|
|
a5475869c5 | ||
|
|
053c4bb5a2 | ||
|
|
9ceb186fb4 | ||
|
|
18542eb915 | ||
|
|
d8655b4a0c | ||
|
|
3b276c6f19 | ||
|
|
898e698bec | ||
|
|
e5049e53f9 | ||
|
|
afd636e69d | ||
|
|
a5b914caee | ||
|
|
df7cd95784 | ||
|
|
5a9357553c | ||
|
|
21d27c36bb | ||
|
|
d153a017b2 | ||
|
|
20a873ae55 | ||
|
|
e54a5a4ea6 | ||
|
|
8f05a58f12 | ||
|
|
d8849f03f9 | ||
|
|
4b8b714e5b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,6 +8,7 @@ yarn-error.log
|
||||
*.iml
|
||||
.venv/
|
||||
_code-samples/*/js/package-lock.json
|
||||
_code-samples/*/js/*[Ss]etup.json
|
||||
|
||||
# PHP
|
||||
composer.lock
|
||||
|
||||
@@ -124,9 +124,9 @@ XRP Ledgerは、スパム対策として、需要に基づいて[トランザク
|
||||
|
||||
XRP Ledgerネットワークはオープンネットワークであり、すべての取引はオープンに公開されています。
|
||||
|
||||
Rippleは Ledgerネットワーク全体のAMLフラグを監視・報告し、該当する疑わしい活動をFinCENに報告することにコミットしています。
|
||||
Rippleは XRP Ledgerネットワーク全体のAMLフラグを監視・報告し、該当する疑わしい活動をFinCENに報告することにコミットしています。
|
||||
|
||||
[XRP Forensics / xrplorer](https://xrplorer.com/)は、XRP Ledgerのマネーロンダリング、詐欺、詐欺、不正使用を追跡し、最小限に抑えるための勧告リストを維持しています。取引所やその他のサービス・プロバイダは、金融犯罪を防止し対応するためにこのサービスを利用することができます。
|
||||
[XRP Forensics / xrplorer](https://xrplorer.com/)は、XRP Ledgerのマネーロンダリング、詐欺、不正使用を追跡し、最小限に抑えるための勧告リストを維持しています。取引所やその他のサービス・プロバイダは、金融犯罪を防止し対応するためにこのサービスを利用することができます。
|
||||
|
||||
|
||||
## セキュリティ上の懸念
|
||||
|
||||
@@ -26,14 +26,14 @@ labels:
|
||||
- `RippleState`
|
||||
- `Check`
|
||||
- アカウントがレジャー内に所有するオブジェクトが1000個未満であること。
|
||||
- トランザクションの送信時、少なくとも1つ分の[所有者準備金](reserves.md)(現在2XRP)に相当する特別な[トランザクションコスト][]を支払う必要があります。
|
||||
- トランザクションの送信時、少なくとも1つ分の[所有者準備金](reserves.md)(現在{% $env.PUBLIC_OWNER_RESERVE %})に相当する特別な[トランザクションコスト][]を支払う必要があります。
|
||||
|
||||
|
||||
## 削除コスト
|
||||
|
||||
{% admonition type="warning" name="注意" %}アカウントの削除要件を満たしていないためにトランザクションが失敗した場合でも、[AccountDeleteトランザクション][]のトランザクションコストは、トランザクションが検証済みレジャーに含まれる場合常に発生します。アカウントを削除できなかった場合に高いトランザクションコストを支払う可能性を減らすには、AccountDeleteトランザクションを送信するときに`fail_hard`オプションを使用してください。{% /admonition %}
|
||||
|
||||
ビットコインや他の多くの暗号通貨とは異なり、XRP Ledgerの公開レジャーチェーンのそれぞれの新しいレジャーバージョンは、レジャーの完全な状態を含んでおり、新しいアカウントが増えるごとにサイズが増加します。そのため、必要な場合を除き、新しいXRP Ledgerアカウントを作成すべきではありません。アカウントを削除することで、アカウントの10XRPの[準備金](reserves.md)の一部を回復することができますが、そのためには少なくとも2XRPを破棄する必要があります。
|
||||
ビットコインや他の多くの暗号通貨とは異なり、XRP Ledgerの公開レジャーチェーンのそれぞれの新しいレジャーバージョンは、レジャーの完全な状態を含んでおり、新しいアカウントが増えるごとにサイズが増加します。そのため、必要な場合を除き、新しいXRP Ledgerアカウントを作成すべきではありません。アカウントを削除することで、アカウントの{% $env.PUBLIC_BASE_RESERVE %}の[準備金](reserves.md)の一部を回復することができますが、そのためには少なくとも{% $env.PUBLIC_OWNER_RESERVE %}を破棄する必要があります。
|
||||
|
||||
取引所など、多くのユーザのために価値の送受信を行う組織は、[**送信元タグ**と**宛先タグ**](../transactions/source-and-destination-tags.md)を使用することで、XRP Ledgerのアカウントを1つだけ(または少数)使用するだけで、ユーザの支払いを区別することができます。
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ Deposit Authorizationが有効化されているアカウントの特徴は次
|
||||
|
||||
- [Paymentトランザクション][]の送信先には**できません**。ただし**以下の例外**は除きます。
|
||||
- 送金先により、支払の送金元が[事前承認](#事前承認)されている場合。{% amendment-disclaimer name="DepositPreauth" /%}
|
||||
- アカウントのXRP残高がアカウントの最低[必要準備金](reserves.md)以下で、XRP PaymentのAmountがアカウントの最低準備金(現時点では10XRP)以下である場合は、このアカウントを送金先に指定できます。これにより、アカウントがトランザクションを送信することも、XRPを受領することもできずに操作不可能な状態になるのを防ぎます。この場合、アカウントの所有者の準備金は関係ありません。
|
||||
- アカウントのXRP残高がアカウントの最低[必要準備金](reserves.md)以下で、XRP PaymentのAmountがアカウントの最低準備金(現時点では{% $env.PUBLIC_BASE_RESERVE %})以下である場合は、このアカウントを送金先に指定できます。これにより、アカウントがトランザクションを送信することも、XRPを受領することもできずに操作不可能な状態になるのを防ぎます。この場合、アカウントの所有者の準備金は関係ありません。
|
||||
- **以下に該当する場合にのみ**[PaymentChannelClaimトランザクション][]からXRPを受領できます。
|
||||
- PaymentChannelClaimトランザクションの送金元がPayment Channelの送金先である場合。
|
||||
- PaymentChannelClaimトランザクションの送金先がPaymentChannelClaimの送金元を[事前承認している](#事前承認)場合。{% amendment-disclaimer name="DepositPreauth" /%}
|
||||
|
||||
@@ -46,7 +46,7 @@ XRP Ledgerでアカウントを取得する一般的な方法は次のとおり
|
||||
|
||||
- 例えば、一般的な取引所でXRPを購入し、その取引所から、指定したアドレスにXRPを出金することができます。
|
||||
|
||||
{% admonition type="warning" name="注意" %}自身のXRP Ledgerアドレスで初めてXRPを受け取る場合は[アカウントの準備金](reserves.md)(現在は10XRP)を支払う必要があります。この金額のXRPは無期限に使用できなくなります。一方で、一般的な取引所では通常、顧客のXRPはすべて、共有されたいくつかのXRP Ledgerアカウントに保有されているため、顧客はその取引所で個々のアカウントの準備金を支払う必要はありません。引き出す前に、XRP Ledgerに直接アカウントを保有することが、金額に見合う価値があるかどうかを検討してください。{% /admonition %}
|
||||
{% admonition type="warning" name="注意" %}自身のXRP Ledgerアドレスで初めてXRPを受け取る場合は[アカウントの準備金](reserves.md)(現在は{% $env.PUBLIC_BASE_RESERVE %})を支払う必要があります。この金額のXRPは無期限に使用できなくなります。一方で、一般的な取引所では通常、顧客のXRPはすべて、共有されたいくつかのXRP Ledgerアカウントに保有されているため、顧客はその取引所で個々のアカウントの準備金を支払う必要はありません。引き出す前に、XRP Ledgerに直接アカウントを保有することが、金額に見合う価値があるかどうかを検討してください。{% /admonition %}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ XRP Ledgerのチケットは、取引をすぐに送信せずに、その取引
|
||||
|
||||
上記の例では、シーケンス番号105または作成した3つのチケットのいずれかを使用してトランザクションを送信できます。チケット103を使ってトランザクションを送信すると、それによってチケット103は元帳から削除されます。その後の次のトランザクションでは、シーケンス番号105、チケット102、またはチケット104を使用できます。
|
||||
|
||||
{% admonition type="warning" name="注意" %}チケットは1枚ごとに[所有者準備金](reserves.md#所有者準備金)としてカウントされますので、チケット1枚につき2XRPを確保する必要があります。 (このXRPは、チケットを使用した後に再び使用可能になります)一度に多くのチケットを作成すると、このコストはすぐに膨れ上がります。{% /admonition %}
|
||||
{% admonition type="warning" name="注意" %}チケットは1枚ごとに[所有者準備金](reserves.md#所有者準備金)としてカウントされますので、チケット1枚につき{% $env.PUBLIC_OWNER_RESERVE %}を確保する必要があります。 (このXRPは、チケットを使用した後に再び使用可能になります)一度に多くのチケットを作成すると、このコストはすぐに膨れ上がります。{% /admonition %}
|
||||
|
||||
シーケンス番号と同様に、トランザクションの送信は、そのトランザクションが[コンセンサス](../consensus-protocol/index.md)によって確認された場合にのみ、チケットを使用します。しかし、意図した通りにならなかった取引でも、[`tec`クラスの結果コード](../../references/protocol/transactions/transaction-results/tec-codes.md)を用いてコンセンサスで確認することができます。
|
||||
|
||||
@@ -51,7 +51,7 @@ XRP Ledgerのチケットは、取引をすぐに送信せずに、その取引
|
||||
- 各チケットは一度しか使用できません。同じチケットシーケンスを使用する複数の異なるトランザクション候補があることは可能ですが、コンセンサスで検証できるのはそのうちの1つだけです。
|
||||
- 各アカウントでは、一度に250枚以上のチケットをレジャーに登録することはできません。また、一度に250枚以上のチケットを作成することもできません。
|
||||
- チケットを使って別のチケットを作ることは _できます_。その場合、使用したチケットは、一度に所持できるチケットの合計数にはカウントされません。
|
||||
- 各チケットは[所有者準備金](reserves.md#所有者準備金)にカウントされるため、まだ使用していないチケット1枚につき2XRPを確保する必要があります。このXRPは、チケットを使用した後、再び使用することができます。
|
||||
- 各チケットは[所有者準備金](reserves.md#所有者準備金)にカウントされるため、まだ使用していないチケット1枚につき{% $env.PUBLIC_OWNER_RESERVE %}を確保する必要があります。このXRPは、チケットを使用した後、再び使用することができます。
|
||||
- 個々の元帳の中では、チケットを使用した取引は、同じ送信者からの他の取引の後に実行されます。1つのアカウントが同じ元帳のバージョンでTicketを使用する複数のトランザクションを持つ場合、それらのTicketは最も低いTicket Sequenceから最も高いTicket Sequenceの順に実行されます。 (詳細については、コンセンサスの[正規順序](../consensus-protocol/consensus-structure.md#xrp-ledgerプロトコル-コンセンサスと検証)に関するドキュメントをご覧ください)。
|
||||
- 個々の元帳の中では、チケットを使用した取引は、同じ送信者からの他の取引の後に実行されます。1つのアカウントが同じ元帳のバージョンでチケットを使用する複数のトランザクションを持つ場合、それらのチケットは最も低いチケット シーケンス番号から最も高いチケット シーケンス番号の順に実行されます。 (詳細については、コンセンサスの[正規順序](../consensus-protocol/consensus-structure.md#xrp-ledgerプロトコル-コンセンサスと検証)に関するドキュメントをご覧ください)。
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
html: consensus-protections.html
|
||||
parent: consensus.html
|
||||
seo:
|
||||
description: Learn how the XRP Ledger Consensus Protocol is protected against various problems and attacks that may occur in a decentralized financial system. #TODO: translate
|
||||
description: 分散型金融システムで発生する可能性のあるさまざまな問題や攻撃から、XRP Ledgerコンセンサスプロトコルがどのように保護されているかを学びます。
|
||||
labels:
|
||||
- ブロックチェーン
|
||||
---
|
||||
|
||||
@@ -12,11 +12,11 @@ NFTをミントし、保有し、販売するためには、XRPを準備金と
|
||||
|
||||
## 基本準備金
|
||||
|
||||
アカウントでは、基本準備金(現在10XRP)を用意する必要があります。基本準備金のXRPの金額は変更される可能性があります。[基本準備金と所有者準備金](../../accounts/reserves.md#基本準備金と所有者準備金)をご覧ください。
|
||||
アカウントでは、基本準備金(現在{% $env.PUBLIC_BASE_RESERVE %})を用意する必要があります。基本準備金のXRPの金額は変更される可能性があります。[基本準備金と所有者準備金](../../accounts/reserves.md#基本準備金と所有者準備金)をご覧ください。
|
||||
|
||||
## 所有者準備金
|
||||
|
||||
XRP Ledgerで所有する各オブジェクトには、現在2XRPの所有者準備金が必要とされています。これは、ユーザが不必要なデータで台帳にスパムをかけることを抑制し、不要になったデータを削除することを促すためのものです。所有者準備金の額は変更される可能性があります。[基本準備金と所有者準備金](../../accounts/reserves.md#基本準備金と所有者準備金)をご覧ください。
|
||||
XRP Ledgerで所有する各オブジェクトには、現在{% $env.PUBLIC_OWNER_RESERVE %}の所有者準備金が必要とされています。これは、ユーザが不必要なデータで台帳にスパムをかけることを抑制し、不要になったデータを削除することを促すためのものです。所有者準備金の額は変更される可能性があります。[基本準備金と所有者準備金](../../accounts/reserves.md#基本準備金と所有者準備金)をご覧ください。
|
||||
|
||||
NFTの場合、 _オブジェクト_ はそれぞれのNFTを指すのではなく、アカウントが所有する`NFTokenPage`オブジェクトを指します。`NFTokenPage`オブジェクトは最大32個のNFTを格納することができます。
|
||||
|
||||
@@ -38,7 +38,7 @@ NFTの保有枚数や保有ページ数によって、所有者準備金の総
|
||||
|
||||
## `NFTokenOffer`の準備金
|
||||
|
||||
各`NFTokenOffer`オブジェクトは、オファーを出すアカウントに対して準備金の1つの増加を必要とします。この記事の執筆時点では、準備金の増分は2XRPです。準備金は、オファーをキャンセルすることで取り戻すことができます。また、オファーが受け入れられると、XRP Ledgerからオファーが削除され、準備金は取り戻されます。
|
||||
各`NFTokenOffer`オブジェクトは、オファーを出すアカウントに対して準備金の1つの増加を必要とします。この記事の執筆時点では、準備金の増分は{% $env.PUBLIC_OWNER_RESERVE %}です。準備金は、オファーをキャンセルすることで取り戻すことができます。また、オファーが受け入れられると、XRP Ledgerからオファーが削除され、準備金は取り戻されます。
|
||||
|
||||
## Practical Considerations
|
||||
|
||||
@@ -55,7 +55,7 @@ NFTをミントし、保有し、売買のオファーをする場合、必要
|
||||
|
||||
{% admonition type="info" name="注記" %}準備金要件ではありませんが、ミントと売却のプロセスにおけるトランザクションの些細な手数料(通常12drops、または.000012XRP)を負担するために、少なくとも必要準備金より1XRPより多く用意しておきくべきです。{% /admonition %}
|
||||
|
||||
仮に200個のNFTをミントし、それぞれに「NFTokenSellOffer」を作成すると、436XRPもの準備金が必要になります。
|
||||
仮に200個のNFTをミントし、それぞれに「NFTokenSellOffer」を作成すると、43.6XRPもの準備金が必要になります。
|
||||
|
||||
| 準備金の種類 | 準備金の額 |
|
||||
|:--------------------|--------:|
|
||||
|
||||
@@ -72,7 +72,7 @@ labels:
|
||||
|
||||
### `NFTokenOffer`の準備金
|
||||
|
||||
各`NFTokenOffer`オブジェクトは、オファーを出すアカウントに1つ分の準備金の増額を要求します。執筆時点では、準備金の増分は2XRPです。この準備金は、オファーをキャンセルすることで取り戻すことができます。
|
||||
各`NFTokenOffer`オブジェクトは、オファーを出すアカウントに1つ分の準備金の増額を要求します。執筆時点では、準備金の増分は{% $env.PUBLIC_OWNER_RESERVE %}です。この準備金は、オファーをキャンセルすることで取り戻すことができます。
|
||||
|
||||
|
||||
### `NFTokenOfferID`のフォーマット
|
||||
|
||||
@@ -48,7 +48,7 @@ AMMを表す[AMMエントリ][]と[特殊なAccountRootエントリ](../../ledge
|
||||
|
||||
## 特殊なトランザクションコスト
|
||||
|
||||
各AMMインスタンスはAccountRootレジャーエントリ、AMMレジャーエントリ、プール内の各トークンのトラストラインを含むため、AMMCreateトランザクションは台帳スパムを抑止するために通常よりもはるかに高い[トランザクションコスト][]を必要とします。標準的な最低0.00001XRPの代わりに、AMMCreateは少なくとも所有者準備金の増分(現在は2XRP)を破棄しなければなりません。これは[AccountDeleteトランザクション][]と同じ特別なトランザクションコストです。
|
||||
各AMMインスタンスはAccountRootレジャーエントリ、AMMレジャーエントリ、プール内の各トークンのトラストラインを含むため、AMMCreateトランザクションは台帳スパムを抑止するために通常よりもはるかに高い[トランザクションコスト][]を必要とします。標準的な最低0.00001XRPの代わりに、AMMCreateは少なくとも所有者準備金の増分(現在は{% $env.PUBLIC_OWNER_RESERVE %})を破棄しなければなりません。これは[AccountDeleteトランザクション][]と同じ特別なトランザクションコストです。
|
||||
|
||||
## エラーケース
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ labels:
|
||||
|
||||
- トランザクションを送信するための十分なXRPが供給されていて、新しい署名者リストの[必要準備金](../../../concepts/accounts/reserves.md)を満たしている資金供給のあるXRP Ledger[アドレス](../../../concepts/accounts/index.md)が必要です。
|
||||
|
||||
- [MultiSignReserve Amendment][]が有効な場合、マルチシグを使用するには、使用する署名と署名者の数に関わらず、アカウントの準備金として2 XRPが必要です。(MultiSignReserve Amendmentは**2019年4月7日**以降、本番環境のXRP Ledgerで有効になっています。)
|
||||
- [MultiSignReserve Amendment][]が有効な場合、マルチシグを使用するには、使用する署名と署名者の数に関わらず、アカウントの準備金として{% $env.PUBLIC_OWNER_RESERVE %}が必要です。(MultiSignReserve Amendmentは**2019年4月7日**以降、本番環境のXRP Ledgerで有効になっています。)
|
||||
|
||||
- [MultiSignReserve Amendment][]が有効ではないテストネットワークでは、マルチシグを使用するには[アカウント準備金](../../../concepts/accounts/reserves.md)に通常よりも多くのXRPが必要となります。必要額は、リストの署名者の数に応じて増加します。
|
||||
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
---
|
||||
html: cancel-an-expired-escrow.html
|
||||
parent: use-escrows.html
|
||||
seo:
|
||||
description: 有効期限切れのEscrowを取り消します。
|
||||
labels:
|
||||
- Escrow
|
||||
- スマートコントラクト
|
||||
---
|
||||
# 有効期限切れEscrowの取消し
|
||||
|
||||
## 1.有効期限切れEscrowの確認
|
||||
|
||||
XRP LedgerのEscrowが有効期限切れとなるのは、その`CancelAfter`の時刻が検証済みレジャーの`close_time`よりも前である場合です。(Escrowに`CancelAfter`時刻が指定されていない場合は、Escrowが有効期限切れになることはありません。)最新の検証済みレジャーの閉鎖時刻は、[ledgerメソッド][]を使用して検索できます。
|
||||
|
||||
リクエスト:
|
||||
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="Websocket" %}
|
||||
{% code-snippet file="/_api-examples/escrow/websocket/ledger-request-expiration.json" language="json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
レスポンス:
|
||||
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="Websocket" %}
|
||||
{% code-snippet file="/_api-examples/escrow/websocket/ledger-response-expiration.json" language="json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
|
||||
[account_objectsメソッド][]を使用してEscrowを検索し、`CancelAfter`の時刻と比較できます。
|
||||
|
||||
リクエスト:
|
||||
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="Websocket" %}
|
||||
{% code-snippet file="/_api-examples/escrow/websocket/account_objects-request-expiration.json" language="json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
レスポンス:
|
||||
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="Websocket" %}
|
||||
{% code-snippet file="/_api-examples/escrow/websocket/account_objects-response-expiration.json" language="json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
## 2.EscrowCancelトランザクションの送信
|
||||
|
||||
XRP Ledgerでは、[EscrowCancelトランザクション][]に[署名して送信する](../../../../concepts/transactions/index.md#トランザクションへの署名とトランザクションの送信)ことで、***誰でも***有効期限切れのEscrowを取り消すことができます。トランザクションの`Owner`フィールドを、そのEscrowを作成した`EscrowCreate`トランザクションの`Account`に設定します。`OfferSequence`フィールドを、`EscrowCreate`トランザクションの`Sequence`に設定します。
|
||||
|
||||
{% partial file="/@l10n/ja/docs/_snippets/secret-key-warning.md" /%}
|
||||
|
||||
リクエスト:
|
||||
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="Websocket" %}
|
||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-request-escrowcancel.json" language="json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
レスポンス:
|
||||
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="Websocket" %}
|
||||
{% code-snippet file="/_api-examples/escrow/websocket/submit-response-escrowcancel.json" language="json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
トランザクションの識別用`hash`値をメモしておきます。これにより、検証済みレジャーバージョンに記録されるときにその最終ステータスを確認できます。
|
||||
|
||||
## 3.検証の待機
|
||||
|
||||
{% partial file="/@l10n/ja/docs/_snippets/wait-for-validation.md" /%}
|
||||
|
||||
## 4.最終結果の確認
|
||||
|
||||
EscrowCancelトランザクションの識別用ハッシュを指定した[txメソッド][]を使用してトランザクションの最終ステータスを確認します。トランザクションのメタデータで`LedgerEntryType`が`Escrow`である`DeletedNode`を探します。また、エスクローに預託された支払いの送金元の`ModifiedNode`(タイプが`AccountRoot`)も探します。オブジェクトの`FinalFields`に、`Balance`フィールドのXRP返金額の増分が表示されている必要があります。
|
||||
|
||||
リクエスト:
|
||||
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="Websocket" %}
|
||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-request-escrowcancel.json" language="json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
レスポンス:
|
||||
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="Websocket" %}
|
||||
{% code-snippet file="/_api-examples/escrow/websocket/tx-response-escrowcancel.json" language="json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
上記の例では、`r3wN3v2vTUkr5qd6daqDc2xE4LSysdVjkT`がEscrowの送金元であり、`Balance`が99999**8**9990 dropから99999**9**9990 dropに増加していることから、エスクローに預託されていた10,000 XRP dropが返金されたことがわかります(drop = 0.01XRP) 。
|
||||
|
||||
{% admonition type="success" name="ヒント" %}Escrowを実行する[EscrowFinishトランザクション][]で使用する`OfferSequence`が不明な場合は、Escrowの`PreviousTxnID`フィールドのトランザクションの識別用ハッシュを指定した[txメソッド][]を使用して、そのEscrowを作成したトランザクションを検索します。Escrowを終了するときには、そのトランザクションの`Sequence`の値を`OfferSequence`の値として使用します。{% /admonition %}
|
||||
|
||||
{% raw-partial file="/@l10n/ja/docs/_snippets/common-links.md" /%}
|
||||
@@ -1,80 +0,0 @@
|
||||
---
|
||||
html: look-up-escrows.html
|
||||
parent: use-escrows.html
|
||||
seo:
|
||||
description: 送金元または送金先のアドレスを使って保留中のEscrowを検索します。
|
||||
labels:
|
||||
- Escrow
|
||||
- スマートコントラクト
|
||||
---
|
||||
# Escrowの検索
|
||||
|
||||
保留中のEscrowはすべて[Escrowオブジェクト](../../../../concepts/payment-types/escrow.md)としてレジャーに保管されます。
|
||||
|
||||
Escrowオブジェクトを検索するには、[account_objectsメソッド][]で[送金元のアドレス](#送金元のアドレスによるescrowの検索)または[送金先のアドレス](#送金先のアドレスによるescrowの検索)を使用して検索します。
|
||||
|
||||
## 送金元のアドレスによるEscrowの検索
|
||||
|
||||
[account_objectsメソッド][]を使用して、送金元アドレスからEscrowオブジェクトを検索できます。
|
||||
|
||||
たとえば、送金元アドレスが`rfztBskAVszuS3s5Kq7zDS74QtHrw893fm`である保留中のEscrowオブジェクトをすべて検索するとします。以下のリクエストの例に従ってこの検索を実行できます。この例では送金元アドレスは`account`の値です。
|
||||
|
||||
リクエスト:
|
||||
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="Websocket" %}
|
||||
{% code-snippet file="/_api-examples/escrow/websocket/account_objects-request.json" language="json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
|
||||
レスポンスは以下の例のようになります。このレスポンスには、送金元アドレスまたは送金先アドレスが`rfztBskAVszuS3s5Kq7zDS74QtHrw893fm`である保留中のEscrowオブジェクトがすべて含まれています。送金元アドレスは`Account`の値であり、送金先アドレスは`Destination`の値です。
|
||||
|
||||
この例では、2番目と4番目のEscrowオブジェクトが検索条件に一致しています。これは、これらのオブジェクトの`Account`(送金元のアドレス)の値が`rfztBskAVszuS3s5Kq7zDS74QtHrw893fm`に設定されているためです。
|
||||
|
||||
レスポンス:
|
||||
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="Websocket" %}
|
||||
{% code-snippet file="/_api-examples/escrow/websocket/account_objects-response.json" language="json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
## 送金先のアドレスによるEscrowの検索
|
||||
|
||||
[account_objectsメソッド][]を使用して、送金先アドレスからEscrowオブジェクトを検索できます。
|
||||
|
||||
{% admonition type="info" name="注記" %}送金先のアドレスによる保留中のEscrowオブジェクトの検索は、[fix1523 Amendment][]が2017/11/14に有効化された後に作成されたEscrowについてのみ行うことができます。{% /admonition %}
|
||||
|
||||
たとえば、送金先アドレスが`rfztBskAVszuS3s5Kq7zDS74QtHrw893fm`である保留中のEscrowオブジェクトをすべて検索するとします。以下のリクエストの例に従ってこの検索を実行できます。この例では送金先アドレスは`account`の値です。
|
||||
|
||||
リクエスト:
|
||||
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="Websocket" %}
|
||||
{% code-snippet file="/_api-examples/escrow/websocket/account_objects-request.json" language="json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
|
||||
レスポンスは以下の例のようになります。レスポンスには送金先アドレスまたは送金元アドレスが`rfztBskAVszuS3s5Kq7zDS74QtHrw893fm`である保留中のEscrowオブジェクトがすべて含まれています。送金先アドレスは`Destination`の値であり、送金元アドレスは`Account`の値です。
|
||||
|
||||
この例では、1番目と3番目のEscrowオブジェクトが検索条件に一致しています。これは、これらのオブジェクトの`Destination`(送金先のアドレス)の値が`rfztBskAVszuS3s5Kq7zDS74QtHrw893fm`に設定されているためです。
|
||||
|
||||
レスポンス:
|
||||
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="Websocket" %}
|
||||
{% code-snippet file="/_api-examples/escrow/websocket/account_objects-response.json" language="json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{% raw-partial file="/@l10n/ja/docs/_snippets/common-links.md" /%}
|
||||
@@ -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" /%}
|
||||
@@ -26,7 +26,7 @@ XRP Ledgerの分散型取引所(DEX)には、「アルゴリズムトレード
|
||||
|
||||
裁定取引を行うには、XRP Ledgerの内部と関連する部分の両方で、多くの方法があります。以下の例は潜在的な戦略を説明するためのものですが、他の方法も可能です。
|
||||
|
||||
**循環支払い**を利用して、マルチアセットトレードを完了し利益を得ることができます。XRP Ledgerは、XRPが真ん中のアセットである3つのアセットセットセットと同様に、アセットペア間の重複した取引を自動的に接続します。しかし、XRP Ledgerのプロトコルは、他のより長い、あるいはより複雑な経路のトレードを自動的に見つけて競うことはしません。(可能な限り最善の経路を見つけることは、計算集約型な問題のカテゴリとして知られています。)したがって、XRP Ledgerが独自の経路を見つける場合、XRP Ledgerのプロトコルは自動的に他の、より長い、あるいはより複雑な経路の取引を見つけ、競争させることはありません。したがって、自分で経路探索(PathFinding)を行えば、このような有益な裁定取引の機会を見つけることが可能です。その場合は、[Paymentトランザクション](../../references/protocol/transactions/types/payment.md)でそれらの[経路(Paths)](../../concepts/tokens/fungible-tokens/paths.md)を明示的に指定できます。1つのFOOを使って2つのBARを買い、その2つのBARを使って3つのTSTを買い、最後に3つのTSTを使って1.1 FOOを買えば、0.1 FOOから取引に関わるトークンの[送金手数料](../../concepts/tokens/fungible-tokens/transfer-fees.md)などのコストを差し引いた利益を得ることができます。
|
||||
**循環支払い**を利用して、マルチアセットトレードを完了し利益を得ることができます。XRP Ledgerは、XRPが真ん中のアセットである3つのアセットセットと同様に、アセットペア間の重複した取引を自動的に接続します。しかし、XRP Ledgerのプロトコルは、他のより長い、あるいはより複雑な経路のトレードを自動的に見つけて競うことはしません。(可能な限り最善の経路を見つけることは、計算集約型な問題のカテゴリとして知られています。)したがって、自分で経路探索(PathFinding)を行えば、このような有益な裁定取引の機会を見つけることが可能です。その場合は、[Paymentトランザクション](../../references/protocol/transactions/types/payment.md)でそれらの[経路(Paths)](../../concepts/tokens/fungible-tokens/paths.md)を明示的に指定できます。1つのFOOを使って2つのBARを買い、その2つのBARを使って3つのTSTを買い、最後に3つのTSTを使って1.1 FOOを買えば、0.1 FOOから取引に関わるトークンの[送金手数料](../../concepts/tokens/fungible-tokens/transfer-fees.md)などのコストを差し引いた利益を得ることができます。
|
||||
|
||||
資産の価格が異なる複数の取引所(CEX)に口座を持っている場合、**取引所間の裁定取引**を行うことができます。例えば、ACME取引所でXRPを1XRPあたり0.45ドルで購入し、そのXRPをWayGate取引所に移動して1XRPあたり0.50ドルで売却した場合、XRPあたり0.05ドルの利益を得ることができます。より複雑な例として、ACME取引所でBTC:ETHの価格が変動し、BTCに対してETHが安くなった場合、ある取引所でETH→XRPを売却し、そのXRPをACME取引所に移動し、XRP→BTC→ETHを取引して利益を得ることで、この価格変動を利用できる可能性があります。XRP Ledgerの取引は数秒で決済されますが、イーサリアムの取引は数分、ビットコインの取引は数時間かかることがあるため、XRPをブリッジ通貨として使用することで、ACME取引所でETH→BTC→BTC→ETHと取引するよりも早くこの機会を利用できる可能性があります。(これはもちろん、XRPへの交換が利益以上のコストにならないだけの十分な流動性と狭いスプレッドがある場合にのみ機能します)
|
||||
|
||||
@@ -48,7 +48,7 @@ XRP Ledgerの分散型取引所(DEX)には、「アルゴリズムトレード
|
||||
|
||||
## テストとよくある間違い
|
||||
|
||||
どのような取引でもそうですが、アルゴリズムトレー ドは確実に儲かる方法ではありません。手作業によるトレードと比べると、アルゴリズムトレードはエラーの余地が非常に少なくなります。小さなミスを犯しても、そのミスを大量のトレードで倍増させようとすれば、問題を修正する前に損失があっという間に膨らんでしまいます。したがって、自分のトレード戦略が実際に利益を上げるかどうかを確認するために、さまざまなテストを行うのが賢明です。戦略やその実際の実装(よく _ボット_ と呼ばれます)をテストするために、次のようなことを行うことができます。
|
||||
どのような取引でもそうですが、アルゴリズムトレードは確実に儲かる方法ではありません。手作業によるトレードと比べると、アルゴリズムトレードはエラーの余地が非常に少なくなります。小さなミスを犯しても、そのミスを大量のトレードで倍増させようとすれば、問題を修正する前に損失があっという間に膨らんでしまいます。したがって、自分のトレード戦略が実際に利益を上げるかどうかを確認するために、さまざまなテストを行うのが賢明です。戦略やその実際の実装(よく _ボット_ と呼ばれます)をテストするために、次のようなことを行うことができます。
|
||||
|
||||
- 現在のレジャーの状態または過去のトレードに基づいて、潜在的な利益を手動で計算します。
|
||||
- 過去のデータを記録してボットに送り、ボットがどのようなアクションを取ったかを記録し、実際の過去の値動きと結果を比較します。
|
||||
@@ -61,7 +61,7 @@ XRP Ledgerの分散型取引所(DEX)には、「アルゴリズムトレード
|
||||
- 通常、四捨五入の違いや、計算時と約定時の値動きの違いを考慮し、金額を調整する必要があります。この金額は「スリッページ」と呼ばれ、適切な金額を設定することが重要です。スリッページが低すぎると、トレードがまったく約定しない可能性があります。一方、スリッページが高すぎると、フロントランニングの影響を受けやすくなり、スリッページが高ければ高いほど、値動きによって利益が削られる可能性が高くなります。
|
||||
- **余分なコストと遅延を考慮しないこと**: 例えば、2つのステーブルコインの裏付けが米ドルであるにもかかわらず、ある発行者が0.5%の送金手数料を請求し、別の発行者が0.25%の[送金手数料](../../concepts/tokens/fungible-tokens/transfer-fees.md)を請求した場合、そのステーブルコインの取引価格には約0.25%の差が生じます。トランザクションを送信するためのコストは、通常は少額ですが、その他の潜在的な遅延の影響も忘れないでください。例えば、オフレジャーの取引所が現時点で有利な価格を示していたとしても、その取引所の入金処理に数時間から数日かかる場合、その取引所で事前に流動性を持っていない限り、その価格を利用することはできません。
|
||||
- **稀な事象を考慮していないこと**: 前例のない出来事(「ブラック・スワン」)はさておき、個々の異常値によって計算結果がゆがむことがあります。一例として(これは実話ですが)、あるトレーダーが、ある戦略の潜在的な利益を特定の時間帯で計算したところ、利益の80%以上が、他のユーザが誤って価格にゼロを追加してしまった1つの「入力ミス」の取引によるものであったと報じました。同じ戦略を、これらの異常値の取引を含まない時間範囲に対して計算すると、利益ははるかに少なくなりました。
|
||||
- **トランザクションのフラグを確認しないこ**と: XRP Ledgerのトランザクションのフラグは、そのトランザクションの処理方法や、プロトコルがそれを「成功」とマークするタイミングに大きな影響を与える可能性があります。例えば、"Offer"トランザクションのフラグは、全額がすぐに得られる場合にのみトレードされる"Fill or Kill"注文にすることができます。"Payment"トランザクションのフラグは、意図した宛先に全額を届けることができなくても成功する[partial payments](../../concepts/payment-types/partial-payments.md)にすることができます。トランザクションの`Flags`フィールドを解析するためにビット演算をする必要がありますが、それをスキップしてしまうと、予想と結果が全く異なったものとなってしまう可能性があります。
|
||||
- **トランザクションのフラグを確認しないこと**: XRP Ledgerのトランザクションのフラグは、そのトランザクションの処理方法や、プロトコルがそれを「成功」とマークするタイミングに大きな影響を与える可能性があります。例えば、"Offer"トランザクションのフラグは、全額がすぐに得られる場合にのみトレードされる"Fill or Kill"注文にすることができます。"Payment"トランザクションのフラグは、意図した宛先に全額を届けることができなくても成功する[partial payments](../../concepts/payment-types/partial-payments.md)にすることができます。トランザクションの`Flags`フィールドを解析するためにビット演算をする必要がありますが、それをスキップしてしまうと、予想と結果が全く異なったものとなってしまう可能性があります。
|
||||
|
||||
## 税金とライセンス
|
||||
|
||||
@@ -72,7 +72,7 @@ XRP Ledgerの分散型取引所(DEX)には、「アルゴリズムトレード
|
||||
|
||||
### トレードの発注
|
||||
|
||||
XRP Ledgerの分散型取引所で _代替可能_ トークンとXRPを売買するには、通常[OfferCreateトランザクション](../../references/protocol/transactions/types/offercreate.md)を送信します。この方法でトレードを行うためのコードと技術的ステップの詳細なウォークスルーについては、[分散型取引所でのトレード](../../tutorials/how-tos/use-tokens/trade-in-the-decentralized-exchange.md)をご覧ください。[Paymentトランザクション](../../references/protocol/transactions/types/payment.md)を使用して通貨を両替することも可能です。[クロスカレンしー支払い](../../concepts/payment-types/cross-currency-payments.md)を他のユーザに送ったり、長い[パス](../../concepts/tokens/fungible-tokens/paths.md)を使って裁定取引の機会を1つの操作にまとめることで、自分自身に送り返すこともできます。
|
||||
XRP Ledgerの分散型取引所で _代替可能_ トークンとXRPを売買するには、通常[OfferCreateトランザクション](../../references/protocol/transactions/types/offercreate.md)を送信します。この方法でトレードを行うためのコードと技術的ステップの詳細なウォークスルーについては、[分散型取引所でのトレード](../../tutorials/how-tos/use-tokens/trade-in-the-decentralized-exchange.md)をご覧ください。[Paymentトランザクション](../../references/protocol/transactions/types/payment.md)を使用して通貨を両替することも可能です。[クロスカレンシー支払い](../../concepts/payment-types/cross-currency-payments.md)を他のユーザに送ったり、長い[パス](../../concepts/tokens/fungible-tokens/paths.md)を使って裁定取引の機会を1つの操作にまとめることで、自分自身に送り返すこともできます。
|
||||
|
||||
NFTをトレードするためのコードと技術的な手順については、[JavaScriptを使用したNFTokenの送信](../../tutorials/javascript/nfts/transfer-nfts.md)をご覧ください。
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ XRP Ledger上のスマートコントラクトは、条件付きで保有する
|
||||
|
||||
オラクルのプログラムが条件を満たしたことを検知した後、エスクローの受取人に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)をご覧ください。
|
||||
|
||||
## 例
|
||||
|
||||
|
||||
@@ -48,9 +48,9 @@ NFTをオークション形式で販売することができます。[NFTオー
|
||||
|
||||
### 準備金要件
|
||||
|
||||
販売用のNFTをミントする際には、XRPの準備金が必要となります。各NFTokenページには、2XRPの準備金が必要です。NFTokenページは16~32個のNFTを保管することができます。
|
||||
販売用のNFTをミントする際には、XRPの準備金が必要となります。各NFTokenページには、{% $env.PUBLIC_OWNER_RESERVE %}の準備金が必要です。NFTokenページは16~32個のNFTを保管することができます。
|
||||
|
||||
各`NFTokenOffer`オブジェクトは、2XRPの準備金が必要です。
|
||||
各`NFTokenOffer`オブジェクトは、{% $env.PUBLIC_OWNER_RESERVE %}の準備金が必要です。
|
||||
|
||||
`NFTokenOffer`を作成したり、NFTを売却したりする際には、些細な送金手数料(およそ6000ドロップ、または0.006 XRP)が発生します。大量に販売する場合、こうした少額の手数料はすぐにかさみますので、ビジネスのコストとして考慮する必要があります。
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ NFTokenのURLは、NFTのコンテンツが保存されている場所へのリ
|
||||
|
||||
[認可Minter](../../concepts/tokens/nfts/authorizing-another-minter.md)をご覧ください。
|
||||
|
||||
ミント済みのNFTは、`NFTokenPage`に記録されます。アカウント上の`NFTokenPage`1つにつき2XRPの準備金が必要です。[NFT準備金](../../concepts/tokens/nfts/reserve-requirements.md)をご覧ください。
|
||||
ミント済みのNFTは、`NFTokenPage`に記録されます。アカウント上の`NFTokenPage`1つにつき{% $env.PUBLIC_OWNER_RESERVE %}の準備金が必要です。[NFT準備金](../../concepts/tokens/nfts/reserve-requirements.md)をご覧ください。
|
||||
|
||||
各「NFTokenPage」は16~32個のNFTを保持します。大量のNFTをミントすると、あなたのXRPを大量に準備金としてロックすることになります。オンデマンドミント(または _遅延ミント_ )を行うことで、XRPを柔軟に維持することができます。[遅延ミント](../../concepts/tokens/nfts/batch-minting.md#mint-on-demand-lazy-minting)と[スクリプトミント](../../concepts/tokens/nfts/batch-minting.md#scripted-minting)をご覧下さい。
|
||||
|
||||
@@ -89,9 +89,9 @@ NFTをオークション形式で販売することができます。[NFTオー
|
||||
|
||||
#### 準備金要件
|
||||
|
||||
販売用のNFTをミントする際には、XRPの準備金が必要となります。各NFTokenページには、2XRPの準備金が必要です。NFTokenページは16~32個のNFTを保管することができます。
|
||||
販売用のNFTをミントする際には、XRPの準備金が必要となります。各NFTokenページには、{% $env.PUBLIC_OWNER_RESERVE %}の準備金が必要です。NFTokenページは16~32個のNFTを保管することができます。
|
||||
|
||||
各`NFTokenOffer`オブジェクトは、2XRPの準備金が必要です。
|
||||
各`NFTokenOffer`オブジェクトは、{% $env.PUBLIC_OWNER_RESERVE %}の準備金が必要です。
|
||||
|
||||
`NFTokenOffer`を作成したり、NFTを売却したりする際には、些細な送金手数料(およそ6000ドロップ、または0.006 XRP)が発生します。大量に販売する場合、こうした少額の手数料はすぐにかさみますので、ビジネスのコストとして考慮する必要があります。
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@ NFTをオークション形式で販売することができます。[NFTオー
|
||||
|
||||
### 準備金要件
|
||||
|
||||
販売用のNFTをミントする際には、XRPの準備金が必要となります。各NFTokenページには、2XRPの準備金が必要です。NFTokenページは16~32個のNFTを保管することができます。
|
||||
販売用のNFTをミントする際には、XRPの準備金が必要となります。各NFTokenページには、{% $env.PUBLIC_OWNER_RESERVE %}の準備金が必要です。NFTokenページは16~32個のNFTを保管することができます。
|
||||
|
||||
各`NFTokenOffer`オブジェクトは、2XRPの準備金が必要です。
|
||||
各`NFTokenOffer`オブジェクトは、{% $env.PUBLIC_OWNER_RESERVE %}の準備金が必要です。
|
||||
|
||||
`NFTokenOffer`を作成したり、NFTを売却したりする際には、些細な送金手数料(およそ6000ドロップ、または0.006 XRP)が発生します。大量に販売する場合、こうした少額の手数料はすぐにかさみますので、ビジネスのコストとして考慮する必要があります。
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ metadata:
|
||||
---
|
||||
# リソース
|
||||
|
||||
XRP Ledgerの理解や開発ためのリソース。Other resources to help understand the XRPL and develop on it.
|
||||
XRP Ledgerの理解や開発ためのリソース。
|
||||
|
||||
|
||||
{% child-pages /%}
|
||||
|
||||
@@ -155,6 +155,8 @@ amendment.table.status: ステータス
|
||||
amendment.status.enabled: 有効
|
||||
amendment.status.eta: 予定
|
||||
amendment.status.openForVoting: 投票中
|
||||
amendment.status.inactive: 無効
|
||||
amendment.status.inactiveButton: 詳細を取得する
|
||||
|
||||
# index.page.tsx
|
||||
home.hero.h1part1: ビジネスのための
|
||||
|
||||
@@ -23,6 +23,7 @@ type AmendmentsCachePayload = {
|
||||
|
||||
// API data caching
|
||||
const amendmentsEndpoint = 'https://vhs.prod.ripplex.io/v1/network/amendments/vote/main/'
|
||||
const amendmentsInfoEndpoint = 'https://vhs.prod.ripplex.io/v1/network/amendments/info/main/'
|
||||
const amendmentsCacheKey = 'xrpl.amendments.mainnet.cache'
|
||||
const amendmentsTTL = 15 * 60 * 1000 // 15 minutes in milliseconds
|
||||
|
||||
@@ -180,6 +181,8 @@ function AmendmentBadge(props: { amendment: Amendment }) {
|
||||
const enabledLabel = translate("amendment.status.enabled", "Enabled")
|
||||
const votingLabel = translate("amendment.status.openForVoting", "Open for Voting")
|
||||
const etaLabel = translate("amendment.status.eta", "Expected")
|
||||
const inactiveLabel = translate("amendment.status.inactive", "Inactive")
|
||||
const inactiveButton = translate("amendment.status.inactiveButton", "Get details")
|
||||
|
||||
React.useEffect(() => {
|
||||
const amendment = props.amendment
|
||||
@@ -202,10 +205,16 @@ function AmendmentBadge(props: { amendment: Amendment }) {
|
||||
else if (amendment.consensus) {
|
||||
setStatus(`${votingLabel}: ${amendment.consensus}`)
|
||||
setColor('80d0e0')
|
||||
setHref(undefined) // No link for voting amendments
|
||||
setHref(undefined)
|
||||
}
|
||||
}, [props.amendment, enabledLabel, etaLabel, votingLabel])
|
||||
|
||||
// Fallback: amendment is inactive
|
||||
else {
|
||||
setStatus(`${inactiveLabel}: ${inactiveButton}`)
|
||||
setColor('lightgrey')
|
||||
setHref(`/resources/known-amendments#${amendment.name.toLowerCase()}`)
|
||||
}
|
||||
}, [props.amendment, enabledLabel, etaLabel, votingLabel, inactiveLabel])
|
||||
|
||||
// Split the status at the colon to create two-color badge
|
||||
const parts = status.split(':')
|
||||
const label = shieldsIoEscape(parts[0])
|
||||
@@ -257,15 +266,32 @@ export function AmendmentDisclaimer(props: {
|
||||
const response = await fetch(amendmentsEndpoint)
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`)
|
||||
throw new Error(`HTTP error! Status: ${response.status}`)
|
||||
}
|
||||
|
||||
const data: AmendmentsResponse = await response.json()
|
||||
writeAmendmentsCache(data.amendments)
|
||||
|
||||
const found = data.amendments.find(a => a.name === props.name)
|
||||
|
||||
// 3. If not found in live data, try the info endpoint.
|
||||
if (!found) {
|
||||
throw new Error(`Couldn't find ${props.name} amendment in status table.`)
|
||||
|
||||
const infoResponse = await fetch(amendmentsInfoEndpoint)
|
||||
|
||||
if (!infoResponse.ok) {
|
||||
throw new Error(`HTTP error from info endpoint! Status: ${infoResponse.status}`)
|
||||
}
|
||||
|
||||
const infoData: AmendmentsResponse = await infoResponse.json()
|
||||
const foundInInfo = infoData.amendments.find(a => a.name === props.name)
|
||||
|
||||
if (!foundInInfo) {
|
||||
throw new Error(`Couldn't find ${props.name} amendment in status tables.`)
|
||||
}
|
||||
|
||||
setStatus(foundInInfo)
|
||||
return
|
||||
}
|
||||
|
||||
setStatus(found)
|
||||
@@ -389,6 +415,8 @@ export function Badge(props: {
|
||||
"更新": "blue", // ja: updated in
|
||||
"in development": "lightgrey",
|
||||
"開発中": "lightgrey", // ja: in development
|
||||
"inactive": "lightgrey",
|
||||
"無効": "lightgrey" // ja: inactive
|
||||
}
|
||||
|
||||
let childstrings = ""
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"id": 2,
|
||||
"command": "account_objects",
|
||||
"account": "r3wN3v2vTUkr5qd6daqDc2xE4LSysdVjkT",
|
||||
"ledger_index": "validated",
|
||||
"type": "escrow"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"id": 5,
|
||||
"command": "account_objects",
|
||||
"account": "rfztBskAVszuS3s5Kq7zDS74QtHrw893fm",
|
||||
"ledger_index": "validated",
|
||||
"type": "escrow"
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"id": 2,
|
||||
"status": "success",
|
||||
"type": "response",
|
||||
"result": {
|
||||
"account": "r3wN3v2vTUkr5qd6daqDc2xE4LSysdVjkT",
|
||||
"account_objects": [
|
||||
{
|
||||
"Account": "r3wN3v2vTUkr5qd6daqDc2xE4LSysdVjkT",
|
||||
"Amount": "10000",
|
||||
"CancelAfter": 559913895,
|
||||
"Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"FinishAfter": 559892324,
|
||||
"Flags": 0,
|
||||
"LedgerEntryType": "Escrow",
|
||||
"OwnerNode": "0000000000000000",
|
||||
"PreviousTxnID": "4756C22BBB7FC23D9081FDB180806939D6FEBC967BE0EC2DB95B166AF9C086E9",
|
||||
"PreviousTxnLgrSeq": 2764813,
|
||||
"index": "7243A9750FA4BE3E63F75F6DACFD79AD6B6C76947F6BDC46CD0F52DBEEF64C89"
|
||||
}
|
||||
],
|
||||
"ledger_hash": "82F24FFA72AED16F467BBE79D387E92FDA39F29038B26E79464CDEDFB506E366",
|
||||
"ledger_index": 2764826,
|
||||
"validated": true
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
{
|
||||
"id": 5,
|
||||
"result": {
|
||||
"account": "rfztBskAVszuS3s5Kq7zDS74QtHrw893fm",
|
||||
"account_objects": [{
|
||||
"Account": "rafD3taonqdnVpaxCCT6sjnScZUeFGf1JG",
|
||||
"Amount": "250",
|
||||
"Destination": "rfztBskAVszuS3s5Kq7zDS74QtHrw893fm",
|
||||
"DestinationNode": "0000000000000000",
|
||||
"FinishAfter": 570672000,
|
||||
"Flags": 0,
|
||||
"LedgerEntryType": "Escrow",
|
||||
"OwnerNode": "0000000000000000",
|
||||
"PreviousTxnID": "A0951691DF3BCBEEB3108F2229A702D078BBBF848268BC601E59B68A2E390AAC",
|
||||
"PreviousTxnLgrSeq": 4602906,
|
||||
"index": "2BF3226ACCA8FF7ACB7201F20A701F51D8666A2FA2FBFBE6A05C9161F9228A18"
|
||||
}, {
|
||||
"Account": "rfztBskAVszuS3s5Kq7zDS74QtHrw893fm",
|
||||
"Amount": "250",
|
||||
"Destination": "r9gyNNzhMtfwZara61u3ycfMLdkTpKJZHX",
|
||||
"DestinationNode": "0000000000000000",
|
||||
"FinishAfter": 570672000,
|
||||
"Flags": 0,
|
||||
"LedgerEntryType": "Escrow",
|
||||
"OwnerNode": "0000000000000000",
|
||||
"PreviousTxnID": "463D5A3CF09F4890B8471027F80414B3B438E6907425B71DC324D7118E90A107",
|
||||
"PreviousTxnLgrSeq": 4603003,
|
||||
"index": "35462CDC28AD830B29D101E8307AF5B6BFBC262F1BDCCA7EB45D1CA3F8B44F53"
|
||||
}, {
|
||||
"Account": "r9gyNNzhMtfwZara61u3ycfMLdkTpKJZHX",
|
||||
"Amount": "250",
|
||||
"Destination": "rfztBskAVszuS3s5Kq7zDS74QtHrw893fm",
|
||||
"DestinationNode": "0000000000000000",
|
||||
"FinishAfter": 570672000,
|
||||
"Flags": 0,
|
||||
"LedgerEntryType": "Escrow",
|
||||
"OwnerNode": "0000000000000000",
|
||||
"PreviousTxnID": "08C9B20AC9EB191238038A108CC4CBBC0243672484B466FB42DED0A7DF6A31A1",
|
||||
"PreviousTxnLgrSeq": 4602954,
|
||||
"index": "A7B0983A1B53D92278E21499064A4F8BBE08CB8D14DB6BBBA8F688AB1D3FDA45"
|
||||
}, {
|
||||
"Account": "rfztBskAVszuS3s5Kq7zDS74QtHrw893fm",
|
||||
"Amount": "250",
|
||||
"Destination": "rafD3taonqdnVpaxCCT6sjnScZUeFGf1JG",
|
||||
"DestinationNode": "0000000000000000",
|
||||
"FinishAfter": 570672000,
|
||||
"Flags": 0,
|
||||
"LedgerEntryType": "Escrow",
|
||||
"OwnerNode": "0000000000000000",
|
||||
"PreviousTxnID": "F4778F528AB3CB945BDB88036EF9FE6C0E899F1629D9E51129E3B93CD488395A",
|
||||
"PreviousTxnLgrSeq": 4602977,
|
||||
"index": "F99A4DDADDDF623908C9A048170AB107AFF78684AB8F3110E9F00BBBC606ABD2"
|
||||
}],
|
||||
"ledger_hash": "1D4850035F175CA6F1CD5CE3B53C01AA83E4F086C13085E4FBC1EEFCCB345A9B",
|
||||
"ledger_index": 4603176,
|
||||
"validated": true
|
||||
},
|
||||
"status": "success",
|
||||
"type": "response"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"id": 4,
|
||||
"command": "ledger",
|
||||
"ledger_index": "validated"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"id": 4,
|
||||
"command": "ledger",
|
||||
"ledger_index": "validated"
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"id": 1,
|
||||
"status": "success",
|
||||
"type": "response",
|
||||
"result": {
|
||||
"ledger": {
|
||||
# ... (trimmed) ...
|
||||
|
||||
"close_time": 560302643,
|
||||
"close_time_human": "2017-Oct-02 23:37:23",
|
||||
"close_time_resolution": 10,
|
||||
|
||||
# ... (trimmed) ...
|
||||
},
|
||||
"ledger_hash": "668F0647A6F3CC277496245DBBE9BD2E3B8E70E7AA824E97EF3237FE7E1EE3F2",
|
||||
"ledger_index": 2906341,
|
||||
"validated": true
|
||||
}
|
||||
}
|
||||
@@ -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,11 +0,0 @@
|
||||
{
|
||||
"id": 5,
|
||||
"command": "submit",
|
||||
"secret": "s████████████████████████████",
|
||||
"tx_json": {
|
||||
"Account": "rhgdnc82FwHFUKXp9ZcpgwXWRAxKf5Buqp",
|
||||
"TransactionType": "EscrowCancel",
|
||||
"Owner": "r3wN3v2vTUkr5qd6daqDc2xE4LSysdVjkT",
|
||||
"OfferSequence": 1
|
||||
}
|
||||
}
|
||||
@@ -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,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": "1200042280000000240000000320190000000168400000000000000A7321027FB1CF34395F18901CD294F77752EEE25277C6E87A224FC7388AA7EF872DB43D74473045022100AC45749FC4291F7811B2D8AC01CA04FEE38910CB7216FB0C5C0AEBC9C0A95F4302203F213C71C00136A0ADC670EFE350874BCB2E559AC02059CEEDFB846685948F2B81142866B7B47574C8A70D5E71FFB95FFDB18951427B82144E87970CD3EA984CF48B1AA6AB6C77DC4AB059FC",
|
||||
"tx_json": {
|
||||
"Account": "rhgdnc82FwHFUKXp9ZcpgwXWRAxKf5Buqp",
|
||||
"Fee": "10",
|
||||
"Flags": 2147483648,
|
||||
"OfferSequence": 1,
|
||||
"Owner": "r3wN3v2vTUkr5qd6daqDc2xE4LSysdVjkT",
|
||||
"Sequence": 3,
|
||||
"SigningPubKey": "027FB1CF34395F18901CD294F77752EEE25277C6E87A224FC7388AA7EF872DB43D",
|
||||
"TransactionType": "EscrowCancel",
|
||||
"TxnSignature": "3045022100AC45749FC4291F7811B2D8AC01CA04FEE38910CB7216FB0C5C0AEBC9C0A95F4302203F213C71C00136A0ADC670EFE350874BCB2E559AC02059CEEDFB846685948F2B",
|
||||
"hash": "65F36C5514153D94F0ADE5CE747061A5E70B73B56B4C66DA5040D99CAF252831"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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": 6,
|
||||
"command": "tx",
|
||||
"transaction": "65F36C5514153D94F0ADE5CE747061A5E70B73B56B4C66DA5040D99CAF252831"
|
||||
}
|
||||
@@ -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,101 +0,0 @@
|
||||
{
|
||||
"id": 6,
|
||||
"status": "success",
|
||||
"type": "response",
|
||||
"result": {
|
||||
"Account": "rhgdnc82FwHFUKXp9ZcpgwXWRAxKf5Buqp",
|
||||
"Fee": "10",
|
||||
"Flags": 2147483648,
|
||||
"OfferSequence": 1,
|
||||
"Owner": "r3wN3v2vTUkr5qd6daqDc2xE4LSysdVjkT",
|
||||
"Sequence": 3,
|
||||
"SigningPubKey": "027FB1CF34395F18901CD294F77752EEE25277C6E87A224FC7388AA7EF872DB43D",
|
||||
"TransactionType": "EscrowCancel",
|
||||
"TxnSignature": "3045022100AC45749FC4291F7811B2D8AC01CA04FEE38910CB7216FB0C5C0AEBC9C0A95F4302203F213C71C00136A0ADC670EFE350874BCB2E559AC02059CEEDFB846685948F2B",
|
||||
"date": 560302841,
|
||||
"hash": "65F36C5514153D94F0ADE5CE747061A5E70B73B56B4C66DA5040D99CAF252831",
|
||||
"inLedger": 2906406,
|
||||
"ledger_index": 2906406,
|
||||
"meta": {
|
||||
"AffectedNodes": [
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"LedgerIndex": "13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8",
|
||||
"PreviousTxnID": "4756C22BBB7FC23D9081FDB180806939D6FEBC967BE0EC2DB95B166AF9C086E9",
|
||||
"PreviousTxnLgrSeq": 2764813
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rhgdnc82FwHFUKXp9ZcpgwXWRAxKf5Buqp",
|
||||
"Balance": "9999999970",
|
||||
"Flags": 0,
|
||||
"OwnerCount": 0,
|
||||
"Sequence": 4
|
||||
},
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"LedgerIndex": "3430FA3A160FA8F9842FA4A8B5549ECDCB3783E585D0F9796A1736DEAE35F6FE",
|
||||
"PreviousFields": {
|
||||
"Balance": "9999999980",
|
||||
"Sequence": 3
|
||||
},
|
||||
"PreviousTxnID": "DA6F5CA8CE13A03B8BC58515E085F2FEF90B3C08230B5AEC8DE4FAF39F79010B",
|
||||
"PreviousTxnLgrSeq": 2906391
|
||||
}
|
||||
},
|
||||
{
|
||||
"DeletedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "r3wN3v2vTUkr5qd6daqDc2xE4LSysdVjkT",
|
||||
"Amount": "10000",
|
||||
"CancelAfter": 559913895,
|
||||
"Destination": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"FinishAfter": 559892324,
|
||||
"Flags": 0,
|
||||
"OwnerNode": "0000000000000000",
|
||||
"PreviousTxnID": "4756C22BBB7FC23D9081FDB180806939D6FEBC967BE0EC2DB95B166AF9C086E9",
|
||||
"PreviousTxnLgrSeq": 2764813
|
||||
},
|
||||
"LedgerEntryType": "Escrow",
|
||||
"LedgerIndex": "7243A9750FA4BE3E63F75F6DACFD79AD6B6C76947F6BDC46CD0F52DBEEF64C89"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Flags": 0,
|
||||
"Owner": "r3wN3v2vTUkr5qd6daqDc2xE4LSysdVjkT",
|
||||
"RootIndex": "DACDBEBD31D14EAC4207A45DB88734AD14D26D908507F41D2FC623BDD91C582F"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "DACDBEBD31D14EAC4207A45DB88734AD14D26D908507F41D2FC623BDD91C582F"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "r3wN3v2vTUkr5qd6daqDc2xE4LSysdVjkT",
|
||||
"Balance": "9999999990",
|
||||
"Flags": 0,
|
||||
"OwnerCount": 0,
|
||||
"Sequence": 2
|
||||
},
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"LedgerIndex": "F5F1834B80A8B5DA878270AB4DE4EA444281181349375F1D21E46D5F3F0ABAC8",
|
||||
"PreviousFields": {
|
||||
"Balance": "9999989990",
|
||||
"OwnerCount": 1
|
||||
},
|
||||
"PreviousTxnID": "4756C22BBB7FC23D9081FDB180806939D6FEBC967BE0EC2DB95B166AF9C086E9",
|
||||
"PreviousTxnLgrSeq": 2764813
|
||||
}
|
||||
}
|
||||
],
|
||||
"TransactionIndex": 2,
|
||||
"TransactionResult": "tesSUCCESS"
|
||||
},
|
||||
"validated": true
|
||||
}
|
||||
}
|
||||
@@ -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,51 +1,174 @@
|
||||
'use strict'
|
||||
const xrpl = require('xrpl');
|
||||
import { Client, isoTimeToRippleTime, rippleTimeToISOTime, validate, getBalanceChanges } from 'xrpl'
|
||||
|
||||
// Preqrequisites:
|
||||
// 1. Create an escrow using the create-escrow.js snippet
|
||||
// 2. Replace the OfferSequence with the sequence number of the escrow you created
|
||||
// 3. Paste the seed of the account that created the escrow
|
||||
// 4. Run this snippet
|
||||
const client = new Client('wss://s.altnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
const seed = "sEd7jfWyNG6J71dEojB3W9YdHp2KCjy"; // replace with your seed
|
||||
const sequenceNumber = 0; // replace with the sequence number of your escrow
|
||||
console.log('Funding new wallet from faucet...')
|
||||
const { wallet } = await client.fundWallet()
|
||||
// const destinationAddress = 'rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe' // Testnet faucet
|
||||
// Alternative: Get another account to send the escrow to. Use this if you get
|
||||
// a tecDIR_FULL error trying to create escrows to the Testnet faucet.
|
||||
const destinationAddress = (await client.fundWallet()).wallet.address
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
// Connect -------------------------------------------------------------------
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233');
|
||||
await client.connect();
|
||||
// Create an escrow that won't be finished -------------------------------------
|
||||
const cancelDelay = 30
|
||||
const cancelAfter = new Date()
|
||||
cancelAfter.setSeconds(cancelAfter.getSeconds() + cancelDelay)
|
||||
console.log('This escrow will expire after:', cancelAfter)
|
||||
// Convert cancelAfter to seconds since the Ripple Epoch:
|
||||
const cancelAfterRippleTime = isoTimeToRippleTime(cancelAfter.toISOString())
|
||||
const conditionHex = 'A02580200000000000000000000000000000000000000000000000000000000000000000810120'
|
||||
|
||||
// Prepare wallet to sign the transaction -------------------------------------
|
||||
const wallet = await xrpl.Wallet.fromSeed(seed);
|
||||
console.log("Wallet Address: ", wallet.address);
|
||||
console.log("Seed: ", seed);
|
||||
const escrowCreate = {
|
||||
TransactionType: 'EscrowCreate',
|
||||
Account: wallet.address,
|
||||
Destination: destinationAddress,
|
||||
Amount: '123456',
|
||||
Condition: conditionHex,
|
||||
CancelAfter: cancelAfterRippleTime
|
||||
}
|
||||
validate(escrowCreate)
|
||||
|
||||
// Construct the escrow cancel transaction ------------------------------------
|
||||
console.log('Signing and submitting the EscrowCreate transaction.')
|
||||
const response = await client.submitAndWait(escrowCreate, {
|
||||
wallet,
|
||||
autofill: true // Note: fee is higher based on condition size in bytes
|
||||
})
|
||||
console.log(JSON.stringify(response.result, null, 2))
|
||||
const escrowCreateResultCode = response.result.meta.TransactionResult
|
||||
if (escrowCreateResultCode !== 'tesSUCCESS') {
|
||||
console.error(`EscrowCreate failed with code ${escrowCreateResultCode}.`)
|
||||
client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if(!sequenceNumber){
|
||||
throw new Error("Please specify the sequence number of the escrow you created");
|
||||
};
|
||||
// Wait for the escrow to expire -----------------------------------------------
|
||||
// Since ledger close times can be rounded by up to 10 seconds, wait an extra
|
||||
// 10 seconds to make sure the escrow has officially expired.
|
||||
console.log(`Waiting ${cancelDelay + 10} seconds for the escrow to expire...`)
|
||||
await sleep(cancelDelay + 10)
|
||||
|
||||
const escrowCancelTransaction = {
|
||||
"Account": wallet.address,
|
||||
"TransactionType": "EscrowCancel",
|
||||
"Owner": wallet.address,
|
||||
"OfferSequence": sequenceNumber, // Sequence number
|
||||
};
|
||||
/* Sleep function that can be used with await */
|
||||
function sleep (delayInSeconds) {
|
||||
const delayInMs = delayInSeconds * 1000
|
||||
return new Promise((resolve) => setTimeout(resolve, delayInMs))
|
||||
}
|
||||
|
||||
xrpl.validate(escrowCancelTransaction);
|
||||
// Look up the official close time of the validated ledger ---------------------
|
||||
const ledger = await client.request({
|
||||
command: 'ledger',
|
||||
ledger_index: 'validated'
|
||||
})
|
||||
if (ledger.error) {
|
||||
console.error(`Error looking up validated ledger: ${ledger.error}`)
|
||||
client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
const closeTime = ledger.result.ledger.close_time
|
||||
console.log('Latest validated ledger closed at',
|
||||
rippleTimeToISOTime(closeTime)
|
||||
)
|
||||
const ledgerHash = ledger.result.ledger.ledger_hash
|
||||
|
||||
// Sign and submit the transaction --------------------------------------------
|
||||
console.log('Signing and submitting the transaction: ', JSON.stringify(escrowCancelTransaction, null, "\t"));
|
||||
const response = await client.submitAndWait(escrowCancelTransaction, { wallet });
|
||||
console.log(`Finished submitting! \n${JSON.stringify(response.result, null, "\t")}`);
|
||||
// Look up escrows connected to the account, handling pagination ---------------
|
||||
let marker
|
||||
let expiredEscrow
|
||||
while (true) {
|
||||
console.log(`Requesting page of account_objects with marker ${marker}`)
|
||||
const resp = await client.request({
|
||||
command: 'account_objects',
|
||||
account: wallet.address,
|
||||
ledger_hash: ledgerHash,
|
||||
type: 'escrow',
|
||||
marker
|
||||
})
|
||||
if (resp.error) {
|
||||
console.error('account_objects failed with error', resp)
|
||||
client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
await client.disconnect();
|
||||
// Add new escrows to the full list
|
||||
for (const escrow of resp.result.account_objects) {
|
||||
if (!escrow.hasOwnProperty('CancelAfter')) {
|
||||
console.log('This escrow does not have an expiration.')
|
||||
} else if (escrow.CancelAfter < closeTime) {
|
||||
console.log('This escrow has expired.')
|
||||
expiredEscrow = escrow
|
||||
break
|
||||
} else {
|
||||
const expirationTime = rippleTimeToISOTime(escrow.CancelAfter)
|
||||
console.log('This escrow expires at', expirationTime)
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
if (expiredEscrow) {
|
||||
// Found an expired escrow, stop paginating
|
||||
break
|
||||
}
|
||||
|
||||
// If there's a marker, loop and fetch the next page of results
|
||||
if (resp.result.marker) {
|
||||
marker = resp.result.marker
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
if (!expiredEscrow) {
|
||||
console.error('Did not find any expired escrows.')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Find the sequence number of the expired escrow ------------------------------
|
||||
let escrow_seq
|
||||
const txResp = await client.request({
|
||||
command: 'tx',
|
||||
transaction: expiredEscrow.PreviousTxnID
|
||||
})
|
||||
if (txResp.error) {
|
||||
console.error("Couldn't get transaction. Maybe this server doesn't have",
|
||||
'enough transaction history available?')
|
||||
client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (txResp.result.tx_json.TransactionType === 'EscrowCreate') {
|
||||
// Save this sequence number for canceling the escrow
|
||||
escrow_seq = txResp.result.tx_json.Sequence
|
||||
if (escrow_seq === 0) {
|
||||
// This transaction used a Ticket, so use TicketSequence instead.
|
||||
escrow_seq = response.result.tx_json.TicketSequence
|
||||
}
|
||||
} else {
|
||||
console.error("This escrow's previous transaction wasn't EscrowCreate!")
|
||||
client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Send EscrowCancel transaction -----------------------------------------------
|
||||
const escrowCancel = {
|
||||
TransactionType: 'EscrowCancel',
|
||||
Account: wallet.address,
|
||||
Owner: expiredEscrow.Account,
|
||||
OfferSequence: escrow_seq
|
||||
}
|
||||
validate(escrowCancel)
|
||||
|
||||
console.log('Signing and submitting the EscrowCancel transaction.')
|
||||
const cancelResponse = await client.submitAndWait(escrowCancel, {
|
||||
wallet,
|
||||
autofill: true
|
||||
})
|
||||
console.log(JSON.stringify(cancelResponse.result, null, 2))
|
||||
const cancelResultCode = cancelResponse.result.meta.TransactionResult
|
||||
if (cancelResultCode !== 'tesSUCCESS') {
|
||||
console.error(`EscrowCancel failed with result code ${cancelResultCode}`)
|
||||
client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log('Escrow canceled. Balance changes:')
|
||||
console.log(JSON.stringify(getBalanceChanges(cancelResponse.result.meta), null, 2))
|
||||
|
||||
client.disconnect()
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
'use strict'
|
||||
const xrpl = require('xrpl');
|
||||
const cc = require('five-bells-condition');
|
||||
const crypto = require('crypto');
|
||||
|
||||
// Useful Documentation:-
|
||||
// 1. five-bells-condition: https://www.npmjs.com/package/five-bells-condition
|
||||
// 2. Crypto module: https://nodejs.org/api/crypto.html
|
||||
|
||||
// Your seed value, for testing purposes you can make one with the faucet:
|
||||
// https://xrpl.org/resources/dev-tools/xrp-faucets
|
||||
const seed = "sEd7jfWyNG6J71dEojB3W9YdHp2KCjy";
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
|
||||
// Connect ----------------------------------------------------------------
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233');
|
||||
await client.connect();
|
||||
|
||||
// Prepare wallet to sign the transaction ---------------------------------
|
||||
const wallet = await xrpl.Wallet.fromSeed(seed);
|
||||
console.log("Wallet Address: ", wallet.address);
|
||||
console.log("Seed: ", seed);
|
||||
|
||||
// Set the escrow finish time ---------------------------------------------
|
||||
let finishAfter = new Date((new Date().getTime() / 1000) + 120); // 2 minutes from now
|
||||
finishAfter = new Date(finishAfter * 1000);
|
||||
console.log("This escrow will finish after: ", finishAfter);
|
||||
|
||||
// Construct condition and fulfillment ------------------------------------
|
||||
const preimageData = crypto.randomBytes(32);
|
||||
const myFulfillment = new cc.PreimageSha256();
|
||||
myFulfillment.setPreimage(preimageData);
|
||||
const conditionHex = myFulfillment.getConditionBinary().toString('hex').toUpperCase();
|
||||
|
||||
console.log('Condition:', conditionHex);
|
||||
console.log('Fulfillment:', myFulfillment.serializeBinary().toString('hex').toUpperCase());
|
||||
|
||||
// Prepare EscrowCreate transaction ------------------------------------
|
||||
const escrowCreateTransaction = {
|
||||
"TransactionType": "EscrowCreate",
|
||||
"Account": wallet.address,
|
||||
"Destination": wallet.address,
|
||||
"Amount": "6000000", //drops XRP
|
||||
"DestinationTag": 2023,
|
||||
"Condition": conditionHex, // Omit this for time-held escrows
|
||||
"Fee": "12",
|
||||
"FinishAfter": xrpl.isoTimeToRippleTime(finishAfter.toISOString()),
|
||||
};
|
||||
|
||||
xrpl.validate(escrowCreateTransaction);
|
||||
|
||||
// Sign and submit the transaction ----------------------------------------
|
||||
console.log('Signing and submitting the transaction:',
|
||||
JSON.stringify(escrowCreateTransaction, null, "\t"), "\n"
|
||||
);
|
||||
const response = await client.submitAndWait(escrowCreateTransaction, { wallet });
|
||||
console.log(`Sequence number: ${response.result.tx_json.Sequence}`);
|
||||
console.log(`Finished submitting! ${JSON.stringify(response.result, null, "\t")}`);
|
||||
|
||||
await client.disconnect();
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
@@ -1,60 +0,0 @@
|
||||
'use strict'
|
||||
const xrpl = require('xrpl')
|
||||
|
||||
// Preqrequisites:
|
||||
// 1. Create an escrow using the create-escrow.js snippet
|
||||
// 2. Replace the OfferSequence with the sequence number of the escrow you created
|
||||
// 3. Replace the Condition and Fulfillment with the values from the escrow you created
|
||||
// 4. Paste the seed of the account that created the escrow
|
||||
// 5. Run the snippet
|
||||
|
||||
const seed = "sEd7jfWyNG6J71dEojB3W9YdHp2KCjy"; // Test seed. Don't use
|
||||
const offerSequence = null;
|
||||
const condition = "";
|
||||
const fulfillment = "";
|
||||
|
||||
const main = async () => {
|
||||
try {
|
||||
// Connect ----------------------------------------------------------------
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233');
|
||||
await client.connect();
|
||||
|
||||
// Prepare wallet to sign the transaction ---------------------------------
|
||||
const wallet = await xrpl.Wallet.fromSeed(seed);
|
||||
console.log("Wallet Address: ", wallet.address);
|
||||
console.log("Seed: ", seed);
|
||||
|
||||
if((!offerSequence)|| (condition === "" || fulfillment === "")){
|
||||
throw new Error("Please specify the sequence number, condition and fulfillment of the escrow you created");
|
||||
};
|
||||
|
||||
// Prepare EscrowFinish transaction ---------------------------------
|
||||
const escrowFinishTransaction = {
|
||||
"Account": wallet.address,
|
||||
"TransactionType": "EscrowFinish",
|
||||
"Owner": wallet.address,
|
||||
// This should equal the sequence number of the escrow transaction
|
||||
"OfferSequence": offerSequence,
|
||||
// Crypto condition that must be met before escrow can be completed, passed on escrow creation.
|
||||
// Omit this for time-held escrows.
|
||||
"Condition": condition,
|
||||
// Fulfillment of the condition, passed on escrow creation.
|
||||
// Omit this for time-held escrows.
|
||||
"Fulfillment": fulfillment,
|
||||
};
|
||||
|
||||
xrpl.validate(escrowFinishTransaction);
|
||||
|
||||
// Sign and submit the transaction ----------------------------------------
|
||||
console.log('Signing and submitting the transaction:', JSON.stringify(escrowFinishTransaction, null, "\t"));
|
||||
const response = await client.submitAndWait(escrowFinishTransaction, { wallet });
|
||||
console.log(`Finished submitting! ${JSON.stringify(response.result, null, "\t")}`);
|
||||
|
||||
await client.disconnect();
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
@@ -1,54 +1,114 @@
|
||||
const xrpl = require('xrpl')
|
||||
import { Client, dropsToXrp, rippleTimeToISOTime } from 'xrpl'
|
||||
|
||||
// List the Escrows on an existing account filtered by source and destination
|
||||
// https://xrpl.org/escrow.html#escrow
|
||||
// https://xrpl.org/account_objects.html#account_objects
|
||||
|
||||
async function main() {
|
||||
// Testnet example: rPRKeXbcFMcn69nR2bovp4bEcP8kZx7x5i
|
||||
account = "rPRKeXbcFMcn69nR2bovp4bEcP8kZx7x5i"
|
||||
|
||||
// Connect to a testnet node
|
||||
console.log("Connecting to Testnet...")
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233/')
|
||||
// Set up client and address
|
||||
const address = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn'
|
||||
console.log('Connecting to Mainnet...')
|
||||
const client = new Client('wss://xrplcluster.com/')
|
||||
await client.connect()
|
||||
|
||||
const response = await client.request({
|
||||
"command": "account_objects",
|
||||
"account": account,
|
||||
"ledger_index": "validated",
|
||||
"type": "escrow"
|
||||
// Look up the official close time of the validated ledger ---------------------
|
||||
const ledger = await client.request({
|
||||
command: 'ledger',
|
||||
ledger_index: 'validated'
|
||||
})
|
||||
if (ledger.error) {
|
||||
console.error(`Error looking up validated ledger: ${ledger.error}`)
|
||||
client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
const close_time = ledger.result.ledger.close_time
|
||||
const ledger_hash = ledger.result.ledger.ledger_hash
|
||||
|
||||
var incoming = []
|
||||
var outgoing = []
|
||||
// Look up objects filtered to escrows, handling pagination --------------------
|
||||
let marker
|
||||
const escrows = []
|
||||
while (true) {
|
||||
console.log(`Requesting page of account_objects with marker ${marker}`)
|
||||
const resp = await client.request({
|
||||
command: 'account_objects',
|
||||
account: address,
|
||||
ledger_hash, // Caution: if you use a shortcut
|
||||
// such as "validated", the ledger may
|
||||
// change during iteration, leading to
|
||||
// inconsistent results.
|
||||
type: 'escrow',
|
||||
marker
|
||||
})
|
||||
if (resp.error) {
|
||||
console.error('account_objects failed with error', resp)
|
||||
client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
for (var i = 0; i < response.result.account_objects.length; i++) {
|
||||
if (response.result.account_objects[i].Account == account) {
|
||||
outgoing.push(response.result.account_objects[i])
|
||||
// Add new escrows to the full list
|
||||
for (const escrow of resp.result.account_objects) {
|
||||
escrows.push(escrow)
|
||||
}
|
||||
|
||||
// If there's a marker, loop and fetch the next page of results
|
||||
if (resp.result.marker) {
|
||||
marker = resp.result.marker
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Define helper function for displaying amounts -------------------------------
|
||||
function display_amount (amount) {
|
||||
if (typeof amount === 'string') {
|
||||
// amount is drops of XRP.
|
||||
const decimal_xrp = dropsToXrp(amount)
|
||||
return `${decimal_xrp} XRP`
|
||||
} else if (amount.hasOwnProperty('mpt_issuance_id')) {
|
||||
// amount is an MPT.
|
||||
// More info may be available, but that would require looking it up.
|
||||
return `${amount.value} units of MPT ${amount.mpt_issuance_id}`
|
||||
} else if (amount.hasOwnProperty('issuer')) {
|
||||
// amount is a trust line token.
|
||||
// Currency may be 3 chars or hex. For guidelines parsing hex codes,
|
||||
// see "Normalize Currency Codes" code sample.
|
||||
return `${amount.value} ${amount.currency} issued by ${amount.issuer}`
|
||||
}
|
||||
console.error(`Unexpected type of amount: ${amount}`)
|
||||
client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Summarize results -----------------------------------------------------------
|
||||
console.log(`Found ${escrows.length} escrow(s).`)
|
||||
|
||||
for (const escrow of escrows) {
|
||||
if (escrow.Account === address) {
|
||||
console.log(`Outgoing escrow to ${escrow.Destination}`)
|
||||
} else if (escrow.Destination === address) {
|
||||
console.log(`Incoming escrow from ${escrow.Account}`)
|
||||
} else {
|
||||
console.log('Neither incoming nor outgoing? This is unexexpected.')
|
||||
}
|
||||
|
||||
console.log(` Amount: ${display_amount(escrow.Amount)}`)
|
||||
|
||||
if (escrow.hasOwnProperty('Condition')) {
|
||||
console.log(` Condition: ${escrow.Condition}`)
|
||||
}
|
||||
|
||||
if (escrow.FinishAfter) {
|
||||
const mature_time_display = rippleTimeToISOTime(escrow.FinishAfter)
|
||||
if (escrow.FinishAfter < close_time) {
|
||||
console.log(` Matured at ${mature_time_display}`)
|
||||
} else {
|
||||
incoming.push(response.result.account_objects[i])
|
||||
console.log(` Will mature at ${mature_time_display}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("\nIncoming/Received escrow(s):")
|
||||
for (var i = 0; i < incoming.length; i++) {
|
||||
console.log(`\n${i+1}. Index (ObjectID/keylet): ${incoming[i].index}`)
|
||||
console.log(` - Account: ${incoming[i].Account})`)
|
||||
console.log(` - Destination: ${incoming[i].Destination}`)
|
||||
console.log(` - Amount: ${incoming[i].Amount} drops`)
|
||||
}
|
||||
|
||||
console.log("\nOutgoing/Sent escrow(s):")
|
||||
for (var i = 0; i < outgoing.length; i++) {
|
||||
console.log(`\n${i+1}. Index (ObjectID/keylet): ${outgoing[i].index}`)
|
||||
console.log(` - Account: ${outgoing[i].Account})`)
|
||||
console.log(` - Destination: ${outgoing[i].Destination}`)
|
||||
console.log(` - Amount: ${outgoing[i].Amount} drops`)
|
||||
if (escrow.hasOwnProperty('CancelAfter')) {
|
||||
const cancel_time_display = rippleTimeToISOTime(escrow.CancelAfter)
|
||||
if (escrow.CancelAfter < close_time) {
|
||||
console.log(` EXPIRED at ${cancel_time_display}`)
|
||||
} else {
|
||||
console.log(` Expires at ${cancel_time_display}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
client.disconnect()
|
||||
// End main()
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
const cc = require('five-bells-condition')
|
||||
const crypto = require('crypto')
|
||||
|
||||
const preimageData = crypto.randomBytes(32)
|
||||
const myFulfillment = new cc.PreimageSha256()
|
||||
myFulfillment.setPreimage(preimageData)
|
||||
|
||||
console.log('Condition:', myFulfillment.getConditionBinary().toString('hex').toUpperCase())
|
||||
console.log('Fulfillment:', myFulfillment.serializeBinary().toString('hex').toUpperCase())
|
||||
@@ -1,9 +1,10 @@
|
||||
{
|
||||
"name": "escrow-examples",
|
||||
"version": "0.0.3",
|
||||
"version": "2.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"five-bells-condition": "*",
|
||||
"xrpl": "^4.0.0"
|
||||
}
|
||||
"xrpl": "^4.4.0"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
89
_code-samples/escrow/js/send-conditional-escrow.js
Normal file
89
_code-samples/escrow/js/send-conditional-escrow.js
Normal file
@@ -0,0 +1,89 @@
|
||||
import xrpl from 'xrpl'
|
||||
import { PreimageSha256 } from 'five-bells-condition'
|
||||
import { randomBytes } from 'crypto'
|
||||
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
console.log('Funding new wallet from faucet...')
|
||||
const { wallet } = await client.fundWallet()
|
||||
// const destination_address = 'rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe' // Testnet faucet
|
||||
// Alternative: Get another account to send the escrow to. Use this if you get
|
||||
// a tecDIR_FULL error trying to create escrows to the Testnet faucet.
|
||||
const destination_address = (await client.fundWallet()).wallet.address
|
||||
|
||||
// Create the crypto-condition for release ----------------------------------
|
||||
const preimage = randomBytes(32)
|
||||
const fulfillment = new PreimageSha256()
|
||||
fulfillment.setPreimage(preimage)
|
||||
const fulfillmentHex = fulfillment.serializeBinary().toString('hex').toUpperCase()
|
||||
const conditionHex = fulfillment.getConditionBinary().toString('hex').toUpperCase()
|
||||
console.log('Condition:', conditionHex)
|
||||
console.log('Fulfillment:', fulfillmentHex)
|
||||
|
||||
// Set the escrow expiration ------------------------------------------------
|
||||
const cancelDelay = 300 // Seconds in the future when the escrow should expire
|
||||
const cancelAfter = new Date() // Current time
|
||||
cancelAfter.setSeconds(cancelAfter.getSeconds() + cancelDelay)
|
||||
console.log('This escrow will expire after:', cancelAfter)
|
||||
// Convert cancelAfter to seconds since the Ripple Epoch:
|
||||
const cancelAfterRippleTime = xrpl.isoTimeToRippleTime(cancelAfter.toISOString())
|
||||
|
||||
// Send EscrowCreate transaction --------------------------------------------
|
||||
const escrowCreate = {
|
||||
TransactionType: 'EscrowCreate',
|
||||
Account: wallet.address,
|
||||
Destination: destination_address,
|
||||
Amount: '123456', // drops of XRP
|
||||
Condition: conditionHex,
|
||||
CancelAfter: cancelAfterRippleTime
|
||||
}
|
||||
xrpl.validate(escrowCreate)
|
||||
|
||||
console.log('Signing and submitting the transaction:',
|
||||
JSON.stringify(escrowCreate, null, 2))
|
||||
const response = await client.submitAndWait(escrowCreate, {
|
||||
wallet,
|
||||
autofill: true // Note: fee is higher based on condition size in bytes
|
||||
})
|
||||
|
||||
// Check result of submitting -----------------------------------------------
|
||||
console.log(JSON.stringify(response.result, null, 2))
|
||||
const escrowCreateResultCode = response.result.meta.TransactionResult
|
||||
if (escrowCreateResultCode === 'tesSUCCESS') {
|
||||
console.log('Escrow created successfully.')
|
||||
} else {
|
||||
console.error(`EscrowCreate failed with code ${escrowCreateResultCode}.`)
|
||||
client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Save the sequence number so you can identify the escrow later.
|
||||
const escrowSeq = response.result.tx_json.Sequence
|
||||
console.log(`Escrow sequence is ${escrowSeq}.`)
|
||||
|
||||
// Send EscrowFinish transaction --------------------------------------------
|
||||
const escrowFinish = {
|
||||
TransactionType: 'EscrowFinish',
|
||||
Account: wallet.address,
|
||||
Owner: wallet.address,
|
||||
OfferSequence: escrowSeq,
|
||||
Condition: conditionHex,
|
||||
Fulfillment: fulfillmentHex
|
||||
}
|
||||
xrpl.validate(escrowFinish)
|
||||
|
||||
console.log('Signing and submitting the transaction:',
|
||||
JSON.stringify(escrowFinish, null, 2))
|
||||
const response2 = await client.submitAndWait(escrowFinish, {
|
||||
wallet,
|
||||
autofill: true // Note: fee is higher based on fulfillment size in bytes
|
||||
})
|
||||
console.log(JSON.stringify(response2.result, null, 2))
|
||||
if (response2.result.meta.TransactionResult === 'tesSUCCESS') {
|
||||
console.log('Escrow finished successfully.')
|
||||
} else {
|
||||
console.log(`Failed with result code ${response2.result.meta.TransactionResult}`)
|
||||
}
|
||||
|
||||
client.disconnect()
|
||||
108
_code-samples/escrow/js/send-timed-escrow.js
Normal file
108
_code-samples/escrow/js/send-timed-escrow.js
Normal file
@@ -0,0 +1,108 @@
|
||||
import xrpl from 'xrpl'
|
||||
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
console.log('Funding new wallet from faucet...')
|
||||
const { wallet } = await client.fundWallet()
|
||||
// const destination_address = 'rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe' // Testnet faucet
|
||||
// Alternative: Get another account to send the escrow to. Use this if you get
|
||||
// a tecDIR_FULL error trying to create escrows to the Testnet faucet.
|
||||
const destination_address = (await client.fundWallet()).wallet.address
|
||||
|
||||
// Set the escrow finish time -----------------------------------------------
|
||||
const delay = 30 // Seconds in the future when the escrow should mature
|
||||
const finishAfter = new Date() // Current time
|
||||
finishAfter.setSeconds(finishAfter.getSeconds() + delay)
|
||||
console.log('This escrow will finish after:', finishAfter)
|
||||
// Convert finishAfter to seconds since the Ripple Epoch:
|
||||
const finishAfterRippleTime = xrpl.isoTimeToRippleTime(finishAfter.toISOString())
|
||||
|
||||
// Send EscrowCreate transaction --------------------------------------------
|
||||
const escrowCreate = {
|
||||
TransactionType: 'EscrowCreate',
|
||||
Account: wallet.address,
|
||||
Destination: destination_address,
|
||||
Amount: '123456', // drops of XRP
|
||||
FinishAfter: finishAfterRippleTime
|
||||
}
|
||||
xrpl.validate(escrowCreate)
|
||||
|
||||
console.log('Signing and submitting the transaction:',
|
||||
JSON.stringify(escrowCreate, null, 2))
|
||||
const response = await client.submitAndWait(escrowCreate, {
|
||||
wallet,
|
||||
autofill: true
|
||||
})
|
||||
console.log(JSON.stringify(response.result, null, 2))
|
||||
const escrowCreateResultCode = response.result.meta.TransactionResult
|
||||
if (escrowCreateResultCode === 'tesSUCCESS') {
|
||||
console.log('Escrow created successfully.')
|
||||
} else {
|
||||
console.error(`EscrowCreate failed with code ${escrowCreateResultCode}.`)
|
||||
client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Save the sequence number so you can identify the escrow later.
|
||||
const escrowSeq = response.result.tx_json.Sequence
|
||||
console.log(`Escrow sequence is ${escrowSeq}.`)
|
||||
|
||||
// Wait for the escrow to be finishable -------------------------------------
|
||||
console.log(`Waiting ${delay} seconds for the escrow to mature...`)
|
||||
await sleep(delay)
|
||||
|
||||
/* Sleep function that can be used with await */
|
||||
function sleep (delayInSeconds) {
|
||||
const delayInMs = delayInSeconds * 1000
|
||||
return new Promise((resolve) => setTimeout(resolve, delayInMs))
|
||||
}
|
||||
|
||||
// Check if escrow can be finished -------------------------------------------
|
||||
let escrowReady = false
|
||||
while (!escrowReady) {
|
||||
// Check the close time of the latest validated ledger.
|
||||
// Close times are rounded by about 10 seconds, so the exact time the escrow
|
||||
// is ready to finish may vary by +/- 10 seconds.
|
||||
const validatedLedger = await client.request({
|
||||
command: 'ledger',
|
||||
ledger_index: 'validated'
|
||||
})
|
||||
const ledgerCloseTime = validatedLedger.result.ledger.close_time
|
||||
console.log('Latest validated ledger closed at',
|
||||
xrpl.rippleTimeToISOTime(ledgerCloseTime))
|
||||
if (ledgerCloseTime > finishAfterRippleTime) {
|
||||
escrowReady = true
|
||||
console.log('Escrow is mature.')
|
||||
} else {
|
||||
let timeDifference = finishAfterRippleTime - ledgerCloseTime
|
||||
if (timeDifference === 0) { timeDifference = 1 }
|
||||
console.log(`Waiting another ${timeDifference} second(s).`)
|
||||
await sleep(timeDifference)
|
||||
}
|
||||
}
|
||||
|
||||
// Send EscrowFinish transaction --------------------------------------------
|
||||
const escrowFinish = {
|
||||
TransactionType: 'EscrowFinish',
|
||||
Account: wallet.address,
|
||||
Owner: wallet.address,
|
||||
OfferSequence: escrowSeq
|
||||
}
|
||||
xrpl.validate(escrowFinish)
|
||||
|
||||
console.log('Signing and submitting the transaction:',
|
||||
JSON.stringify(escrowFinish, null, 2))
|
||||
const response2 = await client.submitAndWait(escrowFinish, {
|
||||
wallet,
|
||||
autofill: true
|
||||
})
|
||||
console.log(JSON.stringify(response2.result, null, 2))
|
||||
if (response2.result.meta.TransactionResult === 'tesSUCCESS') {
|
||||
console.log('Escrow finished successfully. Balance changes:')
|
||||
console.log(
|
||||
JSON.stringify(xrpl.getBalanceChanges(response2.result.meta), null, 2)
|
||||
)
|
||||
}
|
||||
|
||||
client.disconnect()
|
||||
@@ -1,31 +1,136 @@
|
||||
import json
|
||||
from datetime import datetime, timedelta, UTC
|
||||
from time import sleep
|
||||
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models import EscrowCancel
|
||||
from xrpl.models import EscrowCreate, EscrowCancel
|
||||
from xrpl.models.requests import AccountObjects, Ledger, Tx
|
||||
from xrpl.transaction import submit_and_wait
|
||||
from xrpl.utils import datetime_to_ripple_time, ripple_time_to_datetime, get_balance_changes
|
||||
from xrpl.wallet import generate_faucet_wallet
|
||||
|
||||
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to the testnetwork
|
||||
# Set up client and get a wallet
|
||||
client = JsonRpcClient("https://s.altnet.rippletest.net:51234")
|
||||
print("Funding new wallet from faucet...")
|
||||
wallet = generate_faucet_wallet(client, debug=True)
|
||||
# destination_address = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" # Testnet faucet
|
||||
# Alternative: Get another account to send the escrow to. Use this if you get
|
||||
# a tecDIR_FULL error trying to create escrows to the Testnet faucet.
|
||||
destination_address = generate_faucet_wallet(client, debug=True).address
|
||||
|
||||
# Cancel an escrow
|
||||
# An Escrow can only be canceled if it was created with a CancelAfter time
|
||||
|
||||
escrow_sequence = 30215126
|
||||
|
||||
# Sender wallet object
|
||||
sender_wallet = generate_faucet_wallet(client=client)
|
||||
|
||||
# Build escrow cancel transaction
|
||||
cancel_txn = EscrowCancel(
|
||||
account=sender_wallet.address,
|
||||
owner=sender_wallet.address,
|
||||
offer_sequence=escrow_sequence
|
||||
# Create an escrow that won't be finished --------------------------------------
|
||||
cancel_delay = 30
|
||||
cancel_after = datetime.now(tz=UTC) + timedelta(seconds=cancel_delay)
|
||||
print("This escrow will expire after", cancel_after)
|
||||
cancel_after_rippletime = datetime_to_ripple_time(cancel_after)
|
||||
# Use a crypto-condition that nobody knows the fulfillment for
|
||||
condition_hex = "A02580200000000000000000000000000000000000000000000000000000000000000000810120"
|
||||
escrow_create = EscrowCreate(
|
||||
account=wallet.address,
|
||||
destination=destination_address,
|
||||
amount="123456", # drops of XRP
|
||||
condition=condition_hex,
|
||||
cancel_after=cancel_after_rippletime
|
||||
)
|
||||
print("Signing and submitting the EscrowCreate transaction.")
|
||||
response = submit_and_wait(escrow_create, client, wallet, autofill=True)
|
||||
print(json.dumps(response.result, indent=2))
|
||||
|
||||
# Autofill, sign, then submit transaction and wait for result
|
||||
stxn_response = submit_and_wait(cancel_txn, client, sender_wallet)
|
||||
result_code = response.result["meta"]["TransactionResult"]
|
||||
if result_code != "tesSUCCESS":
|
||||
print(f"EscrowCreate failed with result code {result_code}")
|
||||
exit(1)
|
||||
|
||||
# Parse response and return result
|
||||
stxn_result = stxn_response.result
|
||||
# Wait for the escrow to expire ------------------------------------------------
|
||||
# Since ledger close times can be rounded by up to 10 seconds, wait an extra
|
||||
# 10 seconds to make sure the escrow has officially expired.
|
||||
print(f"Waiting {cancel_delay + 10} seconds for the escrow to expire.")
|
||||
sleep(cancel_delay + 10)
|
||||
|
||||
# Parse result and print out the transaction result and transaction hash
|
||||
print(stxn_result["meta"]["TransactionResult"])
|
||||
print(stxn_result["hash"])
|
||||
# Look up the official close time of the validated ledger ----------------------
|
||||
validated_ledger = client.request(Ledger(ledger_index="validated"))
|
||||
close_time = validated_ledger.result["ledger"]["close_time"]
|
||||
print("Latest validated ledger closed at",
|
||||
ripple_time_to_datetime(close_time)
|
||||
)
|
||||
ledger_hash = validated_ledger.result["ledger"]["ledger_hash"]
|
||||
|
||||
# Look up escrows connected to the account, handling pagination ----------------
|
||||
expired_escrow = None
|
||||
marker = None
|
||||
while True:
|
||||
try:
|
||||
response = client.request(AccountObjects(
|
||||
account=wallet.address,
|
||||
ledger_hash=ledger_hash,
|
||||
type="escrow",
|
||||
marker=marker
|
||||
))
|
||||
except Exception as e:
|
||||
print(f"Error: account_objects failed: {e}")
|
||||
exit(1)
|
||||
|
||||
for escrow in response.result["account_objects"]:
|
||||
if "CancelAfter" not in escrow:
|
||||
print("This escrow does not have an expiration")
|
||||
elif escrow["CancelAfter"] < close_time:
|
||||
print("This escrow has expired.")
|
||||
expired_escrow = escrow
|
||||
break
|
||||
else:
|
||||
expiration_time = ripple_time_to_datetime(escrow["CancelAfter"])
|
||||
print(f"This escrow expires at {expiration_time}.")
|
||||
|
||||
if expired_escrow:
|
||||
# Found an expired escrow, stop paginating
|
||||
break
|
||||
|
||||
if "marker" in response.result.keys():
|
||||
marker=marker
|
||||
else:
|
||||
# This is the last page of results
|
||||
break
|
||||
|
||||
if not expired_escrow:
|
||||
print("Did not find any expired escrows.")
|
||||
exit(1)
|
||||
|
||||
# Find the sequence number of the expired escrow -------------------------------
|
||||
response = client.request(Tx(transaction=expired_escrow["PreviousTxnID"]))
|
||||
if not response.is_successful():
|
||||
print("Couldn't get transaction. Maybe this server doesn't have enough "
|
||||
"transaction history available?")
|
||||
exit(1)
|
||||
|
||||
if response.result["tx_json"]["TransactionType"] == "EscrowCreate":
|
||||
# Save this sequence number for canceling the escrow
|
||||
escrow_seq = response.result["tx_json"]["Sequence"]
|
||||
if escrow_seq == 0:
|
||||
# This transaction used a Ticket, so use the TicketSequence instead.
|
||||
escrow_seq = response.result["tx_json"]["TicketSequence"]
|
||||
else:
|
||||
# Currently, this is impossible since no current transaction can update
|
||||
# an escrow without finishing or canceling it. But in the future, if
|
||||
# that becomes possible, you would have to look at the transaction
|
||||
# metadata to find the previous transaction and repeat until you found
|
||||
# the transaction that created the escrow.
|
||||
print("The escrow's previous transaction wasn't EscrowCreate!")
|
||||
exit(1)
|
||||
|
||||
# Send EscrowCancel transaction ------------------------------------------------
|
||||
escrow_cancel = EscrowCancel(
|
||||
account=wallet.address,
|
||||
owner=expired_escrow["Account"],
|
||||
offer_sequence=escrow_seq
|
||||
)
|
||||
print("Signing and submitting the EscrowCancel transaction.")
|
||||
response2 = submit_and_wait(escrow_cancel, client, wallet, autofill=True)
|
||||
print(json.dumps(response2.result, indent=2))
|
||||
|
||||
result_code = response2.result["meta"]["TransactionResult"]
|
||||
if result_code != "tesSUCCESS":
|
||||
print(f"EscrowCancel failed with result code {result_code}")
|
||||
exit(1)
|
||||
|
||||
print("Escrow canceled. Balance changes:")
|
||||
print(json.dumps(get_balance_changes(response2.result["meta"]), indent=2))
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models import EscrowCreate
|
||||
from xrpl.transaction import submit_and_wait
|
||||
from xrpl.utils import datetime_to_ripple_time, xrp_to_drops
|
||||
from xrpl.wallet import generate_faucet_wallet
|
||||
|
||||
# Create Escrow
|
||||
|
||||
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to client
|
||||
|
||||
amount_to_escrow = 10.000
|
||||
|
||||
receiver_addr = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" # Example: send back to Testnet Faucet
|
||||
|
||||
# Escrow will be available to claim after 3 days
|
||||
claim_date = datetime_to_ripple_time(datetime.now() + timedelta(days=3))
|
||||
|
||||
# Escrow will expire after 5 days
|
||||
expiry_date = datetime_to_ripple_time(datetime.now() + timedelta(days=5))
|
||||
|
||||
# Optional field
|
||||
# You can optionally use a Crypto Condition to allow for dynamic release of funds. For example:
|
||||
condition = "A02580205A0E9E4018BE1A6E0F51D39B483122EFDF1DDEF3A4BE83BE71522F9E8CDAB179810120" # do not use in production
|
||||
|
||||
# sender wallet object
|
||||
sender_wallet = generate_faucet_wallet(client=client)
|
||||
|
||||
# Build escrow create transaction
|
||||
create_txn = EscrowCreate(
|
||||
account=sender_wallet.address,
|
||||
amount=xrp_to_drops(amount_to_escrow),
|
||||
destination=receiver_addr,
|
||||
finish_after=claim_date,
|
||||
cancel_after=expiry_date,
|
||||
condition=condition # Omit this for time-held escrows
|
||||
)
|
||||
|
||||
# Autofill, sign, then submit transaction and wait for result
|
||||
stxn_response = submit_and_wait(create_txn, client, sender_wallet)
|
||||
|
||||
# Return result of transaction
|
||||
stxn_result = stxn_response.result
|
||||
|
||||
|
||||
# Parse result and print out the neccesary info
|
||||
print(stxn_result["tx_json"]["Account"])
|
||||
print(stxn_result["tx_json"]["Sequence"])
|
||||
|
||||
print(stxn_result["meta"]["TransactionResult"])
|
||||
print(stxn_result["hash"])
|
||||
@@ -1,44 +0,0 @@
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models import EscrowFinish
|
||||
from xrpl.transaction import submit_and_wait
|
||||
from xrpl.wallet import generate_faucet_wallet
|
||||
|
||||
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to the testnetwork
|
||||
|
||||
# Complete an escrow
|
||||
# Cannot be called until the finish time is reached
|
||||
|
||||
# Required fields (modify to match an escrow you create)
|
||||
escrow_creator = generate_faucet_wallet(client=client).address
|
||||
|
||||
escrow_sequence = 27641268
|
||||
|
||||
# Optional fields
|
||||
|
||||
# Crypto condition that must be met before escrow can be completed, passed on escrow creation
|
||||
condition = "A02580203882E2EB9B44130530541C4CC360D079F265792C4A7ED3840968897CB7DF2DA1810120"
|
||||
|
||||
# Crypto fulfillment of the condtion
|
||||
fulfillment = "A0228020AED2C5FE4D147D310D3CFEBD9BFA81AD0F63CE1ADD92E00379DDDAF8E090E24C"
|
||||
|
||||
# Sender wallet object
|
||||
sender_wallet = generate_faucet_wallet(client=client)
|
||||
|
||||
# Build escrow finish transaction
|
||||
finish_txn = EscrowFinish(
|
||||
account=sender_wallet.address,
|
||||
owner=escrow_creator,
|
||||
offer_sequence=escrow_sequence, # The sequence number of the escrow transaction
|
||||
condition=condition, # Omit this for time-held escrows
|
||||
fulfillment=fulfillment # Omit this for time-held escrows
|
||||
)
|
||||
|
||||
# Autofill, sign, then submit transaction and wait for result
|
||||
stxn_response = submit_and_wait(finish_txn, client, sender_wallet)
|
||||
|
||||
# Parse response and return result
|
||||
stxn_result = stxn_response.result
|
||||
|
||||
# Parse result and print out the transaction result and transaction hash
|
||||
print(stxn_result["meta"]["TransactionResult"])
|
||||
print(stxn_result["hash"])
|
||||
@@ -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}")
|
||||
88
_code-samples/escrow/py/list_escrows.py
Normal file
88
_code-samples/escrow/py/list_escrows.py
Normal file
@@ -0,0 +1,88 @@
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models.requests import AccountObjects, Ledger
|
||||
from xrpl.utils import ripple_time_to_datetime, drops_to_xrp
|
||||
|
||||
address = "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"
|
||||
client = JsonRpcClient("https://xrplcluster.com/")
|
||||
|
||||
# Look up the official close time of the validated ledger ----------------------
|
||||
validated_ledger = client.request(Ledger(ledger_index="validated"))
|
||||
close_time = validated_ledger.result["ledger"]["close_time"]
|
||||
print("Latest validated ledger closed at",
|
||||
ripple_time_to_datetime(close_time)
|
||||
)
|
||||
ledger_hash = validated_ledger.result["ledger"]["ledger_hash"]
|
||||
|
||||
# Look up objects filtered to escrows, handling pagination ---------------------
|
||||
escrows = []
|
||||
marker = None
|
||||
while True:
|
||||
try:
|
||||
response = client.request(AccountObjects(
|
||||
account=address,
|
||||
ledger_hash=ledger_hash, # Caution: if you use a shortcut such as
|
||||
# ledger_index="validated", the ledger may
|
||||
# change during iteration, leading to
|
||||
# inconsistent results.
|
||||
type="escrow",
|
||||
marker=marker
|
||||
))
|
||||
except Exception as e:
|
||||
print(f"Error: account_objects failed: {e}")
|
||||
exit(1)
|
||||
|
||||
# Concatenate escrows from this page to the full list
|
||||
escrows += response.result["account_objects"]
|
||||
|
||||
# If there's a marker, loop and fetch the next page of results
|
||||
if "marker" in response.result.keys():
|
||||
marker=marker
|
||||
else:
|
||||
break
|
||||
|
||||
# Define helper function for displaying amounts --------------------------------
|
||||
def display_amount(amount):
|
||||
if type(amount) == str:
|
||||
# amount is drops of XRP
|
||||
decimal_xrp = drops_to_xrp(amount)
|
||||
return f"{decimal_xrp} XRP"
|
||||
elif "mpt_issuance_id" in amount.keys():
|
||||
# amount is an MPT.
|
||||
# More info may be available, but that would require looking it up.
|
||||
return f"{amount['value']} units of MPT {amount['mpt_issuance_id']}"
|
||||
elif "issuer" in amount.keys():
|
||||
# amount is a trust line token.
|
||||
# Currency may be 3 chars or hex. For guidelines parsing hex codes,
|
||||
# see "Normalize Currency Codes" code sample.
|
||||
return f"{amount['value']} {amount['currency']} issued by {amount['issuer']}"
|
||||
|
||||
print(f"Unexpected type of amount: {amount}")
|
||||
exit(1)
|
||||
|
||||
# Summarize results ------------------------------------------------------------
|
||||
print(f"Found {len(escrows)} escrow(s).")
|
||||
|
||||
for escrow in escrows:
|
||||
if escrow['Account'] == address:
|
||||
print(f"Outgoing escrow to {escrow['Destination']}")
|
||||
elif escrow['Destination'] == address:
|
||||
print(f"Incoming escrow from {escrow['Account']}")
|
||||
else:
|
||||
print("Neither incoming nor outgoing? This is unexpected.")
|
||||
|
||||
if "Condition" in escrow.keys():
|
||||
print(f" Condition: {escrow['Condition']}")
|
||||
|
||||
if "FinishAfter" in escrow.keys():
|
||||
mature_time_display = ripple_time_to_datetime(escrow['FinishAfter'])
|
||||
if escrow["FinishAfter"] < close_time:
|
||||
print(" Matured at", mature_time_display)
|
||||
else:
|
||||
print(" Will mature at", mature_time_display)
|
||||
|
||||
if "CancelAfter" in escrow.keys():
|
||||
cancel_time_display = ripple_time_to_datetime(escrow['CancelAfter'])
|
||||
if escrow["CancelAfter"] < close_time:
|
||||
print(" EXPIRED AT", cancel_time_display)
|
||||
else:
|
||||
print(" Expires at", cancel_time_display)
|
||||
@@ -1,2 +1,2 @@
|
||||
xrpl-py>=3.0.0
|
||||
cryptoconditions
|
||||
cryptoconditions==0.8.1
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models import Tx
|
||||
|
||||
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to the testnetwork
|
||||
|
||||
|
||||
prev_txn_id = "" # should look like this '84503EA84ADC4A65530C6CC91C904FCEE64CFE2BB973C023476184288698991F'
|
||||
# Return escrow seq from `PreviousTxnID` for finishing or cancelling escrows
|
||||
if prev_txn_id == "":
|
||||
print("No transaction id provided. Use create_escrow.py to generate an escrow transaction, then you can look it up by modifying prev_txn_id to use that transaction's id.")
|
||||
|
||||
# Build and send query for PreviousTxnID
|
||||
req = Tx(transaction=prev_txn_id)
|
||||
response = client.request(req)
|
||||
|
||||
# Return the result
|
||||
result = response.result
|
||||
|
||||
# Print escrow sequence if available
|
||||
if "Sequence" in result:
|
||||
print(f'escrow sequence: {result["Sequence"]}')
|
||||
# Use escrow ticket sequence if escrow sequence is not available
|
||||
if "TicketSequence" in result:
|
||||
print(f'escrow ticket sequence: {result["TicketSequence"]}')
|
||||
74
_code-samples/escrow/py/send_conditional_escrow.py
Normal file
74
_code-samples/escrow/py/send_conditional_escrow.py
Normal file
@@ -0,0 +1,74 @@
|
||||
import json
|
||||
from datetime import datetime, timedelta, UTC
|
||||
from os import urandom
|
||||
|
||||
from cryptoconditions import PreimageSha256
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models import EscrowCreate, EscrowFinish
|
||||
from xrpl.transaction import submit_and_wait
|
||||
from xrpl.utils import datetime_to_ripple_time
|
||||
from xrpl.wallet import generate_faucet_wallet
|
||||
|
||||
# Set up client and get a wallet
|
||||
client = JsonRpcClient("https://s.altnet.rippletest.net:51234")
|
||||
print("Funding new wallet from faucet...")
|
||||
wallet = generate_faucet_wallet(client, debug=True)
|
||||
#destination_address = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" # Testnet faucet
|
||||
# Alternative: Get another account to send the escrow to. Use this if you get
|
||||
# a tecDIR_FULL error trying to create escrows to the Testnet faucet.
|
||||
destination_address = generate_faucet_wallet(client, debug=True).address
|
||||
|
||||
# Create the crypto-condition for release -----------------------------------
|
||||
preimage = urandom(32)
|
||||
fulfillment = PreimageSha256(preimage=preimage)
|
||||
condition_hex = fulfillment.condition_binary.hex().upper()
|
||||
fulfillment_hex = fulfillment.serialize_binary().hex().upper()
|
||||
print("Condition:", condition_hex)
|
||||
print("Fulfillment:", fulfillment_hex)
|
||||
|
||||
# Set the escrow expiration -------------------------------------------------
|
||||
cancel_delay = 300
|
||||
cancel_after = datetime.now(tz=UTC) + timedelta(seconds=cancel_delay)
|
||||
print("This escrow will expire after", cancel_after)
|
||||
cancel_after_rippletime = datetime_to_ripple_time(cancel_after)
|
||||
|
||||
# Send EscrowCreate transaction ---------------------------------------------
|
||||
escrow_create = EscrowCreate(
|
||||
account=wallet.address,
|
||||
destination=destination_address,
|
||||
amount="123456", # drops of XRP
|
||||
condition=condition_hex,
|
||||
cancel_after=cancel_after_rippletime
|
||||
)
|
||||
|
||||
print("Signing and submitting the EscrowCreate transaction.")
|
||||
response = submit_and_wait(escrow_create, client, wallet, autofill=True)
|
||||
print(json.dumps(response.result, indent=2))
|
||||
|
||||
# Check result of submitting ------------------------------------------------
|
||||
result_code = response.result["meta"]["TransactionResult"]
|
||||
if result_code != "tesSUCCESS":
|
||||
print(f"EscrowCreate failed with result code {result_code}")
|
||||
exit(1)
|
||||
|
||||
# Save the sequence number so you can identify the escrow later
|
||||
escrow_seq = response.result["tx_json"]["Sequence"]
|
||||
|
||||
# Send EscrowFinish transaction ---------------------------------------------
|
||||
escrow_finish = EscrowFinish(
|
||||
account=wallet.address,
|
||||
owner=wallet.address,
|
||||
offer_sequence=escrow_seq,
|
||||
condition=condition_hex,
|
||||
fulfillment=fulfillment_hex
|
||||
)
|
||||
print("Signing and submitting the EscrowFinish transaction.")
|
||||
response2 = submit_and_wait(escrow_finish, client, wallet, autofill=True)
|
||||
print(json.dumps(response2.result, indent=2))
|
||||
|
||||
result_code = response2.result["meta"]["TransactionResult"]
|
||||
if result_code != "tesSUCCESS":
|
||||
print(f"EscrowFinish failed with result code {result_code}")
|
||||
exit(1)
|
||||
|
||||
print("Escrow finished successfully.")
|
||||
86
_code-samples/escrow/py/send_timed_escrow.py
Normal file
86
_code-samples/escrow/py/send_timed_escrow.py
Normal file
@@ -0,0 +1,86 @@
|
||||
import json
|
||||
from datetime import datetime, timedelta, UTC
|
||||
from time import sleep
|
||||
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models import EscrowCreate, EscrowFinish
|
||||
from xrpl.models.requests import Ledger
|
||||
from xrpl.transaction import submit_and_wait
|
||||
from xrpl.utils import datetime_to_ripple_time, ripple_time_to_datetime
|
||||
from xrpl.wallet import generate_faucet_wallet
|
||||
|
||||
# Set up client and get a wallet
|
||||
client = JsonRpcClient("https://s.altnet.rippletest.net:51234")
|
||||
print("Funding new wallet from faucet...")
|
||||
wallet = generate_faucet_wallet(client, debug=True)
|
||||
# destination_address = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" # Testnet faucet
|
||||
# Alternative: Get another account to send the escrow to. Use this if you get
|
||||
# a tecDIR_FULL error trying to create escrows to the Testnet faucet.
|
||||
destination_address = generate_faucet_wallet(client, debug=True).address
|
||||
|
||||
# Set the escrow finish time ------------------------------------------------
|
||||
delay = 30
|
||||
finish_after = datetime.now(tz=UTC) + timedelta(seconds=delay)
|
||||
print("This escrow will mature after", finish_after)
|
||||
finish_after_rippletime = datetime_to_ripple_time(finish_after)
|
||||
|
||||
# Send EscrowCreate transaction ---------------------------------------------
|
||||
escrow_create = EscrowCreate(
|
||||
account=wallet.address,
|
||||
destination=destination_address,
|
||||
amount="123456", # drops of XRP
|
||||
finish_after=finish_after_rippletime
|
||||
)
|
||||
|
||||
print("Signing and submitting the EscrowCreate transaction.")
|
||||
response = submit_and_wait(escrow_create, client, wallet, autofill=True)
|
||||
print(json.dumps(response.result, indent=2))
|
||||
|
||||
# Check result of submitting ------------------------------------------------
|
||||
result_code = response.result["meta"]["TransactionResult"]
|
||||
if result_code != "tesSUCCESS":
|
||||
print(f"EscrowCreate failed with result code {result_code}")
|
||||
exit(1)
|
||||
|
||||
# Save the sequence number so you can identify the escrow later
|
||||
escrow_seq = response.result["tx_json"]["Sequence"]
|
||||
print(f"Escrow sequence is {escrow_seq}.")
|
||||
|
||||
# Wait for the escrow to be finishable --------------------------------------
|
||||
sleep(delay)
|
||||
|
||||
# Check if escrow can be finished -------------------------------------------
|
||||
escrow_ready = False
|
||||
while not escrow_ready:
|
||||
validated_ledger = client.request(Ledger(ledger_index="validated"))
|
||||
ledger_close_time = validated_ledger.result["ledger"]["close_time"]
|
||||
print("Latest validated ledger closed at",
|
||||
ripple_time_to_datetime(ledger_close_time)
|
||||
)
|
||||
if ledger_close_time > finish_after_rippletime:
|
||||
escrow_ready = True
|
||||
print("Escrow is mature.")
|
||||
else:
|
||||
time_difference = finish_after_rippletime - ledger_close_time
|
||||
if time_difference == 0:
|
||||
time_difference = 1
|
||||
print(f"Waiting another {time_difference} seconds.")
|
||||
sleep(time_difference)
|
||||
|
||||
|
||||
# Send EscrowFinish transaction ---------------------------------------------
|
||||
escrow_finish = EscrowFinish(
|
||||
account=wallet.address,
|
||||
owner=wallet.address,
|
||||
offer_sequence=escrow_seq
|
||||
)
|
||||
print("Signing and submitting the EscrowFinish transaction.")
|
||||
response2 = submit_and_wait(escrow_finish, client, wallet, autofill=True)
|
||||
print(json.dumps(response2.result, indent=2))
|
||||
|
||||
result_code = response2.result["meta"]["TransactionResult"]
|
||||
if result_code != "tesSUCCESS":
|
||||
print(f"EscrowFinish failed with result code {result_code}")
|
||||
exit(1)
|
||||
|
||||
print("Escrow finished successfully.")
|
||||
3
_code-samples/lending-protocol/README.md
Normal file
3
_code-samples/lending-protocol/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Lending Protocol Examples
|
||||
|
||||
Code samples showing how to create a loan broker, claw back first-loss capital, deposit and withdraw first-loss capital, create a loan, manage a loan, and repay a loan.
|
||||
394
_code-samples/lending-protocol/js/README.md
Normal file
394
_code-samples/lending-protocol/js/README.md
Normal file
@@ -0,0 +1,394 @@
|
||||
# Lending Protocol Examples (JavaScript)
|
||||
|
||||
This directory contains JavaScript examples demonstrating how to create a loan broker, claw back first-loss capital, deposit and withdraw first-loss capital, create a loan, manage a loan, and repay a loan.
|
||||
|
||||
## Setup
|
||||
|
||||
Install dependencies before running any examples:
|
||||
|
||||
```sh
|
||||
npm i
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Create a Loan Broker
|
||||
|
||||
```sh
|
||||
node createLoanBroker.js
|
||||
```
|
||||
|
||||
The script should output the LoanBrokerSet transaction, loan broker ID, and loan broker pseudo-account:
|
||||
|
||||
```sh
|
||||
Loan broker/vault owner address: rKL3u76wNGdF2Th4EvCuHV5885T6h2iFTY
|
||||
Vault ID: 33E51DD0333775E37F2CC1EB0DA788F9C663AF919DC23ED595A8D69330E5CD68
|
||||
|
||||
=== Preparing LoanBrokerSet transaction ===
|
||||
|
||||
{
|
||||
"TransactionType": "LoanBrokerSet",
|
||||
"Account": "rKL3u76wNGdF2Th4EvCuHV5885T6h2iFTY",
|
||||
"VaultID": "33E51DD0333775E37F2CC1EB0DA788F9C663AF919DC23ED595A8D69330E5CD68",
|
||||
"ManagementFeeRate": 1000
|
||||
}
|
||||
|
||||
=== Submitting LoanBrokerSet transaction ===
|
||||
|
||||
Loan broker created successfully!
|
||||
|
||||
=== Loan Broker Information ===
|
||||
|
||||
LoanBroker ID: 0AA13C8A8E95D8F2D9EF1FA1B15EF4668EF779A678D1D24D099C532E126E8BBF
|
||||
LoanBroker Psuedo-Account Address: rfhftuQGpqUVRcERZbY9htJshijKur7dS4
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Claw Back First-loss Capital
|
||||
|
||||
```sh
|
||||
node coverClawback.js
|
||||
```
|
||||
|
||||
The script should output the cover available, the LoanBrokerCoverDeposit transaction, cover available after the deposit, the LoanBrokerCoverClawback transaction, and the final cover available after the clawback:
|
||||
|
||||
```sh
|
||||
Loan broker address: r9tQSk5rQdjjVGn1brt8K5XNYFvNSLv3xU
|
||||
MPT issuer address: rJ7DiJdcThwLD5rZjC7D1neXmvLFAGk9t3
|
||||
LoanBrokerID: 655C32ADFCA0712F3CB32CA034C29FE3DE9DE876A86141F0902FB1E05DA0E442
|
||||
MPT ID: 00349F41BFA01892C83AC779E4BBB80C8CE3B92D401E4B6E
|
||||
|
||||
=== Cover Available ===
|
||||
|
||||
0 TSTUSD
|
||||
|
||||
=== Preparing LoanBrokerCoverDeposit transaction ===
|
||||
|
||||
{
|
||||
"TransactionType": "LoanBrokerCoverDeposit",
|
||||
"Account": "r9tQSk5rQdjjVGn1brt8K5XNYFvNSLv3xU",
|
||||
"LoanBrokerID": "655C32ADFCA0712F3CB32CA034C29FE3DE9DE876A86141F0902FB1E05DA0E442",
|
||||
"Amount": {
|
||||
"mpt_issuance_id": "00349F41BFA01892C83AC779E4BBB80C8CE3B92D401E4B6E",
|
||||
"value": "1000"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting LoanBrokerCoverDeposit transaction ===
|
||||
|
||||
Cover deposit successful!
|
||||
|
||||
=== Cover Available After Deposit ===
|
||||
|
||||
1000 TSTUSD
|
||||
|
||||
=== Verifying Asset Issuer ===
|
||||
|
||||
MPT issuer account verified: rJ7DiJdcThwLD5rZjC7D1neXmvLFAGk9t3. Proceeding to clawback.
|
||||
|
||||
=== Preparing LoanBrokerCoverClawback transaction ===
|
||||
|
||||
{
|
||||
"TransactionType": "LoanBrokerCoverClawback",
|
||||
"Account": "rJ7DiJdcThwLD5rZjC7D1neXmvLFAGk9t3",
|
||||
"LoanBrokerID": "655C32ADFCA0712F3CB32CA034C29FE3DE9DE876A86141F0902FB1E05DA0E442",
|
||||
"Amount": {
|
||||
"mpt_issuance_id": "00349F41BFA01892C83AC779E4BBB80C8CE3B92D401E4B6E",
|
||||
"value": "1000"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting LoanBrokerCoverClawback transaction ===
|
||||
|
||||
Successfully clawed back 1000 TSTUSD!
|
||||
|
||||
=== Final Cover Available After Clawback ===
|
||||
|
||||
0 TSTUSD
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Deposit and Withdraw First-loss Capital
|
||||
|
||||
```sh
|
||||
node coverDepositAndWithdraw.js
|
||||
```
|
||||
|
||||
The script should output the LoanBrokerCoverDeposit, cover balance after the deposit, the LoanBrokerCoverWithdraw transaction, and the cover balance after the withdrawal:
|
||||
|
||||
```sh
|
||||
Loan broker address: rKL3u76wNGdF2Th4EvCuHV5885T6h2iFTY
|
||||
LoanBrokerID: F133118D55342F7F78188BDC9259E8593853010878C9F6CEA0E2F56D829C6B15
|
||||
MPT ID: 0031034FF84EB2E8348A34F0A8889A54F45F180E80F12341
|
||||
|
||||
=== Preparing LoanBrokerCoverDeposit transaction ===
|
||||
|
||||
{
|
||||
"TransactionType": "LoanBrokerCoverDeposit",
|
||||
"Account": "rKL3u76wNGdF2Th4EvCuHV5885T6h2iFTY",
|
||||
"LoanBrokerID": "F133118D55342F7F78188BDC9259E8593853010878C9F6CEA0E2F56D829C6B15",
|
||||
"Amount": {
|
||||
"mpt_issuance_id": "0031034FF84EB2E8348A34F0A8889A54F45F180E80F12341",
|
||||
"value": "2000"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting LoanBrokerCoverDeposit transaction ===
|
||||
|
||||
Cover deposit successful!
|
||||
|
||||
=== Cover Balance ===
|
||||
|
||||
LoanBroker Pseudo-Account: rf5FREUsutDyDAaVPPvZnNmoEETr21sPDd
|
||||
Cover balance after deposit: 2000 TSTUSD
|
||||
|
||||
=== Preparing LoanBrokerCoverWithdraw transaction ===
|
||||
|
||||
{
|
||||
"TransactionType": "LoanBrokerCoverWithdraw",
|
||||
"Account": "rKL3u76wNGdF2Th4EvCuHV5885T6h2iFTY",
|
||||
"LoanBrokerID": "F133118D55342F7F78188BDC9259E8593853010878C9F6CEA0E2F56D829C6B15",
|
||||
"Amount": {
|
||||
"mpt_issuance_id": "0031034FF84EB2E8348A34F0A8889A54F45F180E80F12341",
|
||||
"value": "1000"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting LoanBrokerCoverWithdraw transaction ===
|
||||
|
||||
Cover withdraw successful!
|
||||
|
||||
=== Updated Cover Balance ===
|
||||
|
||||
LoanBroker Pseudo-Account: rf5FREUsutDyDAaVPPvZnNmoEETr21sPDd
|
||||
Cover balance after withdraw: 1000 TSTUSD
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Create a Loan
|
||||
|
||||
```sh
|
||||
node createLoan.js
|
||||
```
|
||||
|
||||
The script should output the LoanSet transaction, the updated LoanSet transaction with the loan broker signature, the final LoanSet transaction with the borrower signature added, and then the loan information:
|
||||
|
||||
```sh
|
||||
Loan broker address: rKL3u76wNGdF2Th4EvCuHV5885T6h2iFTY
|
||||
Borrower address: r46Ef5jjnaY7CDP7g22sQgSJJPQEBSmbWA
|
||||
LoanBrokerID: F133118D55342F7F78188BDC9259E8593853010878C9F6CEA0E2F56D829C6B15
|
||||
|
||||
=== Preparing LoanSet transaction ===
|
||||
|
||||
{
|
||||
"TransactionType": "LoanSet",
|
||||
"Account": "rKL3u76wNGdF2Th4EvCuHV5885T6h2iFTY",
|
||||
"Counterparty": "r46Ef5jjnaY7CDP7g22sQgSJJPQEBSmbWA",
|
||||
"LoanBrokerID": "F133118D55342F7F78188BDC9259E8593853010878C9F6CEA0E2F56D829C6B15",
|
||||
"PrincipalRequested": 1000,
|
||||
"InterestRate": 500,
|
||||
"PaymentTotal": 12,
|
||||
"PaymentInterval": 2592000,
|
||||
"GracePeriod": 604800,
|
||||
"LoanOriginationFee": 100,
|
||||
"LoanServiceFee": 10,
|
||||
"Flags": 0,
|
||||
"Sequence": 3212122,
|
||||
"LastLedgerSequence": 3212233,
|
||||
"Fee": "2"
|
||||
}
|
||||
|
||||
=== Adding loan broker signature ===
|
||||
|
||||
TxnSignature: 44348B918E780608534A9499B9990470E6A3C8E5C7DAC33BF2A5EFA0C292D17B3267D3A177A363CC832D6C6DA36E41CB64909C39CA5D55CF36D232DA49022400
|
||||
SigningPubKey: ED37EF81218C3C97389A11F07C8339C2880CEAF1A8C6EB539C616D69EF5EBC688C
|
||||
|
||||
Signed loanSetTx for borrower to sign over:
|
||||
{
|
||||
"Account": "rKL3u76wNGdF2Th4EvCuHV5885T6h2iFTY",
|
||||
"Counterparty": "r46Ef5jjnaY7CDP7g22sQgSJJPQEBSmbWA",
|
||||
"Fee": "2",
|
||||
"Flags": 0,
|
||||
"GracePeriod": 604800,
|
||||
"InterestRate": 500,
|
||||
"LastLedgerSequence": 3212233,
|
||||
"LoanBrokerID": "F133118D55342F7F78188BDC9259E8593853010878C9F6CEA0E2F56D829C6B15",
|
||||
"LoanOriginationFee": "100",
|
||||
"LoanServiceFee": "10",
|
||||
"PaymentInterval": 2592000,
|
||||
"PaymentTotal": 12,
|
||||
"PrincipalRequested": "1000",
|
||||
"Sequence": 3212122,
|
||||
"SigningPubKey": "ED37EF81218C3C97389A11F07C8339C2880CEAF1A8C6EB539C616D69EF5EBC688C",
|
||||
"TransactionType": "LoanSet",
|
||||
"TxnSignature": "44348B918E780608534A9499B9990470E6A3C8E5C7DAC33BF2A5EFA0C292D17B3267D3A177A363CC832D6C6DA36E41CB64909C39CA5D55CF36D232DA49022400"
|
||||
}
|
||||
|
||||
=== Adding borrower signature ===
|
||||
|
||||
Borrower TxnSignature: 2D17F5BAED2540CD875B009A99B02649E24A5DCDFDC5BAFCB2DC41F998FE4AFBDD6BDF8BDF1C3C857ED8DD638F10BEA10295812155D9759E3ADED9D6208F150F
|
||||
Borrower SigningPubKey: ED4C7C0127EFEAFD04B2CDFA1CA3A8EF5933227C610031DF2130010B73CBBBDCDA
|
||||
|
||||
Fully signed LoanSet transaction:
|
||||
{
|
||||
"Account": "rKL3u76wNGdF2Th4EvCuHV5885T6h2iFTY",
|
||||
"Counterparty": "r46Ef5jjnaY7CDP7g22sQgSJJPQEBSmbWA",
|
||||
"CounterpartySignature": {
|
||||
"SigningPubKey": "ED4C7C0127EFEAFD04B2CDFA1CA3A8EF5933227C610031DF2130010B73CBBBDCDA",
|
||||
"TxnSignature": "2D17F5BAED2540CD875B009A99B02649E24A5DCDFDC5BAFCB2DC41F998FE4AFBDD6BDF8BDF1C3C857ED8DD638F10BEA10295812155D9759E3ADED9D6208F150F"
|
||||
},
|
||||
"Fee": "2",
|
||||
"Flags": 0,
|
||||
"GracePeriod": 604800,
|
||||
"InterestRate": 500,
|
||||
"LastLedgerSequence": 3212233,
|
||||
"LoanBrokerID": "F133118D55342F7F78188BDC9259E8593853010878C9F6CEA0E2F56D829C6B15",
|
||||
"LoanOriginationFee": "100",
|
||||
"LoanServiceFee": "10",
|
||||
"PaymentInterval": 2592000,
|
||||
"PaymentTotal": 12,
|
||||
"PrincipalRequested": "1000",
|
||||
"Sequence": 3212122,
|
||||
"SigningPubKey": "ED37EF81218C3C97389A11F07C8339C2880CEAF1A8C6EB539C616D69EF5EBC688C",
|
||||
"TransactionType": "LoanSet",
|
||||
"TxnSignature": "44348B918E780608534A9499B9990470E6A3C8E5C7DAC33BF2A5EFA0C292D17B3267D3A177A363CC832D6C6DA36E41CB64909C39CA5D55CF36D232DA49022400"
|
||||
}
|
||||
|
||||
=== Submitting signed LoanSet transaction ===
|
||||
|
||||
Loan created successfully!
|
||||
|
||||
=== Loan Information ===
|
||||
|
||||
{
|
||||
"Borrower": "r46Ef5jjnaY7CDP7g22sQgSJJPQEBSmbWA",
|
||||
"GracePeriod": 604800,
|
||||
"InterestRate": 500,
|
||||
"LoanBrokerID": "F133118D55342F7F78188BDC9259E8593853010878C9F6CEA0E2F56D829C6B15",
|
||||
"LoanOriginationFee": "100",
|
||||
"LoanSequence": 3,
|
||||
"LoanServiceFee": "10",
|
||||
"NextPaymentDueDate": 825408182,
|
||||
"PaymentInterval": 2592000,
|
||||
"PaymentRemaining": 12,
|
||||
"PeriodicPayment": "83.55610375293148956",
|
||||
"PrincipalOutstanding": "1000",
|
||||
"StartDate": 822816182,
|
||||
"TotalValueOutstanding": "1003"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Manage a Loan
|
||||
|
||||
```sh
|
||||
node loanManage.js
|
||||
```
|
||||
|
||||
The script should output the initial status of the loan, the LoanManage transaction, and the updated loan status and grace period after impairment. The script will countdown the grace period before outputting another LoanManage transaction, and then the final flags on the loan.
|
||||
|
||||
```sh
|
||||
Loan broker address: rKL3u76wNGdF2Th4EvCuHV5885T6h2iFTY
|
||||
LoanID: D28764B238CF3F7D7BF4AFD07394838EDD5F278B838F97A55BEAEC1E5152719C
|
||||
|
||||
=== Loan Status ===
|
||||
|
||||
Total Amount Owed: 1001 TSTUSD.
|
||||
Payment Due Date: 2/25/2026, 11:58:20 PM
|
||||
|
||||
=== Preparing LoanManage transaction to impair loan ===
|
||||
|
||||
{
|
||||
"TransactionType": "LoanManage",
|
||||
"Account": "rKL3u76wNGdF2Th4EvCuHV5885T6h2iFTY",
|
||||
"LoanID": "D28764B238CF3F7D7BF4AFD07394838EDD5F278B838F97A55BEAEC1E5152719C",
|
||||
"Flags": 131072
|
||||
}
|
||||
|
||||
=== Submitting LoanManage impairment transaction ===
|
||||
|
||||
Loan impaired successfully!
|
||||
New Payment Due Date: 1/27/2026, 12:05:02 AM
|
||||
Grace Period: 60 seconds
|
||||
|
||||
=== Countdown until loan can be defaulted ===
|
||||
|
||||
Grace period expired. Loan can now be defaulted.
|
||||
|
||||
=== Preparing LoanManage transaction to default loan ===
|
||||
|
||||
{
|
||||
"TransactionType": "LoanManage",
|
||||
"Account": "rKL3u76wNGdF2Th4EvCuHV5885T6h2iFTY",
|
||||
"LoanID": "D28764B238CF3F7D7BF4AFD07394838EDD5F278B838F97A55BEAEC1E5152719C",
|
||||
"Flags": 65536
|
||||
}
|
||||
|
||||
=== Submitting LoanManage default transaction ===
|
||||
|
||||
Loan defaulted successfully!
|
||||
|
||||
=== Checking final loan status ===
|
||||
|
||||
Final loan flags (parsed): {"tfLoanDefault":true,"tfLoanImpair":true}
|
||||
```
|
||||
|
||||
## Pay a Loan
|
||||
|
||||
```sh
|
||||
node loanPay.js
|
||||
```
|
||||
|
||||
The script should output the amount required to totally pay off a loan, the LoanPay transaction, the amount due after the payment, the LoanDelete transaction, and then the status of the loan ledger entry:
|
||||
|
||||
```sh
|
||||
Borrower address: r46Ef5jjnaY7CDP7g22sQgSJJPQEBSmbWA
|
||||
LoanID: 8AC2B4425E604E7BB1082DD2BF2CA902B5087143B7775BE0A4DA954D3F52D06E
|
||||
MPT ID: 0031034FF84EB2E8348A34F0A8889A54F45F180E80F12341
|
||||
|
||||
=== Loan Status ===
|
||||
|
||||
Amount Owed: 1001 TSTUSD
|
||||
Loan Service Fee: 10 TSTUSD
|
||||
Total Payment Due (including fees): 1011 TSTUSD
|
||||
|
||||
=== Preparing LoanPay transaction ===
|
||||
|
||||
{
|
||||
"TransactionType": "LoanPay",
|
||||
"Account": "r46Ef5jjnaY7CDP7g22sQgSJJPQEBSmbWA",
|
||||
"LoanID": "8AC2B4425E604E7BB1082DD2BF2CA902B5087143B7775BE0A4DA954D3F52D06E",
|
||||
"Amount": {
|
||||
"mpt_issuance_id": "0031034FF84EB2E8348A34F0A8889A54F45F180E80F12341",
|
||||
"value": "1011"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting LoanPay transaction ===
|
||||
|
||||
Loan paid successfully!
|
||||
|
||||
=== Loan Status After Payment ===
|
||||
|
||||
Outstanding Loan Balance: Loan fully paid off!
|
||||
|
||||
=== Preparing LoanDelete transaction ===
|
||||
|
||||
{
|
||||
"TransactionType": "LoanDelete",
|
||||
"Account": "r46Ef5jjnaY7CDP7g22sQgSJJPQEBSmbWA",
|
||||
"LoanID": "8AC2B4425E604E7BB1082DD2BF2CA902B5087143B7775BE0A4DA954D3F52D06E"
|
||||
}
|
||||
|
||||
=== Submitting LoanDelete transaction ===
|
||||
|
||||
Loan deleted successfully!
|
||||
|
||||
=== Verifying Loan Deletion ===
|
||||
|
||||
Loan has been successfully removed from the XRP Ledger!
|
||||
```
|
||||
143
_code-samples/lending-protocol/js/coverClawback.js
Normal file
143
_code-samples/lending-protocol/js/coverClawback.js
Normal file
@@ -0,0 +1,143 @@
|
||||
// IMPORTANT: This example deposits and claws back first-loss capital from a
|
||||
// preconfigured LoanBroker entry. The first-loss capital is an MPT
|
||||
// with clawback enabled.
|
||||
|
||||
import fs from 'fs'
|
||||
import { execSync } from 'child_process'
|
||||
import xrpl from 'xrpl'
|
||||
|
||||
// Connect to the network ----------------------
|
||||
const client = new xrpl.Client('wss://s.devnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
// This step checks for the necessary setup data to run the lending protocol tutorials.
|
||||
// If missing, lendingSetup.js will generate the data.
|
||||
if (!fs.existsSync('lendingSetup.json')) {
|
||||
console.log(`\n=== Lending tutorial data doesn't exist. Running setup script... ===\n`)
|
||||
execSync('node lendingSetup.js', { stdio: 'inherit' })
|
||||
}
|
||||
|
||||
// Load preconfigured accounts and LoanBrokerID.
|
||||
const setupData = JSON.parse(fs.readFileSync('lendingSetup.json', 'utf8'))
|
||||
|
||||
// You can replace these values with your own
|
||||
const loanBroker = xrpl.Wallet.fromSeed(setupData.loanBroker.seed)
|
||||
const mptIssuer = xrpl.Wallet.fromSeed(setupData.depositor.seed)
|
||||
const loanBrokerID = setupData.loanBrokerID
|
||||
const mptID = setupData.mptID
|
||||
|
||||
console.log(`\nLoan broker address: ${loanBroker.address}`)
|
||||
console.log(`MPT issuer address: ${mptIssuer.address}`)
|
||||
console.log(`LoanBrokerID: ${loanBrokerID}`)
|
||||
console.log(`MPT ID: ${mptID}`)
|
||||
|
||||
// Check cover available ----------------------
|
||||
console.log(`\n=== Cover Available ===\n`)
|
||||
const coverInfo = await client.request({
|
||||
command: 'ledger_entry',
|
||||
index: loanBrokerID,
|
||||
ledger_index: 'validated'
|
||||
})
|
||||
|
||||
let currentCoverAvailable = coverInfo.result.node.CoverAvailable || '0'
|
||||
console.log(`${currentCoverAvailable} TSTUSD`)
|
||||
|
||||
// Prepare LoanBrokerCoverDeposit transaction ----------------------
|
||||
console.log(`\n=== Preparing LoanBrokerCoverDeposit transaction ===\n`)
|
||||
const coverDepositTx = {
|
||||
TransactionType: 'LoanBrokerCoverDeposit',
|
||||
Account: loanBroker.address,
|
||||
LoanBrokerID: loanBrokerID,
|
||||
Amount: {
|
||||
mpt_issuance_id: mptID,
|
||||
value: '1000'
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the transaction structure before submitting
|
||||
xrpl.validate(coverDepositTx)
|
||||
console.log(JSON.stringify(coverDepositTx, null, 2))
|
||||
|
||||
// Sign, submit, and wait for deposit validation ----------------------
|
||||
console.log(`\n=== Submitting LoanBrokerCoverDeposit transaction ===\n`)
|
||||
const depositResponse = await client.submitAndWait(coverDepositTx, {
|
||||
wallet: loanBroker,
|
||||
autofill: true
|
||||
})
|
||||
|
||||
if (depositResponse.result.meta.TransactionResult !== 'tesSUCCESS') {
|
||||
const resultCode = depositResponse.result.meta.TransactionResult
|
||||
console.error('Error: Unable to deposit cover:', resultCode)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('Cover deposit successful!')
|
||||
|
||||
// Extract updated cover available after deposit ----------------------
|
||||
console.log(`\n=== Cover Available After Deposit ===\n`)
|
||||
let loanBrokerNode = depositResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.ModifiedNode?.LedgerEntryType === 'LoanBroker'
|
||||
)
|
||||
|
||||
currentCoverAvailable = loanBrokerNode.ModifiedNode.FinalFields.CoverAvailable
|
||||
console.log(`${currentCoverAvailable} TSTUSD`)
|
||||
|
||||
// Verify issuer of cover asset matches ----------------------
|
||||
// Only the issuer of the asset can submit clawback transactions.
|
||||
// The asset must also have clawback enabled.
|
||||
console.log(`\n=== Verifying Asset Issuer ===\n`)
|
||||
const assetIssuerInfo = await client.request({
|
||||
command: 'ledger_entry',
|
||||
mpt_issuance: mptID,
|
||||
ledger_index: 'validated'
|
||||
})
|
||||
|
||||
if (assetIssuerInfo.result.node.Issuer !== mptIssuer.address) {
|
||||
console.error(`Error: ${assetIssuerInfo.result.node.Issuer} does not match account (${mptIssuer.address}) attempting clawback!`)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log(`MPT issuer account verified: ${mptIssuer.address}. Proceeding to clawback.`)
|
||||
|
||||
// Prepare LoanBrokerCoverClawback transaction ----------------------
|
||||
console.log(`\n=== Preparing LoanBrokerCoverClawback transaction ===\n`)
|
||||
const coverClawbackTx = {
|
||||
TransactionType: 'LoanBrokerCoverClawback',
|
||||
Account: mptIssuer.address,
|
||||
LoanBrokerID: loanBrokerID,
|
||||
Amount: {
|
||||
mpt_issuance_id: mptID,
|
||||
value: currentCoverAvailable
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the transaction structure before submitting
|
||||
xrpl.validate(coverClawbackTx)
|
||||
console.log(JSON.stringify(coverClawbackTx, null, 2))
|
||||
|
||||
// Sign, submit, and wait for clawback validation ----------------------
|
||||
console.log(`\n=== Submitting LoanBrokerCoverClawback transaction ===\n`)
|
||||
const clawbackResponse = await client.submitAndWait(coverClawbackTx, {
|
||||
wallet: mptIssuer,
|
||||
autofill: true
|
||||
})
|
||||
|
||||
if (clawbackResponse.result.meta.TransactionResult !== 'tesSUCCESS') {
|
||||
const resultCode = clawbackResponse.result.meta.TransactionResult
|
||||
console.error('Error: Unable to clawback cover:', resultCode)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log(`Successfully clawed back ${currentCoverAvailable} TSTUSD!`)
|
||||
|
||||
// Extract final cover available ----------------------
|
||||
console.log(`\n=== Final Cover Available After Clawback ===\n`)
|
||||
loanBrokerNode = clawbackResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.ModifiedNode?.LedgerEntryType === 'LoanBroker'
|
||||
)
|
||||
|
||||
console.log(`${loanBrokerNode.ModifiedNode.FinalFields.CoverAvailable || '0'} TSTUSD`)
|
||||
|
||||
await client.disconnect()
|
||||
108
_code-samples/lending-protocol/js/coverDepositAndWithdraw.js
Normal file
108
_code-samples/lending-protocol/js/coverDepositAndWithdraw.js
Normal file
@@ -0,0 +1,108 @@
|
||||
// IMPORTANT: This example deposits and withdraws first-loss capital from a
|
||||
// preconfigured LoanBroker entry.
|
||||
|
||||
import fs from 'fs'
|
||||
import { execSync } from 'child_process'
|
||||
import xrpl from 'xrpl'
|
||||
|
||||
// Connect to the network ----------------------
|
||||
const client = new xrpl.Client('wss://s.devnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
// This step checks for the necessary setup data to run the lending protocol tutorials.
|
||||
// If missing, lendingSetup.js will generate the data.
|
||||
if (!fs.existsSync('lendingSetup.json')) {
|
||||
console.log(`\n=== Lending tutorial data doesn't exist. Running setup script... ===\n`)
|
||||
execSync('node lendingSetup.js', { stdio: 'inherit' })
|
||||
}
|
||||
|
||||
// Load preconfigured accounts and LoanBrokerID.
|
||||
const setupData = JSON.parse(fs.readFileSync('lendingSetup.json', 'utf8'))
|
||||
|
||||
// You can replace these values with your own
|
||||
const loanBroker = xrpl.Wallet.fromSeed(setupData.loanBroker.seed)
|
||||
const loanBrokerID = setupData.loanBrokerID
|
||||
const mptID = setupData.mptID
|
||||
|
||||
console.log(`\nLoan broker address: ${loanBroker.address}`)
|
||||
console.log(`LoanBrokerID: ${loanBrokerID}`)
|
||||
console.log(`MPT ID: ${mptID}`)
|
||||
|
||||
// Prepare LoanBrokerCoverDeposit transaction ----------------------
|
||||
console.log(`\n=== Preparing LoanBrokerCoverDeposit transaction ===\n`)
|
||||
const coverDepositTx = {
|
||||
TransactionType: 'LoanBrokerCoverDeposit',
|
||||
Account: loanBroker.address,
|
||||
LoanBrokerID: loanBrokerID,
|
||||
Amount: {
|
||||
mpt_issuance_id: mptID,
|
||||
value: '2000'
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the transaction structure before submitting
|
||||
xrpl.validate(coverDepositTx)
|
||||
console.log(JSON.stringify(coverDepositTx, null, 2))
|
||||
|
||||
// Sign, submit, and wait for deposit validation ----------------------
|
||||
console.log(`\n=== Submitting LoanBrokerCoverDeposit transaction ===\n`)
|
||||
const depositResponse = await client.submitAndWait(coverDepositTx, {
|
||||
wallet: loanBroker,
|
||||
autofill: true
|
||||
})
|
||||
if (depositResponse.result.meta.TransactionResult !== 'tesSUCCESS') {
|
||||
const resultCode = depositResponse.result.meta.TransactionResult
|
||||
console.error('Error: Unable to deposit cover:', resultCode)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('Cover deposit successful!')
|
||||
|
||||
// Extract cover balance from the transaction result
|
||||
console.log(`\n=== Cover Balance ===\n`)
|
||||
let loanBrokerNode = depositResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.ModifiedNode?.LedgerEntryType === 'LoanBroker'
|
||||
)
|
||||
// First-loss capital is stored in the LoanBroker's pseudo-account.
|
||||
console.log(`LoanBroker Pseudo-Account: ${loanBrokerNode.ModifiedNode.FinalFields.Account}`)
|
||||
console.log(`Cover balance after deposit: ${loanBrokerNode.ModifiedNode.FinalFields.CoverAvailable} TSTUSD`)
|
||||
|
||||
// Prepare LoanBrokerCoverWithdraw transaction ----------------------
|
||||
console.log(`\n=== Preparing LoanBrokerCoverWithdraw transaction ===\n`)
|
||||
const coverWithdrawTx = {
|
||||
TransactionType: 'LoanBrokerCoverWithdraw',
|
||||
Account: loanBroker.address,
|
||||
LoanBrokerID: loanBrokerID,
|
||||
Amount: {
|
||||
mpt_issuance_id: mptID,
|
||||
value: '1000'
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the transaction structure before submitting
|
||||
xrpl.validate(coverWithdrawTx)
|
||||
console.log(JSON.stringify(coverWithdrawTx, null, 2))
|
||||
|
||||
// Sign, submit, and wait for withdraw validation ----------------------
|
||||
console.log(`\n=== Submitting LoanBrokerCoverWithdraw transaction ===\n`)
|
||||
const withdrawResponse = await client.submitAndWait(coverWithdrawTx, {
|
||||
wallet: loanBroker,
|
||||
autofill: true
|
||||
})
|
||||
if (withdrawResponse.result.meta.TransactionResult !== 'tesSUCCESS') {
|
||||
const resultCode = withdrawResponse.result.meta.TransactionResult
|
||||
console.error('Error: Unable to withdraw cover:', resultCode)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('Cover withdraw successful!')
|
||||
|
||||
// Extract updated cover balance from the transaction result
|
||||
console.log(`\n=== Updated Cover Balance ===\n`)
|
||||
loanBrokerNode = withdrawResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.ModifiedNode?.LedgerEntryType === 'LoanBroker'
|
||||
)
|
||||
console.log(`LoanBroker Pseudo-Account: ${loanBrokerNode.ModifiedNode.FinalFields.Account}`)
|
||||
console.log(`Cover balance after withdraw: ${loanBrokerNode.ModifiedNode.FinalFields.CoverAvailable} TSTUSD`)
|
||||
|
||||
await client.disconnect()
|
||||
130
_code-samples/lending-protocol/js/createLoan.js
Normal file
130
_code-samples/lending-protocol/js/createLoan.js
Normal file
@@ -0,0 +1,130 @@
|
||||
// IMPORTANT: This example creates a loan using a preconfigured
|
||||
// loan broker, borrower, and private vault.
|
||||
|
||||
import fs from 'fs'
|
||||
import { execSync } from 'child_process'
|
||||
import xrpl from 'xrpl'
|
||||
|
||||
// Connect to the network ----------------------
|
||||
const client = new xrpl.Client('wss://s.devnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
// This step checks for the necessary setup data to run the lending protocol tutorials.
|
||||
// If missing, lendingSetup.js will generate the data.
|
||||
if (!fs.existsSync('lendingSetup.json')) {
|
||||
console.log(`\n=== Lending tutorial data doesn't exist. Running setup script... ===\n`)
|
||||
execSync('node lendingSetup.js', { stdio: 'inherit' })
|
||||
}
|
||||
|
||||
// Load preconfigured accounts and LoanBrokerID.
|
||||
const setupData = JSON.parse(fs.readFileSync('lendingSetup.json', 'utf8'))
|
||||
|
||||
// You can replace these values with your own
|
||||
const loanBroker = xrpl.Wallet.fromSeed(setupData.loanBroker.seed)
|
||||
const borrower = xrpl.Wallet.fromSeed(setupData.borrower.seed)
|
||||
const loanBrokerID = setupData.loanBrokerID
|
||||
|
||||
console.log(`\nLoan broker address: ${loanBroker.address}`)
|
||||
console.log(`Borrower address: ${borrower.address}`)
|
||||
console.log(`LoanBrokerID: ${loanBrokerID}`)
|
||||
|
||||
// Prepare LoanSet transaction ----------------------
|
||||
// Account and Counterparty accounts can be swapped, but determines signing order.
|
||||
// Account signs first, Counterparty signs second.
|
||||
console.log(`\n=== Preparing LoanSet transaction ===\n`)
|
||||
|
||||
// Suppress unnecessary console warning from autofilling LoanSet.
|
||||
console.warn = () => {}
|
||||
|
||||
const loanSetTx = await client.autofill({
|
||||
TransactionType: 'LoanSet',
|
||||
Account: loanBroker.address,
|
||||
Counterparty: borrower.address,
|
||||
LoanBrokerID: loanBrokerID,
|
||||
PrincipalRequested: 1000,
|
||||
InterestRate: 500,
|
||||
PaymentTotal: 12,
|
||||
PaymentInterval: 2592000,
|
||||
GracePeriod: 604800,
|
||||
LoanOriginationFee: 100,
|
||||
LoanServiceFee: 10
|
||||
})
|
||||
|
||||
console.log(JSON.stringify(loanSetTx, null, 2))
|
||||
|
||||
// Loan broker signs first
|
||||
console.log(`\n=== Adding loan broker signature ===\n`)
|
||||
const loanBrokerSignature = await client.request({
|
||||
command: 'sign',
|
||||
tx_json: loanSetTx,
|
||||
secret: loanBroker.seed
|
||||
})
|
||||
|
||||
const loanBrokerSignatureResult = loanBrokerSignature.result.tx_json
|
||||
|
||||
console.log(`TxnSignature: ${loanBrokerSignatureResult.TxnSignature}`)
|
||||
console.log(`SigningPubKey: ${loanBrokerSignatureResult.SigningPubKey}\n`)
|
||||
console.log(`Signed loanSetTx for borrower to sign over:\n${JSON.stringify(loanBrokerSignatureResult, null, 2)}`)
|
||||
|
||||
// Borrower signs second
|
||||
console.log(`\n=== Adding borrower signature ===\n`)
|
||||
|
||||
const borrowerSignature = await client.request({
|
||||
command: 'sign',
|
||||
tx_json: loanBrokerSignatureResult,
|
||||
secret: borrower.seed,
|
||||
signature_target: 'CounterpartySignature'
|
||||
})
|
||||
|
||||
const borrowerSignatureResult = borrowerSignature.result.tx_json
|
||||
|
||||
console.log(`Borrower TxnSignature: ${borrowerSignatureResult.CounterpartySignature.TxnSignature}`)
|
||||
console.log(`Borrower SigningPubKey: ${borrowerSignatureResult.CounterpartySignature.SigningPubKey}`)
|
||||
|
||||
// Validate the transaction structure before submitting.
|
||||
xrpl.validate(borrowerSignatureResult)
|
||||
console.log(`\nFully signed LoanSet transaction:\n${JSON.stringify(borrowerSignatureResult, null, 2)}`)
|
||||
|
||||
// Submit and wait for validation ----------------------
|
||||
console.log(`\n=== Submitting signed LoanSet transaction ===\n`)
|
||||
|
||||
// Submit the transaction
|
||||
const submitResult = await client.submit(borrowerSignatureResult)
|
||||
const txHash = submitResult.result.tx_json.hash
|
||||
|
||||
// Helper function to check tx hash is validated
|
||||
async function validateTx (hash, maxRetries = 20) {
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
try {
|
||||
const tx = await client.request({ command: 'tx', transaction: hash })
|
||||
if (tx.result.validated) {
|
||||
return tx
|
||||
}
|
||||
} catch (error) {
|
||||
// Transaction not validated yet, check again
|
||||
}
|
||||
}
|
||||
console.error(`Error: Transaction ${hash} not validated after ${maxRetries} attempts.`)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Validate the transaction
|
||||
const submitResponse = await validateTx(txHash)
|
||||
if (submitResponse.result.meta.TransactionResult !== 'tesSUCCESS') {
|
||||
const resultCode = submitResponse.result.meta.TransactionResult
|
||||
console.error('Error: Unable to create loan:', resultCode)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('Loan created successfully!')
|
||||
|
||||
// Extract loan information from the transaction result.
|
||||
console.log(`\n=== Loan Information ===\n`)
|
||||
const loanNode = submitResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.CreatedNode?.LedgerEntryType === 'Loan'
|
||||
)
|
||||
console.log(JSON.stringify(loanNode.CreatedNode.NewFields, null, 2))
|
||||
|
||||
await client.disconnect()
|
||||
66
_code-samples/lending-protocol/js/createLoanBroker.js
Normal file
66
_code-samples/lending-protocol/js/createLoanBroker.js
Normal file
@@ -0,0 +1,66 @@
|
||||
// IMPORTANT: This example creates a loan broker using an existing account
|
||||
// that has already created a PRIVATE vault.
|
||||
// If you want to create a loan broker for a PUBLIC vault, you can replace the vaultID
|
||||
// and loanBroker values with your own.
|
||||
|
||||
import fs from 'fs'
|
||||
import { execSync } from 'child_process'
|
||||
import xrpl from 'xrpl'
|
||||
|
||||
// Connect to the network ----------------------
|
||||
const client = new xrpl.Client('wss://s.devnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
// This step checks for the necessary setup data to run the lending protocol tutorials.
|
||||
// If missing, lendingSetup.js will generate the data.
|
||||
if (!fs.existsSync('lendingSetup.json')) {
|
||||
console.log(`\n=== Lending tutorial data doesn't exist. Running setup script... ===\n`)
|
||||
execSync('node lendingSetup.js', { stdio: 'inherit' })
|
||||
}
|
||||
|
||||
// Load preconfigured accounts and VaultID.
|
||||
const setupData = JSON.parse(fs.readFileSync('lendingSetup.json', 'utf8'))
|
||||
|
||||
// You can replace these values with your own
|
||||
const loanBroker = xrpl.Wallet.fromSeed(setupData.loanBroker.seed)
|
||||
const vaultID = setupData.vaultID
|
||||
|
||||
console.log(`\nLoan broker/vault owner address: ${loanBroker.address}`)
|
||||
console.log(`Vault ID: ${vaultID}`)
|
||||
|
||||
// Prepare LoanBrokerSet transaction ----------------------
|
||||
console.log(`\n=== Preparing LoanBrokerSet transaction ===\n`)
|
||||
const loanBrokerSetTx = {
|
||||
TransactionType: 'LoanBrokerSet',
|
||||
Account: loanBroker.address,
|
||||
VaultID: vaultID,
|
||||
ManagementFeeRate: 1000
|
||||
}
|
||||
|
||||
// Validate the transaction structure before submitting
|
||||
xrpl.validate(loanBrokerSetTx)
|
||||
console.log(JSON.stringify(loanBrokerSetTx, null, 2))
|
||||
|
||||
// Submit, sign, and wait for validation ----------------------
|
||||
console.log(`\n=== Submitting LoanBrokerSet transaction ===\n`)
|
||||
const submitResponse = await client.submitAndWait(loanBrokerSetTx, {
|
||||
wallet: loanBroker,
|
||||
autofill: true
|
||||
})
|
||||
if (submitResponse.result.meta.TransactionResult !== 'tesSUCCESS') {
|
||||
const resultCode = submitResponse.result.meta.TransactionResult
|
||||
console.error('Error: Unable to create loan broker:', resultCode)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('Loan broker created successfully!')
|
||||
|
||||
// Extract loan broker information from the transaction result
|
||||
console.log(`\n=== Loan Broker Information ===\n`)
|
||||
const loanBrokerNode = submitResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.CreatedNode?.LedgerEntryType === 'LoanBroker'
|
||||
)
|
||||
console.log(`LoanBroker ID: ${loanBrokerNode.CreatedNode.LedgerIndex}`)
|
||||
console.log(`LoanBroker Psuedo-Account Address: ${loanBrokerNode.CreatedNode.NewFields.Account}`)
|
||||
|
||||
await client.disconnect()
|
||||
375
_code-samples/lending-protocol/js/lendingSetup.js
Normal file
375
_code-samples/lending-protocol/js/lendingSetup.js
Normal file
@@ -0,0 +1,375 @@
|
||||
import xrpl from 'xrpl'
|
||||
import fs from 'fs'
|
||||
|
||||
// Setup script for lending protocol tutorials
|
||||
|
||||
process.stdout.write('Setting up tutorial: 0/6\r')
|
||||
|
||||
const client = new xrpl.Client('wss://s.devnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
// Create and fund wallets
|
||||
const [
|
||||
{ wallet: loanBroker },
|
||||
{ wallet: borrower },
|
||||
{ wallet: depositor },
|
||||
{ wallet: credentialIssuer }
|
||||
] = await Promise.all([
|
||||
client.fundWallet(),
|
||||
client.fundWallet(),
|
||||
client.fundWallet(),
|
||||
client.fundWallet()
|
||||
])
|
||||
|
||||
process.stdout.write('Setting up tutorial: 1/6\r')
|
||||
|
||||
// Issue MPT with depositor
|
||||
// Create tickets for later use with loanBroker
|
||||
// Set up credentials and domain with credentialIssuer
|
||||
const credentialType = xrpl.convertStringToHex('KYC-Verified')
|
||||
const mptData = {
|
||||
ticker: 'TSTUSD',
|
||||
name: 'Test USD MPT',
|
||||
desc: 'A sample non-yield-bearing stablecoin backed by U.S. Treasuries.',
|
||||
icon: 'https://example.org/tstusd-icon.png',
|
||||
asset_class: 'rwa',
|
||||
asset_subclass: 'stablecoin',
|
||||
issuer_name: 'Example Treasury Reserve Co.',
|
||||
uris: [
|
||||
{
|
||||
uri: 'https://exampletreasury.com/tstusd',
|
||||
category: 'website',
|
||||
title: 'Product Page'
|
||||
},
|
||||
{
|
||||
uri: 'https://exampletreasury.com/tstusd/reserve',
|
||||
category: 'docs',
|
||||
title: 'Reserve Attestation'
|
||||
}
|
||||
],
|
||||
additional_info: {
|
||||
reserve_type: 'U.S. Treasury Bills',
|
||||
custody_provider: 'Example Custodian Bank',
|
||||
audit_frequency: 'Monthly',
|
||||
last_audit_date: '2026-01-15',
|
||||
pegged_currency: 'USD'
|
||||
}
|
||||
}
|
||||
|
||||
const [ticketCreateResponse, mptIssuanceResponse] = await Promise.all([
|
||||
client.submitAndWait({
|
||||
TransactionType: 'TicketCreate',
|
||||
Account: loanBroker.address,
|
||||
TicketCount: 2
|
||||
}, { wallet: loanBroker, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'MPTokenIssuanceCreate',
|
||||
Account: depositor.address,
|
||||
MaximumAmount: '100000000',
|
||||
TransferFee: 0,
|
||||
Flags:
|
||||
xrpl.MPTokenIssuanceCreateFlags.tfMPTCanTransfer |
|
||||
xrpl.MPTokenIssuanceCreateFlags.tfMPTCanClawback |
|
||||
xrpl.MPTokenIssuanceCreateFlags.tfMPTCanTrade,
|
||||
MPTokenMetadata: xrpl.encodeMPTokenMetadata(mptData)
|
||||
}, { wallet: depositor, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'Batch',
|
||||
Account: credentialIssuer.address,
|
||||
Flags: xrpl.BatchFlags.tfAllOrNothing,
|
||||
RawTransactions: [
|
||||
{
|
||||
RawTransaction: {
|
||||
TransactionType: 'CredentialCreate',
|
||||
Account: credentialIssuer.address,
|
||||
Subject: loanBroker.address,
|
||||
CredentialType: credentialType,
|
||||
Flags: xrpl.GlobalFlags.tfInnerBatchTxn
|
||||
}
|
||||
},
|
||||
{
|
||||
RawTransaction: {
|
||||
TransactionType: 'CredentialCreate',
|
||||
Account: credentialIssuer.address,
|
||||
Subject: borrower.address,
|
||||
CredentialType: credentialType,
|
||||
Flags: xrpl.GlobalFlags.tfInnerBatchTxn
|
||||
}
|
||||
},
|
||||
{
|
||||
RawTransaction: {
|
||||
TransactionType: 'CredentialCreate',
|
||||
Account: credentialIssuer.address,
|
||||
Subject: depositor.address,
|
||||
CredentialType: credentialType,
|
||||
Flags: xrpl.GlobalFlags.tfInnerBatchTxn
|
||||
}
|
||||
},
|
||||
{
|
||||
RawTransaction: {
|
||||
TransactionType: 'PermissionedDomainSet',
|
||||
Account: credentialIssuer.address,
|
||||
AcceptedCredentials: [
|
||||
{
|
||||
Credential: {
|
||||
Issuer: credentialIssuer.address,
|
||||
CredentialType: credentialType
|
||||
}
|
||||
}
|
||||
],
|
||||
Flags: xrpl.GlobalFlags.tfInnerBatchTxn
|
||||
}
|
||||
}
|
||||
]
|
||||
}, { wallet: credentialIssuer, autofill: true })
|
||||
])
|
||||
|
||||
// Extract ticket sequence numbers
|
||||
const tickets = ticketCreateResponse.result.meta.AffectedNodes
|
||||
.filter(node => node.CreatedNode?.LedgerEntryType === 'Ticket')
|
||||
.map(node => node.CreatedNode.NewFields.TicketSequence)
|
||||
|
||||
// Extract MPT issuance ID
|
||||
const mptID = mptIssuanceResponse.result.meta.mpt_issuance_id
|
||||
|
||||
// Get domain ID
|
||||
const credentialIssuerObjects = await client.request({
|
||||
command: 'account_objects',
|
||||
account: credentialIssuer.address,
|
||||
ledger_index: 'validated'
|
||||
})
|
||||
const domainID = credentialIssuerObjects.result.account_objects.find(node =>
|
||||
node.LedgerEntryType === 'PermissionedDomain'
|
||||
).index
|
||||
|
||||
process.stdout.write('Setting up tutorial: 2/6\r')
|
||||
|
||||
// Accept credentials and authorize MPT for each account
|
||||
await Promise.all([
|
||||
...([loanBroker, borrower].map(wallet =>
|
||||
client.submitAndWait({
|
||||
TransactionType: 'Batch',
|
||||
Account: wallet.address,
|
||||
Flags: xrpl.BatchFlags.tfAllOrNothing,
|
||||
RawTransactions: [
|
||||
{
|
||||
RawTransaction: {
|
||||
TransactionType: 'CredentialAccept',
|
||||
Account: wallet.address,
|
||||
Issuer: credentialIssuer.address,
|
||||
CredentialType: credentialType,
|
||||
Flags: xrpl.GlobalFlags.tfInnerBatchTxn
|
||||
}
|
||||
},
|
||||
{
|
||||
RawTransaction: {
|
||||
TransactionType: 'MPTokenAuthorize',
|
||||
Account: wallet.address,
|
||||
MPTokenIssuanceID: mptID,
|
||||
Flags: xrpl.GlobalFlags.tfInnerBatchTxn
|
||||
}
|
||||
}
|
||||
]
|
||||
}, { wallet, autofill: true })
|
||||
)),
|
||||
// Depositor only needs to accept credentials
|
||||
client.submitAndWait({
|
||||
TransactionType: 'CredentialAccept',
|
||||
Account: depositor.address,
|
||||
Issuer: credentialIssuer.address,
|
||||
CredentialType: credentialType
|
||||
}, { wallet: depositor, autofill: true })
|
||||
])
|
||||
|
||||
process.stdout.write('Setting up tutorial: 3/6\r')
|
||||
|
||||
// Create private vault and distribute MPT to accounts
|
||||
const [vaultCreateResponse] = await Promise.all([
|
||||
client.submitAndWait({
|
||||
TransactionType: 'VaultCreate',
|
||||
Account: loanBroker.address,
|
||||
Asset: {
|
||||
mpt_issuance_id: mptID
|
||||
},
|
||||
Flags: xrpl.VaultCreateFlags.tfVaultPrivate,
|
||||
DomainID: domainID
|
||||
}, { wallet: loanBroker, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'Batch',
|
||||
Account: depositor.address,
|
||||
Flags: xrpl.BatchFlags.tfAllOrNothing,
|
||||
RawTransactions: [
|
||||
{
|
||||
RawTransaction: {
|
||||
TransactionType: 'Payment',
|
||||
Account: depositor.address,
|
||||
Destination: loanBroker.address,
|
||||
Amount: {
|
||||
mpt_issuance_id: mptID,
|
||||
value: '5000'
|
||||
},
|
||||
Flags: xrpl.GlobalFlags.tfInnerBatchTxn
|
||||
}
|
||||
},
|
||||
{
|
||||
RawTransaction: {
|
||||
TransactionType: 'Payment',
|
||||
Account: depositor.address,
|
||||
Destination: borrower.address,
|
||||
Amount: {
|
||||
mpt_issuance_id: mptID,
|
||||
value: '2500'
|
||||
},
|
||||
Flags: xrpl.GlobalFlags.tfInnerBatchTxn
|
||||
}
|
||||
}
|
||||
]
|
||||
}, { wallet: depositor, autofill: true })
|
||||
])
|
||||
|
||||
const vaultID = vaultCreateResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.CreatedNode?.LedgerEntryType === 'Vault'
|
||||
).CreatedNode.LedgerIndex
|
||||
|
||||
process.stdout.write('Setting up tutorial: 4/6\r')
|
||||
|
||||
// Create LoanBroker and deposit MPT into vault
|
||||
const [loanBrokerSetResponse] = await Promise.all([
|
||||
client.submitAndWait({
|
||||
TransactionType: 'LoanBrokerSet',
|
||||
Account: loanBroker.address,
|
||||
VaultID: vaultID
|
||||
}, { wallet: loanBroker, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'VaultDeposit',
|
||||
Account: depositor.address,
|
||||
VaultID: vaultID,
|
||||
Amount: {
|
||||
mpt_issuance_id: mptID,
|
||||
value: '50000000'
|
||||
}
|
||||
}, { wallet: depositor, autofill: true })
|
||||
])
|
||||
|
||||
const loanBrokerID = loanBrokerSetResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.CreatedNode?.LedgerEntryType === 'LoanBroker'
|
||||
).CreatedNode.LedgerIndex
|
||||
|
||||
process.stdout.write('Setting up tutorial: 5/6\r')
|
||||
|
||||
// Create 2 identical loans with complete repayment due in 30 days
|
||||
|
||||
// Suppress unnecessary console warning from autofilling LoanSet.
|
||||
console.warn = () => {}
|
||||
|
||||
// Helper function to create and sign a LoanSet transaction
|
||||
async function createSignedLoanSetTx (ticketSequence) {
|
||||
const loanSetTx = await client.autofill({
|
||||
TransactionType: 'LoanSet',
|
||||
Account: loanBroker.address,
|
||||
Counterparty: borrower.address,
|
||||
LoanBrokerID: loanBrokerID,
|
||||
PrincipalRequested: 1000,
|
||||
InterestRate: 500,
|
||||
PaymentTotal: 1,
|
||||
PaymentInterval: 2592000,
|
||||
LoanOriginationFee: 100,
|
||||
LoanServiceFee: 10,
|
||||
Sequence: 0,
|
||||
TicketSequence: ticketSequence
|
||||
})
|
||||
|
||||
const loanBrokerSignature = await client.request({
|
||||
command: 'sign',
|
||||
tx_json: loanSetTx,
|
||||
secret: loanBroker.seed
|
||||
})
|
||||
|
||||
const borrowerSignature = await client.request({
|
||||
command: 'sign',
|
||||
tx_json: loanBrokerSignature.result.tx_json,
|
||||
secret: borrower.seed,
|
||||
signature_target: 'CounterpartySignature'
|
||||
})
|
||||
|
||||
return borrowerSignature.result.tx_json
|
||||
}
|
||||
|
||||
// Create and submit both loans
|
||||
const [signedLoan1, signedLoan2] = await Promise.all([
|
||||
createSignedLoanSetTx(tickets[0]),
|
||||
createSignedLoanSetTx(tickets[1])
|
||||
])
|
||||
|
||||
const [submitLoan1, submitLoan2] = await Promise.all([
|
||||
client.submit(signedLoan1),
|
||||
client.submit(signedLoan2)
|
||||
])
|
||||
const hash1 = submitLoan1.result.tx_json.hash
|
||||
const hash2 = submitLoan2.result.tx_json.hash
|
||||
|
||||
// Helper function to check tx hash is validated
|
||||
async function validateTx (hash, maxRetries = 20) {
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
try {
|
||||
const tx = await client.request({ command: 'tx', transaction: hash })
|
||||
if (tx.result.validated) {
|
||||
return tx
|
||||
}
|
||||
} catch (error) {
|
||||
// Transaction not validated yet, check again
|
||||
}
|
||||
}
|
||||
console.error(`Error: Transaction ${hash} not validated after ${maxRetries} attempts.`)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const [submitResponse1, submitResponse2] = await Promise.all([
|
||||
validateTx(hash1),
|
||||
validateTx(hash2)
|
||||
])
|
||||
|
||||
const loanID1 = submitResponse1.result.meta.AffectedNodes.find(node =>
|
||||
node.CreatedNode?.LedgerEntryType === 'Loan'
|
||||
).CreatedNode.LedgerIndex
|
||||
|
||||
const loanID2 = submitResponse2.result.meta.AffectedNodes.find(node =>
|
||||
node.CreatedNode?.LedgerEntryType === 'Loan'
|
||||
).CreatedNode.LedgerIndex
|
||||
|
||||
process.stdout.write('Setting up tutorial: 6/6\r')
|
||||
|
||||
// Write setup data to JSON file
|
||||
const setupData = {
|
||||
description: 'This file is auto-generated by lendingSetup.js. It stores XRPL account info for use in lending protocol tutorials.',
|
||||
loanBroker: {
|
||||
address: loanBroker.address,
|
||||
seed: loanBroker.seed
|
||||
},
|
||||
borrower: {
|
||||
address: borrower.address,
|
||||
seed: borrower.seed
|
||||
},
|
||||
depositor: {
|
||||
address: depositor.address,
|
||||
seed: depositor.seed
|
||||
},
|
||||
credentialIssuer: {
|
||||
address: credentialIssuer.address,
|
||||
seed: credentialIssuer.seed
|
||||
},
|
||||
domainID,
|
||||
mptID,
|
||||
vaultID,
|
||||
loanBrokerID,
|
||||
loanID1,
|
||||
loanID2
|
||||
}
|
||||
|
||||
fs.writeFileSync('lendingSetup.json', JSON.stringify(setupData, null, 2))
|
||||
|
||||
process.stdout.write('Setting up tutorial: Complete!\n')
|
||||
|
||||
await client.disconnect()
|
||||
144
_code-samples/lending-protocol/js/loanManage.js
Normal file
144
_code-samples/lending-protocol/js/loanManage.js
Normal file
@@ -0,0 +1,144 @@
|
||||
// IMPORTANT: This example impairs an existing loan, which has a 60 second grace period.
|
||||
// After the 60 seconds pass, this example defaults the loan.
|
||||
|
||||
import fs from 'fs'
|
||||
import { execSync } from 'child_process'
|
||||
import xrpl from 'xrpl'
|
||||
|
||||
// Connect to the network ----------------------
|
||||
const client = new xrpl.Client('wss://s.devnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
// This step checks for the necessary setup data to run the lending protocol tutorials.
|
||||
// If missing, lendingSetup.js will generate the data.
|
||||
if (!fs.existsSync('lendingSetup.json')) {
|
||||
console.log(`\n=== Lending tutorial data doesn't exist. Running setup script... ===\n`)
|
||||
execSync('node lendingSetup.js', { stdio: 'inherit' })
|
||||
}
|
||||
|
||||
// Load preconfigured accounts and LoanID.
|
||||
const setupData = JSON.parse(fs.readFileSync('lendingSetup.json', 'utf8'))
|
||||
|
||||
// You can replace these values with your own
|
||||
const loanBroker = xrpl.Wallet.fromSeed(setupData.loanBroker.seed)
|
||||
const loanID = setupData.loanID1
|
||||
|
||||
console.log(`\nLoan broker address: ${loanBroker.address}`)
|
||||
console.log(`LoanID: ${loanID}`)
|
||||
|
||||
// Check loan status before impairment ----------------------
|
||||
console.log(`\n=== Loan Status ===\n`)
|
||||
const loanStatus = await client.request({
|
||||
command: 'ledger_entry',
|
||||
index: loanID,
|
||||
ledger_index: 'validated'
|
||||
})
|
||||
|
||||
console.log(`Total Amount Owed: ${loanStatus.result.node.TotalValueOutstanding} TSTUSD.`)
|
||||
// Convert Ripple Epoch timestamp to local date and time
|
||||
let nextPaymentDueDate = loanStatus.result.node.NextPaymentDueDate
|
||||
let paymentDue = new Date((nextPaymentDueDate + 946684800) * 1000)
|
||||
console.log(`Payment Due Date: ${paymentDue.toLocaleString()}`)
|
||||
|
||||
// Prepare LoanManage transaction to impair the loan ----------------------
|
||||
console.log(`\n=== Preparing LoanManage transaction to impair loan ===\n`)
|
||||
const loanManageImpair = {
|
||||
TransactionType: 'LoanManage',
|
||||
Account: loanBroker.address,
|
||||
LoanID: loanID,
|
||||
Flags: xrpl.LoanManageFlags.tfLoanImpair
|
||||
}
|
||||
|
||||
// Validate the impairment transaction before submitting
|
||||
xrpl.validate(loanManageImpair)
|
||||
console.log(JSON.stringify(loanManageImpair, null, 2))
|
||||
|
||||
// Sign, submit, and wait for impairment validation ----------------------
|
||||
console.log(`\n=== Submitting LoanManage impairment transaction ===\n`)
|
||||
const impairResponse = await client.submitAndWait(loanManageImpair, {
|
||||
wallet: loanBroker,
|
||||
autofill: true
|
||||
})
|
||||
|
||||
if (impairResponse.result.meta.TransactionResult !== 'tesSUCCESS') {
|
||||
const resultCode = impairResponse.result.meta.TransactionResult
|
||||
console.error('Error: Unable to impair loan:', resultCode)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('Loan impaired successfully!')
|
||||
|
||||
// Extract loan impairment info from transaction results ----------------------
|
||||
let loanNode = impairResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.ModifiedNode?.LedgerEntryType === 'Loan'
|
||||
)
|
||||
|
||||
// Check grace period and next payment due date
|
||||
const gracePeriod = loanNode.ModifiedNode.FinalFields.GracePeriod
|
||||
nextPaymentDueDate = loanNode.ModifiedNode.FinalFields.NextPaymentDueDate
|
||||
const defaultTime = nextPaymentDueDate + gracePeriod
|
||||
paymentDue = new Date((nextPaymentDueDate + 946684800) * 1000)
|
||||
|
||||
console.log(`New Payment Due Date: ${paymentDue.toLocaleString()}`)
|
||||
console.log(`Grace Period: ${gracePeriod} seconds`)
|
||||
|
||||
// Convert current time to Ripple Epoch timestamp
|
||||
const currentTime = Math.floor(Date.now() / 1000) - 946684800
|
||||
let secondsUntilDefault = defaultTime - currentTime
|
||||
|
||||
// Countdown until loan can be defaulted ----------------------
|
||||
console.log(`\n=== Countdown until loan can be defaulted ===\n`)
|
||||
|
||||
await new Promise((resolve) => {
|
||||
const countdown = setInterval(() => {
|
||||
if (secondsUntilDefault <= 0) {
|
||||
clearInterval(countdown)
|
||||
process.stdout.write('\rGrace period expired. Loan can now be defaulted.\n')
|
||||
resolve()
|
||||
} else {
|
||||
process.stdout.write(`\r${secondsUntilDefault} seconds...`)
|
||||
secondsUntilDefault--
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
// Prepare LoanManage transaction to default the loan ----------------------
|
||||
console.log(`\n=== Preparing LoanManage transaction to default loan ===\n`)
|
||||
const loanManageDefault = {
|
||||
TransactionType: 'LoanManage',
|
||||
Account: loanBroker.address,
|
||||
LoanID: loanID,
|
||||
Flags: xrpl.LoanManageFlags.tfLoanDefault
|
||||
}
|
||||
|
||||
// Validate the default transaction before submitting
|
||||
xrpl.validate(loanManageDefault)
|
||||
console.log(JSON.stringify(loanManageDefault, null, 2))
|
||||
|
||||
// Sign, submit, and wait for default validation ----------------------
|
||||
console.log(`\n=== Submitting LoanManage default transaction ===\n`)
|
||||
const defaultResponse = await client.submitAndWait(loanManageDefault, {
|
||||
wallet: loanBroker,
|
||||
autofill: true
|
||||
})
|
||||
|
||||
if (defaultResponse.result.meta.TransactionResult !== 'tesSUCCESS') {
|
||||
const resultCode = defaultResponse.result.meta.TransactionResult
|
||||
console.error('Error: Unable to default loan:', resultCode)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('Loan defaulted successfully!')
|
||||
|
||||
// Verify loan default status from transaction results ----------------------
|
||||
console.log(`\n=== Checking final loan status ===\n`)
|
||||
loanNode = defaultResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.ModifiedNode?.LedgerEntryType === 'Loan'
|
||||
)
|
||||
const loanFlags = loanNode.ModifiedNode.FinalFields.Flags
|
||||
console.log(`Final loan flags (parsed): ${JSON.stringify(xrpl.parseTransactionFlags({
|
||||
TransactionType: 'LoanManage',
|
||||
Flags: loanFlags
|
||||
}))}`)
|
||||
|
||||
await client.disconnect()
|
||||
134
_code-samples/lending-protocol/js/loanPay.js
Normal file
134
_code-samples/lending-protocol/js/loanPay.js
Normal file
@@ -0,0 +1,134 @@
|
||||
// IMPORTANT: This example pays off an existing loan and then deletes it.
|
||||
|
||||
import fs from 'fs'
|
||||
import { execSync } from 'child_process'
|
||||
import xrpl from 'xrpl'
|
||||
|
||||
// Connect to the network ----------------------
|
||||
const client = new xrpl.Client('wss://s.devnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
// This step checks for the necessary setup data to run the lending protocol tutorials.
|
||||
// If missing, lendingSetup.js will generate the data.
|
||||
if (!fs.existsSync('lendingSetup.json')) {
|
||||
console.log(`\n=== Lending tutorial data doesn't exist. Running setup script... ===\n`)
|
||||
execSync('node lendingSetup.js', { stdio: 'inherit' })
|
||||
}
|
||||
|
||||
// Load preconfigured accounts and LoanID.
|
||||
const setupData = JSON.parse(fs.readFileSync('lendingSetup.json', 'utf8'))
|
||||
|
||||
// You can replace these values with your own
|
||||
const borrower = xrpl.Wallet.fromSeed(setupData.borrower.seed)
|
||||
const loanID = setupData.loanID2
|
||||
const mptID = setupData.mptID
|
||||
|
||||
console.log(`\nBorrower address: ${borrower.address}`)
|
||||
console.log(`LoanID: ${loanID}`)
|
||||
console.log(`MPT ID: ${mptID}`)
|
||||
|
||||
// Check initial loan status ----------------------
|
||||
console.log(`\n=== Loan Status ===\n`)
|
||||
const loanStatus = await client.request({
|
||||
command: 'ledger_entry',
|
||||
index: loanID,
|
||||
ledger_index: 'validated'
|
||||
})
|
||||
|
||||
const totalValueOutstanding = loanStatus.result.node.TotalValueOutstanding
|
||||
const loanServiceFee = loanStatus.result.node.LoanServiceFee
|
||||
const totalPayment = (BigInt(totalValueOutstanding) + BigInt(loanServiceFee)).toString()
|
||||
|
||||
console.log(`Amount Owed: ${totalValueOutstanding} TSTUSD`)
|
||||
console.log(`Loan Service Fee: ${loanServiceFee} TSTUSD`)
|
||||
console.log(`Total Payment Due (including fees): ${totalPayment} TSTUSD`)
|
||||
|
||||
// Prepare LoanPay transaction ----------------------
|
||||
console.log(`\n=== Preparing LoanPay transaction ===\n`)
|
||||
|
||||
const loanPayTx = {
|
||||
TransactionType: 'LoanPay',
|
||||
Account: borrower.address,
|
||||
LoanID: loanID,
|
||||
Amount: {
|
||||
mpt_issuance_id: mptID,
|
||||
value: totalPayment
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the transaction structure before submitting
|
||||
xrpl.validate(loanPayTx)
|
||||
console.log(JSON.stringify(loanPayTx, null, 2))
|
||||
|
||||
// Sign, submit, and wait for payment validation ----------------------
|
||||
console.log(`\n=== Submitting LoanPay transaction ===\n`)
|
||||
const payResponse = await client.submitAndWait(loanPayTx, {
|
||||
wallet: borrower,
|
||||
autofill: true
|
||||
})
|
||||
|
||||
if (payResponse.result.meta.TransactionResult !== 'tesSUCCESS') {
|
||||
const resultCode = payResponse.result.meta.TransactionResult
|
||||
console.error('Error: Unable to pay loan:', resultCode)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('Loan paid successfully!')
|
||||
|
||||
// Extract updated loan info from transaction results ----------------------
|
||||
console.log(`\n=== Loan Status After Payment ===\n`)
|
||||
const loanNode = payResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.ModifiedNode?.LedgerEntryType === 'Loan'
|
||||
)
|
||||
|
||||
const finalBalance = loanNode.ModifiedNode.FinalFields.TotalValueOutstanding
|
||||
? `${loanNode.ModifiedNode.FinalFields.TotalValueOutstanding} TSTUSD`
|
||||
: 'Loan fully paid off!'
|
||||
console.log(`Outstanding Loan Balance: ${finalBalance}`)
|
||||
|
||||
// Prepare LoanDelete transaction ----------------------
|
||||
// Either the loan broker or borrower can submit this transaction.
|
||||
console.log(`\n=== Preparing LoanDelete transaction ===\n`)
|
||||
const loanDeleteTx = {
|
||||
TransactionType: 'LoanDelete',
|
||||
Account: borrower.address,
|
||||
LoanID: loanID
|
||||
}
|
||||
|
||||
// Validate the transaction structure before submitting
|
||||
xrpl.validate(loanDeleteTx)
|
||||
console.log(JSON.stringify(loanDeleteTx, null, 2))
|
||||
|
||||
// Sign, submit, and wait for deletion validation ----------------------
|
||||
console.log(`\n=== Submitting LoanDelete transaction ===\n`)
|
||||
const deleteResponse = await client.submitAndWait(loanDeleteTx, {
|
||||
wallet: borrower,
|
||||
autofill: true
|
||||
})
|
||||
|
||||
if (deleteResponse.result.meta.TransactionResult !== 'tesSUCCESS') {
|
||||
const resultCode = deleteResponse.result.meta.TransactionResult
|
||||
console.error('Error: Unable to delete loan:', resultCode)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('Loan deleted successfully!')
|
||||
|
||||
// Verify loan deletion ----------------------
|
||||
console.log(`\n=== Verifying Loan Deletion ===\n`)
|
||||
try {
|
||||
await client.request({
|
||||
command: 'ledger_entry',
|
||||
index: loanID,
|
||||
ledger_index: 'validated'
|
||||
})
|
||||
console.log('Warning: Loan still exists in the ledger.')
|
||||
} catch (error) {
|
||||
if (error.data.error === 'entryNotFound') {
|
||||
console.log('Loan has been successfully removed from the XRP Ledger!')
|
||||
} else {
|
||||
console.error('Error checking loan status:', error)
|
||||
}
|
||||
}
|
||||
|
||||
await client.disconnect()
|
||||
8
_code-samples/lending-protocol/js/package.json
Normal file
8
_code-samples/lending-protocol/js/package.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "lending-protocol-examples",
|
||||
"description": "Example code for creating and managing loans.",
|
||||
"dependencies": {
|
||||
"xrpl": "^4.5.0"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
3
_code-samples/vaults/README.md
Normal file
3
_code-samples/vaults/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Single Asset Vault Examples
|
||||
|
||||
Shows how to create, deposit into, and withdraw from single asset vaults on the XRP Ledger.
|
||||
187
_code-samples/vaults/js/README.md
Normal file
187
_code-samples/vaults/js/README.md
Normal file
@@ -0,0 +1,187 @@
|
||||
# Single Asset Vault Examples (JavaScript)
|
||||
|
||||
This directory contains JavaScript examples demonstrating how to create, deposit into, and withdraw from single asset vaults on the XRP Ledger.
|
||||
|
||||
## Setup
|
||||
|
||||
Install dependencies before running any examples:
|
||||
|
||||
```sh
|
||||
npm i
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Create a Vault
|
||||
|
||||
```sh
|
||||
node createVault.js
|
||||
```
|
||||
|
||||
The script should output the VaultCreate transaction, vault ID, and complete vault information:
|
||||
|
||||
```sh
|
||||
Vault owner address: rLXZNDSS7gWvQZKunRUFiaViSiHo1yd4Ms
|
||||
MPT issuance ID: 0003E3B486D3DACD8BB468AB33793B9626BD894A92AB3AB4
|
||||
Permissioned domain ID: 3BB81D0D164456A2D74720F63FD923F16DE08FB3223D3ED103D09F525A8D69D1
|
||||
|
||||
|
||||
=== VaultCreate transaction ===
|
||||
{
|
||||
"TransactionType": "VaultCreate",
|
||||
"Account": "rLXZNDSS7gWvQZKunRUFiaViSiHo1yd4Ms",
|
||||
"Asset": {
|
||||
"mpt_issuance_id": "0003E3B486D3DACD8BB468AB33793B9626BD894A92AB3AB4"
|
||||
},
|
||||
"Flags": 65536,
|
||||
"DomainID": "3BB81D0D164456A2D74720F63FD923F16DE08FB3223D3ED103D09F525A8D69D1",
|
||||
"Data": "50726976617465207661756C74",
|
||||
"MPTokenMetadata": "7B226163223A2264656669222C226169223A7B226578616D706C655F696E666F223A2274657374227D2C2264223A2250726F706F7274696F6E616C206F776E65727368697020736861726573206F6620746865207661756C742E222C2269223A226578616D706C652E636F6D2F61737365742D69636F6E2E706E67222C22696E223A22417373657420497373756572204E616D65222C226E223A225661756C7420736861726573222C2274223A22534841524531222C227573223A5B7B2263223A2277656273697465222C2274223A2241737365742057656273697465222C2275223A226578616D706C652E636F6D2F6173736574227D2C7B2263223A22646F6373222C2274223A22446F6373222C2275223A226578616D706C652E636F6D2F646F6373227D5D7D",
|
||||
"AssetsMaximum": "0",
|
||||
"WithdrawalPolicy": 1
|
||||
}
|
||||
|
||||
=== Submitting VaultCreate transaction... ===
|
||||
Vault created successfully!
|
||||
|
||||
Vault ID: 9D25282C143F0F7F71F0E6FC7ABB3BD6FB30B7DCF04DF4A1E31C701B1B332D29
|
||||
Vault pseudo-account address: rnBAKKEBBTqswakdeJJkZtBs9SRgpMkThj
|
||||
Share MPT issuance ID: 000000012DF200D67FF9DA7686FF8B6F32097337D7765211
|
||||
|
||||
=== Getting vault_info... ===
|
||||
{
|
||||
"api_version": 2,
|
||||
"id": 12,
|
||||
"result": {
|
||||
"ledger_hash": "73B53C0608A9C87C2B97314F0BAD109F236C4A95FB53FE4E8CEAEFE826A1E7AB",
|
||||
"ledger_index": 597229,
|
||||
"validated": true,
|
||||
"vault": {
|
||||
"Account": "rnBAKKEBBTqswakdeJJkZtBs9SRgpMkThj",
|
||||
"Asset": {
|
||||
"mpt_issuance_id": "0003E3B486D3DACD8BB468AB33793B9626BD894A92AB3AB4"
|
||||
},
|
||||
"Data": "50726976617465207661756C74",
|
||||
"Flags": 65536,
|
||||
"LedgerEntryType": "Vault",
|
||||
"Owner": "rLXZNDSS7gWvQZKunRUFiaViSiHo1yd4Ms",
|
||||
"OwnerNode": "0",
|
||||
"PreviousTxnID": "8B64609225F802258250824B2C6C0A8B752AB8CBB6FAF64D433DC2F35C09E131",
|
||||
"PreviousTxnLgrSeq": 597229,
|
||||
"Sequence": 597228,
|
||||
"ShareMPTID": "000000012DF200D67FF9DA7686FF8B6F32097337D7765211",
|
||||
"WithdrawalPolicy": 1,
|
||||
"index": "9D25282C143F0F7F71F0E6FC7ABB3BD6FB30B7DCF04DF4A1E31C701B1B332D29",
|
||||
"shares": {
|
||||
"DomainID": "3BB81D0D164456A2D74720F63FD923F16DE08FB3223D3ED103D09F525A8D69D1",
|
||||
"Flags": 60,
|
||||
"Issuer": "rnBAKKEBBTqswakdeJJkZtBs9SRgpMkThj",
|
||||
"LedgerEntryType": "MPTokenIssuance",
|
||||
"MPTokenMetadata": "7B226163223A2264656669222C226169223A7B226578616D706C655F696E666F223A2274657374227D2C2264223A2250726F706F7274696F6E616C206F776E65727368697020736861726573206F6620746865207661756C742E222C2269223A226578616D706C652E636F6D2F61737365742D69636F6E2E706E67222C22696E223A22417373657420497373756572204E616D65222C226E223A225661756C7420736861726573222C2274223A22534841524531222C227573223A5B7B2263223A2277656273697465222C2274223A2241737365742057656273697465222C2275223A226578616D706C652E636F6D2F6173736574227D2C7B2263223A22646F6373222C2274223A22446F6373222C2275223A226578616D706C652E636F6D2F646F6373227D5D7D",
|
||||
"OutstandingAmount": "0",
|
||||
"OwnerNode": "0",
|
||||
"PreviousTxnID": "8B64609225F802258250824B2C6C0A8B752AB8CBB6FAF64D433DC2F35C09E131",
|
||||
"PreviousTxnLgrSeq": 597229,
|
||||
"Sequence": 1,
|
||||
"index": "4C3CC0AF1FE27EBE364F02AFF889D73D1F6F7CB5ED6126D1CD605E8952E18302",
|
||||
"mpt_issuance_id": "000000012DF200D67FF9DA7686FF8B6F32097337D7765211"
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "response"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Deposit into a Vault
|
||||
|
||||
```sh
|
||||
node deposit.js
|
||||
```
|
||||
|
||||
The script should output the vault state before and after the deposit, along with the depositor's share balance:
|
||||
|
||||
```sh
|
||||
Depositor address: rnEmvWahVbNXzs8zGjhEfkBwo41Zn5wDDU
|
||||
Vault ID: 6AC4EC2D775C6275D314996D6ECDD16DCB9382A29FDB769951C42192FCED76EF
|
||||
Asset MPT issuance ID: 0003E3B486D3DACD8BB468AB33793B9626BD894A92AB3AB4
|
||||
Vault share MPT issuance ID: 0000000152E7CD364F869E832EDB806C4A7AD8B3D0C151C5
|
||||
|
||||
=== Getting initial vault state... ===
|
||||
- Total vault value: 1
|
||||
- Available assets: 1
|
||||
|
||||
=== Checking depositor's balance... ===
|
||||
Balance: 9937
|
||||
|
||||
=== VaultDeposit transaction ===
|
||||
{
|
||||
"TransactionType": "VaultDeposit",
|
||||
"Account": "rnEmvWahVbNXzs8zGjhEfkBwo41Zn5wDDU",
|
||||
"VaultID": "6AC4EC2D775C6275D314996D6ECDD16DCB9382A29FDB769951C42192FCED76EF",
|
||||
"Amount": {
|
||||
"mpt_issuance_id": "0003E3B486D3DACD8BB468AB33793B9626BD894A92AB3AB4",
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting VaultDeposit transaction... ===
|
||||
Deposit successful!
|
||||
|
||||
=== Vault state after deposit ===
|
||||
- Total vault value: 2
|
||||
- Available assets: 2
|
||||
|
||||
=== Depositor's share balance ==
|
||||
Shares held: 2
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Withdraw from a Vault
|
||||
|
||||
```sh
|
||||
node withdraw.js
|
||||
```
|
||||
|
||||
The script should output the vault state before and after the withdrawal, along with updated share and asset balances:
|
||||
|
||||
```sh
|
||||
Depositor address: rnEmvWahVbNXzs8zGjhEfkBwo41Zn5wDDU
|
||||
Vault ID: 6AC4EC2D775C6275D314996D6ECDD16DCB9382A29FDB769951C42192FCED76EF
|
||||
Asset MPT issuance ID: 0003E3B486D3DACD8BB468AB33793B9626BD894A92AB3AB4
|
||||
Vault share MPT issuance ID: 0000000152E7CD364F869E832EDB806C4A7AD8B3D0C151C5
|
||||
|
||||
=== Getting initial vault state... ===
|
||||
Initial vault state:
|
||||
Assets Total: 2
|
||||
Assets Available: 2
|
||||
|
||||
=== Checking depositor's share balance... ===
|
||||
Shares held: 2
|
||||
|
||||
=== Preparing VaultWithdraw transaction ===
|
||||
{
|
||||
"TransactionType": "VaultWithdraw",
|
||||
"Account": "rnEmvWahVbNXzs8zGjhEfkBwo41Zn5wDDU",
|
||||
"VaultID": "6AC4EC2D775C6275D314996D6ECDD16DCB9382A29FDB769951C42192FCED76EF",
|
||||
"Amount": {
|
||||
"mpt_issuance_id": "0003E3B486D3DACD8BB468AB33793B9626BD894A92AB3AB4",
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting VaultWithdraw transaction... ===
|
||||
Withdrawal successful!
|
||||
|
||||
=== Vault state after withdrawal ===
|
||||
Assets Total: 1
|
||||
Assets Available: 1
|
||||
|
||||
=== Depositor's share balance ==
|
||||
Shares held: 1
|
||||
|
||||
=== Depositor's asset balance ==
|
||||
Balance: 9937
|
||||
```
|
||||
111
_code-samples/vaults/js/createVault.js
Normal file
111
_code-samples/vaults/js/createVault.js
Normal file
@@ -0,0 +1,111 @@
|
||||
import xrpl from "xrpl"
|
||||
import { execSync } from "child_process"
|
||||
import fs from "fs"
|
||||
|
||||
// Auto-run setup if needed
|
||||
if (!fs.existsSync("vaultSetup.json")) {
|
||||
console.log(`\n=== Vault setup data doesn't exist. Running setup script... ===\n`)
|
||||
execSync("node vaultSetup.js", { stdio: "inherit" })
|
||||
}
|
||||
|
||||
// Load setup data
|
||||
const setupData = JSON.parse(fs.readFileSync("vaultSetup.json", "utf8"))
|
||||
|
||||
// Connect to the network
|
||||
const client = new xrpl.Client("wss://s.devnet.rippletest.net:51233")
|
||||
await client.connect()
|
||||
|
||||
// Create and fund vault owner account
|
||||
const { wallet: vaultOwner } = await client.fundWallet()
|
||||
|
||||
// You can replace these values with your own
|
||||
const mptIssuanceId = setupData.mptIssuanceId
|
||||
const domainId = setupData.domainId
|
||||
|
||||
console.log(`Vault owner address: ${vaultOwner.address}`)
|
||||
console.log(`MPT issuance ID: ${mptIssuanceId}`)
|
||||
console.log(`Permissioned domain ID: ${domainId}\n`)
|
||||
|
||||
// Prepare VaultCreate transaction ----------------------
|
||||
console.log(`\n=== VaultCreate transaction ===`)
|
||||
const vaultCreateTx = {
|
||||
TransactionType: "VaultCreate",
|
||||
Account: vaultOwner.address,
|
||||
Asset: { mpt_issuance_id: mptIssuanceId },
|
||||
Flags: xrpl.VaultCreateFlags.tfVaultPrivate, // Omit tfVaultPrivate flag for public vaults
|
||||
// To make vault shares non-transferable add the tfVaultShareNonTransferable flag:
|
||||
// Flags: xrpl.VaultCreateFlags.tfVaultPrivate | xrpl.VaultCreateFlags.tfVaultShareNonTransferable
|
||||
DomainID: domainId, // Omit for public vaults
|
||||
// Convert Vault data to a string (without excess whitespace), then string to hex.
|
||||
Data: xrpl.convertStringToHex(JSON.stringify(
|
||||
{ n: "LATAM Fund II", w: "examplefund.com" })
|
||||
),
|
||||
// Encode JSON metadata as hex string per XLS-89 MPT Metadata Schema.
|
||||
// See: https://xls.xrpl.org/xls/XLS-0089-multi-purpose-token-metadata-schema.html
|
||||
MPTokenMetadata: xrpl.encodeMPTokenMetadata({
|
||||
ticker: "SHARE1",
|
||||
name: "Vault shares",
|
||||
desc: "Proportional ownership shares of the vault.",
|
||||
icon: "example.com/asset-icon.png",
|
||||
asset_class: "defi",
|
||||
issuer_name: "Asset Issuer Name",
|
||||
uris: [
|
||||
{
|
||||
uri: "example.com/asset",
|
||||
category: "website",
|
||||
title: "Asset Website",
|
||||
},
|
||||
{
|
||||
uri: "example.com/docs",
|
||||
category: "docs",
|
||||
title: "Docs",
|
||||
},
|
||||
],
|
||||
additional_info: {
|
||||
example_info: "test",
|
||||
},
|
||||
}),
|
||||
AssetsMaximum: "0", // No cap
|
||||
WithdrawalPolicy: xrpl.VaultWithdrawalPolicy.vaultStrategyFirstComeFirstServe,
|
||||
};
|
||||
|
||||
// Validate the transaction structure before submitting
|
||||
xrpl.validate(vaultCreateTx)
|
||||
console.log(JSON.stringify(vaultCreateTx, null, 2))
|
||||
|
||||
// Submit, sign, and wait for validation ----------------------
|
||||
console.log("\n=== Submitting VaultCreate transaction... ===")
|
||||
const submit_response = await client.submitAndWait(vaultCreateTx, {
|
||||
wallet: vaultOwner,
|
||||
autofill: true,
|
||||
})
|
||||
if (submit_response.result.meta.TransactionResult !== "tesSUCCESS") {
|
||||
const result_code = submit_response.result.meta.TransactionResult;
|
||||
console.error("Error: Unable to create vault:", result_code)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
console.log("Vault created successfully!")
|
||||
|
||||
// Extract vault information from the transaction result
|
||||
const affectedNodes = submit_response.result.meta.AffectedNodes || []
|
||||
const vaultNode = affectedNodes.find(
|
||||
(node) => node.CreatedNode?.LedgerEntryType === "Vault"
|
||||
)
|
||||
if (vaultNode) {
|
||||
console.log(`\nVault ID: ${vaultNode.CreatedNode.LedgerIndex}`)
|
||||
console.log(`Vault pseudo-account address: ${vaultNode.CreatedNode.NewFields.Account}`)
|
||||
console.log(`Share MPT issuance ID: ${vaultNode.CreatedNode.NewFields.ShareMPTID}`)
|
||||
}
|
||||
|
||||
// Call vault_info method to retrieve the vault's information
|
||||
console.log("\n=== Getting vault_info... ===")
|
||||
const vaultID = vaultNode.CreatedNode.LedgerIndex
|
||||
const vault_info_response = await client.request({
|
||||
command: "vault_info",
|
||||
vault_id: vaultID,
|
||||
ledger_index: "validated"
|
||||
})
|
||||
console.log(JSON.stringify(vault_info_response, null, 2))
|
||||
|
||||
await client.disconnect()
|
||||
145
_code-samples/vaults/js/deposit.js
Normal file
145
_code-samples/vaults/js/deposit.js
Normal file
@@ -0,0 +1,145 @@
|
||||
// IMPORTANT: This example deposits into an existing PRIVATE vault.
|
||||
// The depositor account used has valid credentials in the vault's Permissioned Domain.
|
||||
// Without valid credentials, the VaultDeposit transaction will fail.
|
||||
// If you want to deposit into a public vault, you can replace the vaultID and shareMPTIssuanceId
|
||||
// values with your own.
|
||||
|
||||
import xrpl from "xrpl"
|
||||
import { execSync } from "child_process"
|
||||
import fs from "fs"
|
||||
|
||||
// Auto-run setup if needed
|
||||
if (!fs.existsSync("vaultSetup.json")) {
|
||||
console.log(`\n=== Vault setup data doesn't exist. Running setup script... ===\n`)
|
||||
execSync("node vaultSetup.js", { stdio: "inherit" })
|
||||
}
|
||||
|
||||
// Load setup data
|
||||
const setupData = JSON.parse(fs.readFileSync("vaultSetup.json", "utf8"))
|
||||
|
||||
// Connect to the network
|
||||
const client = new xrpl.Client("wss://s.devnet.rippletest.net:51233")
|
||||
await client.connect()
|
||||
|
||||
// You can replace these values with your own
|
||||
const depositor = xrpl.Wallet.fromSeed(setupData.depositor.seed)
|
||||
const vaultID = setupData.vaultID
|
||||
const assetMPTIssuanceId = setupData.mptIssuanceId
|
||||
const shareMPTIssuanceId = setupData.vaultShareMPTIssuanceId
|
||||
|
||||
console.log(`Depositor address: ${depositor.address}`)
|
||||
console.log(`Vault ID: ${vaultID}`)
|
||||
console.log(`Asset MPT issuance ID: ${assetMPTIssuanceId}`)
|
||||
console.log(`Vault share MPT issuance ID: ${shareMPTIssuanceId}`)
|
||||
|
||||
const depositAmount = 1
|
||||
|
||||
// Get initial vault state ----------------------
|
||||
console.log("\n=== Getting initial vault state... ===")
|
||||
const initialVaultInfo = await client.request({
|
||||
command: "vault_info",
|
||||
vault_id: vaultID,
|
||||
ledger_index: "validated"
|
||||
})
|
||||
|
||||
console.log(` - Total vault value: ${initialVaultInfo.result.vault.AssetsTotal}`)
|
||||
console.log(` - Available assets: ${initialVaultInfo.result.vault.AssetsAvailable}`)
|
||||
|
||||
// Check depositor's asset balance ----------------------
|
||||
console.log("\n=== Checking depositor's balance... ===")
|
||||
try {
|
||||
// Use ledger_entry to get specific MPT issuance balance
|
||||
const ledgerEntryResult = await client.request({
|
||||
command: "ledger_entry",
|
||||
mptoken: {
|
||||
mpt_issuance_id: assetMPTIssuanceId,
|
||||
account: depositor.address
|
||||
},
|
||||
ledger_index: "validated"
|
||||
})
|
||||
|
||||
const balance = ledgerEntryResult.result.node?.MPTAmount
|
||||
console.log(`Balance: ${balance}`)
|
||||
|
||||
// Check if balance is sufficient
|
||||
if (balance < depositAmount) {
|
||||
console.error(`Error: Insufficient balance! Have ${balance}, need ${depositAmount}`)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.data?.error === 'entryNotFound') {
|
||||
console.log(`Error: The depositor doesn't hold any assets with ID: ${assetMPTIssuanceId}`)
|
||||
}
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Prepare VaultDeposit transaction ----------------------
|
||||
console.log(`\n=== VaultDeposit transaction ===`)
|
||||
const vaultDepositTx = {
|
||||
TransactionType: "VaultDeposit",
|
||||
Account: depositor.address,
|
||||
VaultID: vaultID,
|
||||
Amount: {
|
||||
mpt_issuance_id: assetMPTIssuanceId,
|
||||
value: depositAmount.toString()
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the transaction structure before submitting
|
||||
xrpl.validate(vaultDepositTx)
|
||||
console.log(JSON.stringify(vaultDepositTx, null, 2))
|
||||
|
||||
// Submit VaultDeposit transaction ----------------------
|
||||
console.log("\n=== Submitting VaultDeposit transaction... ===")
|
||||
const depositResult = await client.submitAndWait(vaultDepositTx, {
|
||||
wallet: depositor,
|
||||
autofill: true,
|
||||
})
|
||||
if (depositResult.result.meta.TransactionResult !== "tesSUCCESS") {
|
||||
const result_code = depositResult.result.meta.TransactionResult
|
||||
console.error("Error: Unable to deposit:", result_code)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
console.log("Deposit successful!")
|
||||
|
||||
// Extract vault state from transaction metadata ----------------------
|
||||
console.log("\n=== Vault state after deposit ===")
|
||||
const affectedNodes = depositResult.result.meta.AffectedNodes
|
||||
const vaultNode = affectedNodes.find(
|
||||
(node) => {
|
||||
return (
|
||||
node.ModifiedNode &&
|
||||
node.ModifiedNode.LedgerEntryType === "Vault" &&
|
||||
node.ModifiedNode.LedgerIndex === vaultID
|
||||
)
|
||||
}
|
||||
)
|
||||
if (vaultNode) {
|
||||
const vaultFields = vaultNode.ModifiedNode.FinalFields
|
||||
console.log(` - Total vault value: ${vaultFields.AssetsTotal}`)
|
||||
console.log(` - Available assets: ${vaultFields.AssetsAvailable}`)
|
||||
}
|
||||
|
||||
// Get the depositor's share balance ----------------------
|
||||
console.log("\n=== Depositor's share balance ==")
|
||||
const depositorShareNode = affectedNodes.find((node) => {
|
||||
const shareNode = node.ModifiedNode || node.CreatedNode
|
||||
const fields = shareNode?.FinalFields || shareNode?.NewFields
|
||||
return (
|
||||
shareNode &&
|
||||
shareNode.LedgerEntryType === "MPToken" &&
|
||||
fields?.Account === depositor.address &&
|
||||
fields?.MPTokenIssuanceID === shareMPTIssuanceId
|
||||
)
|
||||
})
|
||||
if (depositorShareNode) {
|
||||
const shareNode = depositorShareNode.ModifiedNode || depositorShareNode.CreatedNode
|
||||
const shareFields = shareNode.FinalFields || shareNode.NewFields
|
||||
console.log(`Shares held: ${shareFields.MPTAmount}`)
|
||||
}
|
||||
|
||||
await client.disconnect()
|
||||
|
||||
8
_code-samples/vaults/js/package.json
Normal file
8
_code-samples/vaults/js/package.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "vault-examples",
|
||||
"description": "Example code for creating and managing vaults",
|
||||
"dependencies": {
|
||||
"xrpl": "^4.5.0"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
264
_code-samples/vaults/js/vaultSetup.js
Normal file
264
_code-samples/vaults/js/vaultSetup.js
Normal file
@@ -0,0 +1,264 @@
|
||||
import xrpl from 'xrpl'
|
||||
import fs from 'fs'
|
||||
|
||||
// Setup script for vault tutorials
|
||||
|
||||
process.stdout.write('Setting up tutorial: 0/7\r')
|
||||
|
||||
const client = new xrpl.Client('wss://s.devnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
// Create and fund all wallets
|
||||
const [
|
||||
{ wallet: mptIssuer },
|
||||
{ wallet: domainOwner },
|
||||
{ wallet: depositor },
|
||||
{ wallet: vaultOwner }
|
||||
] = await Promise.all([
|
||||
client.fundWallet(),
|
||||
client.fundWallet(),
|
||||
client.fundWallet(),
|
||||
client.fundWallet()
|
||||
])
|
||||
|
||||
// Step 1: Create MPT issuance
|
||||
process.stdout.write('Setting up tutorial: 1/7\r')
|
||||
|
||||
const mptCreateResult = await client.submitAndWait(
|
||||
{
|
||||
TransactionType: 'MPTokenIssuanceCreate',
|
||||
Account: mptIssuer.address,
|
||||
Flags:
|
||||
xrpl.MPTokenIssuanceCreateFlags.tfMPTCanTransfer |
|
||||
xrpl.MPTokenIssuanceCreateFlags.tfMPTCanLock,
|
||||
AssetScale: 2,
|
||||
TransferFee: 0,
|
||||
MaximumAmount: '1000000000000',
|
||||
MPTokenMetadata: xrpl.encodeMPTokenMetadata({
|
||||
ticker: 'USTST',
|
||||
name: 'USTST Stablecoin',
|
||||
desc: 'A test stablecoin token',
|
||||
icon: 'example.org/ustst-icon.png',
|
||||
asset_class: 'rwa',
|
||||
asset_subclass: 'stablecoin',
|
||||
issuer_name: 'Test Stablecoin Inc',
|
||||
uris: [
|
||||
{
|
||||
uri: 'example.org/ustst',
|
||||
category: 'website',
|
||||
title: 'USTST Official Website'
|
||||
},
|
||||
{
|
||||
uri: 'example.org/ustst/reserves',
|
||||
category: 'attestation',
|
||||
title: 'Reserve Attestation Reports'
|
||||
},
|
||||
{
|
||||
uri: 'example.org/ustst/docs',
|
||||
category: 'docs',
|
||||
title: 'USTST Documentation'
|
||||
}
|
||||
],
|
||||
additional_info: {
|
||||
backing: 'USD',
|
||||
reserve_ratio: '1:1'
|
||||
}
|
||||
})
|
||||
},
|
||||
{ wallet: mptIssuer, autofill: true }
|
||||
)
|
||||
|
||||
const mptIssuanceId = mptCreateResult.result.meta.mpt_issuance_id
|
||||
|
||||
// Step 2: Create Permissioned Domain
|
||||
process.stdout.write('Setting up tutorial: 2/7\r')
|
||||
|
||||
const credType = 'VaultAccess'
|
||||
const domainResult = await client.submitAndWait(
|
||||
{
|
||||
TransactionType: 'PermissionedDomainSet',
|
||||
Account: domainOwner.address,
|
||||
AcceptedCredentials: [
|
||||
{
|
||||
Credential: {
|
||||
Issuer: domainOwner.address,
|
||||
CredentialType: xrpl.convertStringToHex(credType)
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{ wallet: domainOwner, autofill: true }
|
||||
)
|
||||
|
||||
const domainId = domainResult.result.meta.AffectedNodes.find(
|
||||
(node) => node.CreatedNode?.LedgerEntryType === 'PermissionedDomain'
|
||||
).CreatedNode.LedgerIndex
|
||||
|
||||
// Step 3: Create depositor account with credentials and MPT balance
|
||||
process.stdout.write('Setting up tutorial: 3/7\r')
|
||||
|
||||
await Promise.all([
|
||||
client.submitAndWait(
|
||||
{
|
||||
TransactionType: 'CredentialCreate',
|
||||
Account: domainOwner.address,
|
||||
Subject: depositor.address,
|
||||
CredentialType: xrpl.convertStringToHex(credType)
|
||||
},
|
||||
{ wallet: domainOwner, autofill: true }
|
||||
),
|
||||
client.submitAndWait(
|
||||
{
|
||||
TransactionType: 'Batch',
|
||||
Account: depositor.address,
|
||||
Flags: xrpl.BatchFlags.tfAllOrNothing,
|
||||
RawTransactions: [
|
||||
{
|
||||
RawTransaction: {
|
||||
TransactionType: 'CredentialAccept',
|
||||
Account: depositor.address,
|
||||
Issuer: domainOwner.address,
|
||||
CredentialType: xrpl.convertStringToHex(credType),
|
||||
Flags: xrpl.GlobalFlags.tfInnerBatchTxn
|
||||
}
|
||||
},
|
||||
{
|
||||
RawTransaction: {
|
||||
TransactionType: 'MPTokenAuthorize',
|
||||
Account: depositor.address,
|
||||
MPTokenIssuanceID: mptIssuanceId,
|
||||
Flags: xrpl.GlobalFlags.tfInnerBatchTxn
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{ wallet: depositor, autofill: true }
|
||||
)
|
||||
])
|
||||
|
||||
process.stdout.write('Setting up tutorial: 4/7\r')
|
||||
|
||||
const paymentResult = await client.submitAndWait(
|
||||
{
|
||||
TransactionType: 'Payment',
|
||||
Account: mptIssuer.address,
|
||||
Destination: depositor.address,
|
||||
Amount: {
|
||||
mpt_issuance_id: mptIssuanceId,
|
||||
value: '10000'
|
||||
}
|
||||
},
|
||||
{ wallet: mptIssuer, autofill: true }
|
||||
)
|
||||
|
||||
if (paymentResult.result.meta.TransactionResult !== 'tesSUCCESS') {
|
||||
console.error('\nPayment failed:', paymentResult.result.meta.TransactionResult)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Step 5: Create a vault for deposit/withdraw examples
|
||||
process.stdout.write('Setting up tutorial: 5/7\r')
|
||||
|
||||
const vaultCreateResult = await client.submitAndWait(
|
||||
{
|
||||
TransactionType: 'VaultCreate',
|
||||
Account: vaultOwner.address,
|
||||
Asset: {
|
||||
mpt_issuance_id: mptIssuanceId
|
||||
},
|
||||
Flags: xrpl.VaultCreateFlags.tfVaultPrivate,
|
||||
DomainID: domainId,
|
||||
Data: xrpl.convertStringToHex(
|
||||
JSON.stringify({ n: "LATAM Fund II", w: "examplefund.com" })
|
||||
),
|
||||
MPTokenMetadata: xrpl.encodeMPTokenMetadata({
|
||||
ticker: 'SHARE1',
|
||||
name: 'Vault Shares',
|
||||
desc: 'Proportional ownership shares of the vault',
|
||||
icon: 'example.com/vault-shares-icon.png',
|
||||
asset_class: 'defi',
|
||||
issuer_name: 'Vault Owner',
|
||||
uris: [
|
||||
{
|
||||
uri: 'example.com/asset',
|
||||
category: 'website',
|
||||
title: 'Asset Website'
|
||||
},
|
||||
{
|
||||
uri: 'example.com/docs',
|
||||
category: 'docs',
|
||||
title: 'Docs'
|
||||
}
|
||||
],
|
||||
additional_info: {
|
||||
example_info: 'test'
|
||||
}
|
||||
}),
|
||||
AssetsMaximum: '0',
|
||||
WithdrawalPolicy:
|
||||
xrpl.VaultWithdrawalPolicy.vaultStrategyFirstComeFirstServe
|
||||
},
|
||||
{ wallet: vaultOwner, autofill: true }
|
||||
)
|
||||
|
||||
const vaultNode = vaultCreateResult.result.meta.AffectedNodes.find(
|
||||
(node) => node.CreatedNode?.LedgerEntryType === 'Vault'
|
||||
)
|
||||
const vaultID = vaultNode.CreatedNode.LedgerIndex
|
||||
const vaultShareMPTIssuanceId = vaultNode.CreatedNode.NewFields.ShareMPTID
|
||||
|
||||
// Step 6: Make an initial deposit so withdraw example has shares to work with
|
||||
process.stdout.write('Setting up tutorial: 6/7\r')
|
||||
|
||||
const initialDepositResult = await client.submitAndWait(
|
||||
{
|
||||
TransactionType: 'VaultDeposit',
|
||||
Account: depositor.address,
|
||||
VaultID: vaultID,
|
||||
Amount: {
|
||||
mpt_issuance_id: mptIssuanceId,
|
||||
value: '1000'
|
||||
}
|
||||
},
|
||||
{ wallet: depositor, autofill: true }
|
||||
)
|
||||
|
||||
if (initialDepositResult.result.meta.TransactionResult !== 'tesSUCCESS') {
|
||||
console.error('\nInitial deposit failed:', initialDepositResult.result.meta.TransactionResult)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Step 7: Save setup data to file
|
||||
process.stdout.write('Setting up tutorial: 7/7\r')
|
||||
|
||||
const setupData = {
|
||||
mptIssuer: {
|
||||
address: mptIssuer.address,
|
||||
seed: mptIssuer.seed
|
||||
},
|
||||
mptIssuanceId,
|
||||
domainOwner: {
|
||||
address: domainOwner.address,
|
||||
seed: domainOwner.seed
|
||||
},
|
||||
domainId,
|
||||
credentialType: credType,
|
||||
depositor: {
|
||||
address: depositor.address,
|
||||
seed: depositor.seed
|
||||
},
|
||||
vaultOwner: {
|
||||
address: vaultOwner.address,
|
||||
seed: vaultOwner.seed
|
||||
},
|
||||
vaultID,
|
||||
vaultShareMPTIssuanceId
|
||||
}
|
||||
|
||||
fs.writeFileSync('vaultSetup.json', JSON.stringify(setupData, null, 2))
|
||||
|
||||
process.stdout.write('Setting up tutorial: Complete!\n')
|
||||
|
||||
await client.disconnect()
|
||||
159
_code-samples/vaults/js/withdraw.js
Normal file
159
_code-samples/vaults/js/withdraw.js
Normal file
@@ -0,0 +1,159 @@
|
||||
import xrpl from "xrpl"
|
||||
import { execSync } from "child_process"
|
||||
import fs from "fs"
|
||||
|
||||
// Auto-run setup if needed
|
||||
if (!fs.existsSync("vaultSetup.json")) {
|
||||
console.log(`\n=== Vault setup data doesn't exist. Running setup script... ===\n`)
|
||||
execSync("node vaultSetup.js", { stdio: "inherit" })
|
||||
}
|
||||
|
||||
// Load setup data
|
||||
const setupData = JSON.parse(fs.readFileSync("vaultSetup.json", "utf8"))
|
||||
|
||||
// Connect to the network
|
||||
const client = new xrpl.Client("wss://s.devnet.rippletest.net:51233")
|
||||
await client.connect()
|
||||
|
||||
// You can replace these values with your own
|
||||
const depositor = xrpl.Wallet.fromSeed(setupData.depositor.seed)
|
||||
const vaultID = setupData.vaultID
|
||||
const assetMPTIssuanceId = setupData.mptIssuanceId
|
||||
const shareMPTIssuanceId = setupData.vaultShareMPTIssuanceId
|
||||
|
||||
console.log(`Depositor address: ${depositor.address}`)
|
||||
console.log(`Vault ID: ${vaultID}`)
|
||||
console.log(`Asset MPT issuance ID: ${assetMPTIssuanceId}`)
|
||||
console.log(`Vault share MPT issuance ID: ${shareMPTIssuanceId}`)
|
||||
|
||||
const withdrawAmount = "1"
|
||||
|
||||
// Get initial vault state ----------------------
|
||||
console.log("\n=== Getting initial vault state... ===")
|
||||
const initialVaultInfo = await client.request({
|
||||
command: "vault_info",
|
||||
vault_id: vaultID,
|
||||
ledger_index: "validated"
|
||||
})
|
||||
|
||||
console.log(`Initial vault state:`)
|
||||
console.log(` Assets Total: ${initialVaultInfo.result.vault.AssetsTotal}`)
|
||||
console.log(` Assets Available: ${initialVaultInfo.result.vault.AssetsAvailable}`)
|
||||
|
||||
// Check depositor's share balance ----------------------
|
||||
console.log("\n=== Checking depositor's share balance... ===")
|
||||
try {
|
||||
const shareBalanceResult = await client.request({
|
||||
command: "ledger_entry",
|
||||
mptoken: {
|
||||
mpt_issuance_id: shareMPTIssuanceId,
|
||||
account: depositor.address
|
||||
},
|
||||
ledger_index: "validated"
|
||||
})
|
||||
|
||||
const shareBalance = shareBalanceResult.result.node.MPTAmount
|
||||
console.log(`Shares held: ${shareBalance}`)
|
||||
} catch (error) {
|
||||
if (error.data?.error === 'entryNotFound') {
|
||||
console.error(`Error: The depositor doesn't hold any vault shares with ID: ${shareMPTIssuanceId}.`)
|
||||
}
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Prepare VaultWithdraw transaction ----------------------
|
||||
console.log(`\n=== Preparing VaultWithdraw transaction ===`)
|
||||
const vaultWithdrawTx = {
|
||||
TransactionType: "VaultWithdraw",
|
||||
Account: depositor.address,
|
||||
VaultID: vaultID,
|
||||
Amount: {
|
||||
mpt_issuance_id: assetMPTIssuanceId,
|
||||
value: withdrawAmount
|
||||
},
|
||||
// Optional: Add Destination field to send assets to a different account
|
||||
// Destination: "rGg4tHPRGJfewwJkd8immCFx9uSo2GgcoY"
|
||||
}
|
||||
|
||||
// Validate the transaction structure before submitting
|
||||
xrpl.validate(vaultWithdrawTx)
|
||||
console.log(JSON.stringify(vaultWithdrawTx, null, 2))
|
||||
|
||||
// Submit VaultWithdraw transaction ----------------------
|
||||
console.log("\n=== Submitting VaultWithdraw transaction... ===")
|
||||
const withdrawResult = await client.submitAndWait(vaultWithdrawTx, {
|
||||
wallet: depositor,
|
||||
autofill: true,
|
||||
})
|
||||
if (withdrawResult.result.meta.TransactionResult !== "tesSUCCESS") {
|
||||
const result_code = withdrawResult.result.meta.TransactionResult
|
||||
console.error("Error: Unable to withdraw from vault:", result_code)
|
||||
await client.disconnect()
|
||||
process.exit(1)
|
||||
}
|
||||
console.log("Withdrawal successful!")
|
||||
|
||||
// Extract vault state from transaction metadata ----------------------
|
||||
console.log("\n=== Vault state after withdrawal ===")
|
||||
const affectedNodes = withdrawResult.result.meta.AffectedNodes
|
||||
const vaultNode = affectedNodes.find(
|
||||
(node) => {
|
||||
const modifiedNode = node.ModifiedNode || node.DeletedNode
|
||||
return (
|
||||
modifiedNode &&
|
||||
modifiedNode.LedgerEntryType === "Vault" &&
|
||||
modifiedNode.LedgerIndex === vaultID
|
||||
)
|
||||
}
|
||||
)
|
||||
if (vaultNode) {
|
||||
if (vaultNode.DeletedNode) {
|
||||
console.log(` Vault empty (all assets withdrawn)`)
|
||||
} else {
|
||||
const vaultFields = vaultNode.ModifiedNode.FinalFields
|
||||
console.log(` Assets Total: ${vaultFields.AssetsTotal}`)
|
||||
console.log(` Assets Available: ${vaultFields.AssetsAvailable}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Get the depositor's share balance ----------------------
|
||||
console.log("\n=== Depositor's share balance ==")
|
||||
const depositorShareNode = affectedNodes.find((node) => {
|
||||
const modifiedNode = node.ModifiedNode || node.DeletedNode
|
||||
return (
|
||||
modifiedNode &&
|
||||
modifiedNode.LedgerEntryType === "MPToken" &&
|
||||
modifiedNode.FinalFields?.Account === depositor.address &&
|
||||
modifiedNode.FinalFields?.MPTokenIssuanceID === shareMPTIssuanceId
|
||||
)
|
||||
})
|
||||
if (depositorShareNode) {
|
||||
if (depositorShareNode.DeletedNode) {
|
||||
console.log(`No more shares held (redeemed all shares)`)
|
||||
} else {
|
||||
const shareFields = depositorShareNode.ModifiedNode.FinalFields
|
||||
console.log(`Shares held: ${shareFields.MPTAmount}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Get the depositor's asset balance ----------------------
|
||||
console.log("\n=== Depositor's asset balance ==")
|
||||
const depositorAssetNode = affectedNodes.find((node) => {
|
||||
const assetNode = node.ModifiedNode || node.CreatedNode
|
||||
const fields = assetNode?.FinalFields || assetNode?.NewFields
|
||||
return (
|
||||
assetNode &&
|
||||
assetNode.LedgerEntryType === "MPToken" &&
|
||||
fields?.Account === depositor.address &&
|
||||
fields?.MPTokenIssuanceID === assetMPTIssuanceId
|
||||
)
|
||||
})
|
||||
if (depositorAssetNode) {
|
||||
const assetNode = depositorAssetNode.ModifiedNode || depositorAssetNode.CreatedNode
|
||||
const assetFields = assetNode.FinalFields || assetNode.NewFields
|
||||
console.log(`Balance: ${assetFields.MPTAmount}`)
|
||||
}
|
||||
|
||||
await client.disconnect()
|
||||
|
||||
@@ -26,7 +26,7 @@ const logos = {
|
||||
],
|
||||
developer_tooling: ["cryptum", "evernode", "threezy", "tokenize"],
|
||||
interoperability: ["multichain"],
|
||||
wallet: ["crossmark", "edge", "gem-wallet", "xumm", "joey-wallet"],
|
||||
wallet: ["crossmark", "edge", "gem-wallet", "xumm", "joey-wallet", "bifrost-wallet", "bitget-wallet"],
|
||||
nfts: [
|
||||
"aesthetes",
|
||||
"audiotarky",
|
||||
@@ -413,6 +413,24 @@ const cardsData = [
|
||||
category_name: "Wallet",
|
||||
link: "https://xaman.app/#team",
|
||||
},
|
||||
{
|
||||
id: "bifrost-wallet",
|
||||
title: "Bifrost Wallet",
|
||||
description:
|
||||
"Bifrost Wallet is a secure, independently audited self-custodial wallet for the XRP Ledger with multi-chain support. Purpose-built for XRPFi: a wallet where your XRP works for you and earns yield.",
|
||||
category_id: "wallet",
|
||||
category_name: "Wallet",
|
||||
link: "https://bifrostwallet.com/",
|
||||
},
|
||||
{
|
||||
id: "bitget-wallet",
|
||||
title: "Bitget Wallet",
|
||||
description:
|
||||
"Bitget Wallet is a non-custodial wallet designed to make crypto simple and secure for everyone.",
|
||||
category_id: "wallet",
|
||||
category_name: "Wallet",
|
||||
link: "https://web3.bitget.com/",
|
||||
},
|
||||
];
|
||||
|
||||
const featured_categories = {
|
||||
@@ -459,7 +477,7 @@ const uses = [
|
||||
{
|
||||
id: "wallet",
|
||||
title: "Wallet",
|
||||
number: 5,
|
||||
number: 7,
|
||||
description:
|
||||
"Build digital wallets to store passwords and interact with various blockchains to send and receive digital assets, including XRP."
|
||||
},
|
||||
|
||||
@@ -18,19 +18,15 @@ const links = [
|
||||
];
|
||||
|
||||
const softwallets = [
|
||||
{ href: "https://towolabs.com/", id: "wallet-towo", alt: "Towo" },
|
||||
{ href: "https://xaman.app/", id: "wallet-xumm", alt: "Xaman" },
|
||||
{ href: "https://trustwallet.com/", id: "wallet-trust", alt: "Trust Wallet" },
|
||||
{
|
||||
href: "https://gatehub.net/",
|
||||
id: "wallet-gatehub",
|
||||
alt: "Gatehub",
|
||||
imgclasses: "invertible-img",
|
||||
},
|
||||
{ href: "https://gemwallet.app/", id: "wallet-gem", alt: "Gem Wallet" },
|
||||
{ href: "https://bifrostwallet.com/", id: "wallet-bifrost", alt: "Bifrost Wallet" },
|
||||
{ href: "https://web3.bitget.com/", id: "wallet-bitget", alt: "Bitget Wallet" },
|
||||
{ href: "https://coin.space/", id: "wallet-coin", alt: "Coin Space" },
|
||||
{ href: "https://crossmark.io/", id: "wallet-crossmark", alt: "Crossmark Wallet" },
|
||||
{ href: "https://gatehub.net/", id: "wallet-gatehub", alt: "Gatehub", imgclasses: "invertible-img" },
|
||||
{ href: "https://gemwallet.app/", id: "wallet-gem", alt: "Gem Wallet" },
|
||||
{ href: "https://joeywallet.xyz/", id: "wallet-joey", alt: "Joey Wallet" },
|
||||
{ href: "https://trustwallet.com/", id: "wallet-trust", alt: "Trust Wallet" },
|
||||
{ href: "https://xaman.app/", id: "wallet-xumm", alt: "Xaman" }
|
||||
];
|
||||
|
||||
const hardwallets = [
|
||||
@@ -61,16 +57,8 @@ const exchanges = [
|
||||
{ href: "https://www.liquid.com/", id: "exch-liquid", alt: "Liquid" },
|
||||
{ href: "https://www.lmax.com/", id: "exch-lmax", alt: "LMAX" },
|
||||
{ href: "https://www.bitfinex.com/", id: "exch-bitfinex", alt: "Bitfinex" },
|
||||
{
|
||||
href: "https://www.etoro.com/crypto/exchange/",
|
||||
id: "exch-etoro",
|
||||
alt: "eToro",
|
||||
},
|
||||
{
|
||||
href: "https://currency.com",
|
||||
id: "exch-currency-com",
|
||||
alt: "Currency.com",
|
||||
},
|
||||
{ href: "https://www.etoro.com/crypto/exchange/", id: "exch-etoro", alt: "eToro"},
|
||||
{ href: "https://currency.com", id: "exch-currency-com", alt: "Currency.com"},
|
||||
{ href: "https://bittrex.com/", id: "exch-bittrex", alt: "Bittrex" },
|
||||
];
|
||||
|
||||
|
||||
192
blog/2026/clio-2.7.0.md
Normal file
192
blog/2026/clio-2.7.0.md
Normal file
@@ -0,0 +1,192 @@
|
||||
---
|
||||
category: 2026
|
||||
date: "2026-01-27"
|
||||
template: '../../@theme/templates/blogpost'
|
||||
seo:
|
||||
title: Introducing Clio version 2.7.0
|
||||
description: Version 2.7.0 of Clio, an XRP Ledger API server optimized for HTTP and WebSocket API calls, is now available. This release adds new features and bug fixes.
|
||||
labels:
|
||||
- Clio Release Notes
|
||||
markdown:
|
||||
editPage:
|
||||
hide: true
|
||||
---
|
||||
# Introducing Clio version 2.7.0
|
||||
|
||||
Version 2.7.0 of Clio, an XRP Ledger API server optimized for HTTP and WebSocket API calls, is now available. This release adds new features and bug fixes.
|
||||
|
||||
## Install / Upgrade
|
||||
|
||||
| Package |
|
||||
| :------- |
|
||||
| [Clio Server Linux Release (GCC)](https://github.com/XRPLF/clio/releases/download/2.7.0/clio_server_Linux_Release_gcc.zip) |
|
||||
| [Clio Server Linux Debian Release (amd64)](https://github.com/XRPLF/clio/releases/download/2.7.0/clio_2.7.0_amd64.deb) |
|
||||
| [Clio Server macOS Release (Apple Clang 17)](https://github.com/XRPLF/clio/releases/download/2.7.0/clio_server_macOS_Release_apple-clang.zip) |
|
||||
|
||||
For other platforms, please [build from source](https://github.com/XRPLF/clio/releases/tag/2.7.0). The most recent commit in the git log should be:
|
||||
|
||||
```text
|
||||
Author: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
|
||||
Date: Thu Jan 15 19:03:47 2026 +0000
|
||||
|
||||
ci: Restart colima on macOS (#2923)
|
||||
```
|
||||
|
||||
## What's Changed
|
||||
|
||||
See the [Full Changelog on GitHub](https://github.com/XRPLF/clio/compare/2.6.0...2.7.0).
|
||||
|
||||
### Features
|
||||
|
||||
- Adds `account_mptoken_issuances` API method to retrieve all `MPTokenIssuances` created by a specified account, and `account_mptokens` API method to retrieve all `MPTokens` held by a specified account. ([#2680](https://github.com/XRPLF/clio/pull/2680))
|
||||
- Adds DynamicMPT support to `account_mptoken_issuances` handler. ([#2820](https://github.com/XRPLF/clio/pull/2820))
|
||||
|
||||
### Improvements
|
||||
|
||||
- Removed old ETL implementation and enabled ETLng by default. ([#2752](https://github.com/XRPLF/clio/pull/2752))
|
||||
- Added async framework `submit` method for running one-shot tasks that don't require a handle to retrieve the result. ([#2751](https://github.com/XRPLF/clio/pull/2751))
|
||||
- Updated the Ledger Publisher to use async framework instead of directly using `io_context`. ([#2756](https://github.com/XRPLF/clio/pull/2756))
|
||||
- Added support for normal/high priority to `WorkQueue`. ([#2721](https://github.com/XRPLF/clio/pull/2721))
|
||||
- Added ability to read and write `LedgerCache` to file. ([#2761](https://github.com/XRPLF/clio/pull/2761))
|
||||
- Added graceful shutdown for old web server. ([#2786](https://github.com/XRPLF/clio/pull/2786))
|
||||
- Prometheus requests are now handled in `WorkQueue`. ([#2790](https://github.com/XRPLF/clio/pull/2790))
|
||||
- Added observable value utility to enable reactive approach across the codebase. ([#2831](https://github.com/XRPLF/clio/pull/2831))
|
||||
- Added option to save cache asynchronously. ([#2883](https://github.com/XRPLF/clio/pull/2883))
|
||||
- Added basic support for channels. ([#2859](https://github.com/XRPLF/clio/pull/2859))
|
||||
- Added build information to `clio_server --version` command. ([#2893](https://github.com/XRPLF/clio/pull/2893))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fixed an issue where `account_info` was omitting the `signer_lists` field when requested for accounts with no signer lists. ([#2746](https://github.com/XRPLF/clio/pull/2746))
|
||||
- Fixed an issue where `ledger_entry` error codes didn't match with `rippled`. ([#2549](https://github.com/XRPLF/clio/pull/2549))
|
||||
- Enhanced cache saving error to include more information. ([#2794](https://github.com/XRPLF/clio/pull/2794))
|
||||
- Fixed `WorkQueue` contention issues. ([#2866](https://github.com/XRPLF/clio/pull/2866))
|
||||
- Fixed issue where failed asserts in tests produced no output. ([#2905](https://github.com/XRPLF/clio/pull/2905))
|
||||
- Added workaround for an edge case exception in `AmendmentCenter`. ([#2897](https://github.com/XRPLF/clio/pull/2897))
|
||||
- Fixed `WorkQueue` performance. ([#2887](https://github.com/XRPLF/clio/pull/2887))
|
||||
|
||||
### Refactor
|
||||
|
||||
- Refactored duplicate `ledger_index` pattern in RPC handlers into a common function. ([#2755](https://github.com/XRPLF/clio/pull/2755))
|
||||
- Refactored `getLedgerIndex` to return `std::expected` instead of throwing exceptions. ([#2788](https://github.com/XRPLF/clio/pull/2788))
|
||||
- Added writing command to `etl::SystemState`. ([#2842](https://github.com/XRPLF/clio/pull/2842))
|
||||
|
||||
### Documentation
|
||||
|
||||
- Removed `logging.md` from README. ([#2710](https://github.com/XRPLF/clio/pull/2710))
|
||||
- Fixed `graceful_period` description. ([#2791](https://github.com/XRPLF/clio/pull/2791))
|
||||
|
||||
### Styling
|
||||
|
||||
- Fixed pre-commit style issues. ([#2743](https://github.com/XRPLF/clio/pull/2743))
|
||||
- Fixed comment in `pre-commit-autoupdate.yml`. ([#2750](https://github.com/XRPLF/clio/pull/2750))
|
||||
- Fixed hadolint issues. ([#2777](https://github.com/XRPLF/clio/pull/2777))
|
||||
- Added black pre-commit hook. ([#2811](https://github.com/XRPLF/clio/pull/2811))
|
||||
- Updated pre-commit hooks. ([#2825](https://github.com/XRPLF/clio/pull/2825), [#2875](https://github.com/XRPLF/clio/pull/2875))
|
||||
- Used `shfmt` for shell scripts. ([#2841](https://github.com/XRPLF/clio/pull/2841))
|
||||
- Fixed clang-tidy error. ([#2901](https://github.com/XRPLF/clio/pull/2901))
|
||||
|
||||
### Testing
|
||||
|
||||
- Fixed flaky `DeadlineIsHandledCorrectly` test. ([#2716](https://github.com/XRPLF/clio/pull/2716))
|
||||
- Fixed flaky test. ([#2729](https://github.com/XRPLF/clio/pull/2729))
|
||||
|
||||
### Miscellaneous Tasks
|
||||
|
||||
- Pinned all GitHub actions. ([#2712](https://github.com/XRPLF/clio/pull/2712))
|
||||
- Updated CI to use intermediate environment variables for improved security. ([#2713](https://github.com/XRPLF/clio/pull/2713))
|
||||
- Updated CI to save full logs for failed sanitizer tests. ([#2715](https://github.com/XRPLF/clio/pull/2715))
|
||||
- Enabled clang asan builds. ([#2717](https://github.com/XRPLF/clio/pull/2717))
|
||||
- [DEPENDABOT] bump actions/upload-artifact from 4.6.2 to 5.0.0. ([#2722](https://github.com/XRPLF/clio/pull/2722))
|
||||
- [DEPENDABOT] bump actions/upload-artifact from 4.6.2 to 5.0.0 in /.github/actions/code-coverage. ([#2725](https://github.com/XRPLF/clio/pull/2725))
|
||||
- [DEPENDABOT] bump actions/download-artifact from 5.0.0 to 6.0.0. ([#2723](https://github.com/XRPLF/clio/pull/2723))
|
||||
- Improved pre-commit failure message. ([#2720](https://github.com/XRPLF/clio/pull/2720))
|
||||
- Updated CI to use XRPLF/get-nproc Github action. ([#2727](https://github.com/XRPLF/clio/pull/2727))
|
||||
- [DEPENDABOT] bump actions/checkout from 4.3.0 to 5.0.0. ([#2724](https://github.com/XRPLF/clio/pull/2724))
|
||||
- Added date to nightly release version. ([#2731](https://github.com/XRPLF/clio/pull/2731))
|
||||
- Fixed nightly commits link. ([#2738](https://github.com/XRPLF/clio/pull/2738))
|
||||
- Updated CI to use new prepare-runner. ([#2742](https://github.com/XRPLF/clio/pull/2742))
|
||||
- Updated tooling in Docker images. ([#2737](https://github.com/XRPLF/clio/pull/2737))
|
||||
- Installed pre-commit in the main CI image. ([#2744](https://github.com/XRPLF/clio/pull/2744))
|
||||
- Updated docker images. ([#2745](https://github.com/XRPLF/clio/pull/2745))
|
||||
- Added date to nightly release title. ([#2748](https://github.com/XRPLF/clio/pull/2748))
|
||||
- Updated prepare-runner to fix `ccache` on macOS. ([#2749](https://github.com/XRPLF/clio/pull/2749))
|
||||
- Removed backticks from release date. ([#2754](https://github.com/XRPLF/clio/pull/2754))
|
||||
- Specified apple-clang 17.0 in Conan profile. ([#2757](https://github.com/XRPLF/clio/pull/2757))
|
||||
- Fixed pre-commit hook failing on empty file. ([#2766](https://github.com/XRPLF/clio/pull/2766))
|
||||
- [DEPENDABOT] bump docker/setup-qemu-action from 3.6.0 to 3.7.0 in /.github/actions/build-docker-image. ([#2763](https://github.com/XRPLF/clio/pull/2763))
|
||||
- [DEPENDABOT] bump docker/metadata-action from 5.8.0 to 5.9.0 in /.github/actions/build-docker-image. ([#2762](https://github.com/XRPLF/clio/pull/2762))
|
||||
- Changed default `max_queue_size` to 1000. ([#2771](https://github.com/XRPLF/clio/pull/2771))
|
||||
- Specified bash as default shell in Github workflows. ([#2772](https://github.com/XRPLF/clio/pull/2772))
|
||||
- Updated CI to use `ucontext` in ASAN builds. ([#2775](https://github.com/XRPLF/clio/pull/2775))
|
||||
- Updated `xrpl` version to 3.0.0-rc1. ([#2776](https://github.com/XRPLF/clio/pull/2776))
|
||||
- Forced usage of `ucontext` with ASAN. ([#2774](https://github.com/XRPLF/clio/pull/2774))
|
||||
- Removed redundant silencing of ASAN errors in CI. ([#2779](https://github.com/XRPLF/clio/pull/2779))
|
||||
- Updated CI to use environment variables instead of input. ([#2781](https://github.com/XRPLF/clio/pull/2781))
|
||||
- Improved cache implementation. ([#2780](https://github.com/XRPLF/clio/pull/2780))
|
||||
- Updated nudb recipe to remove linker warnings. ([#2787](https://github.com/XRPLF/clio/pull/2787))
|
||||
- Updated CI to use environment variables instead of input in cache-key. ([#2789](https://github.com/XRPLF/clio/pull/2789))
|
||||
- Added defines for asan/tsan to Conan profile. ([#2784](https://github.com/XRPLF/clio/pull/2784))
|
||||
- Enabled TSAN in CI. ([#2785](https://github.com/XRPLF/clio/pull/2785))
|
||||
- Updated CI to stop downloading `ccache` on develop branch. ([#2792](https://github.com/XRPLF/clio/pull/2792))
|
||||
- Updated CI to always upload cache on develop. ([#2793](https://github.com/XRPLF/clio/pull/2793))
|
||||
- [DEPENDABOT] bump peter-evans/create-pull-request from 7.0.8 to 7.0.9. ([#2805](https://github.com/XRPLF/clio/pull/2805))
|
||||
- [DEPENDABOT] bump actions/checkout from 5.0.0 to 6.0.0. ([#2806](https://github.com/XRPLF/clio/pull/2806))
|
||||
- Updated `spdlog` and `fmt` libraries. ([#2804](https://github.com/XRPLF/clio/pull/2804))
|
||||
- Ran clang-tidy multiple times to ensure all issues were resolved. ([#2803](https://github.com/XRPLF/clio/pull/2803))
|
||||
- Fixed Repeat-based tests TSAN issues. ([#2810](https://github.com/XRPLF/clio/pull/2810))
|
||||
- Fixed `WebServerAdminTestsSuit` TSAN issues. ([#2809](https://github.com/XRPLF/clio/pull/2809))
|
||||
- Used `boost::asio::ssl::stream` instead of `boost::beast::ssl_stream`. ([#2814](https://github.com/XRPLF/clio/pull/2814))
|
||||
- Installed latest Ninja in images. ([#2813](https://github.com/XRPLF/clio/pull/2813))
|
||||
- Updated images to use latest Ninja. ([#2817](https://github.com/XRPLF/clio/pull/2817))
|
||||
- Updated lockfile. ([#2818](https://github.com/XRPLF/clio/pull/2818))
|
||||
- Added mathbunnyru to maintainers. ([#2823](https://github.com/XRPLF/clio/pull/2823))
|
||||
- Fixed TSAN async-signal-unsafe issue. ([#2824](https://github.com/XRPLF/clio/pull/2824))
|
||||
- [DEPENDABOT] bump docker/metadata-action from 5.9.0 to 5.10.0 in /.github/actions/build-docker-image. ([#2826](https://github.com/XRPLF/clio/pull/2826))
|
||||
- [DEPENDABOT] bump actions/checkout from 6.0.0 to 6.0.1. ([#2837](https://github.com/XRPLF/clio/pull/2837))
|
||||
- [DEPENDABOT] bump peter-evans/create-pull-request from 7.0.9 to 7.0.11. ([#2836](https://github.com/XRPLF/clio/pull/2836))
|
||||
- [DEPENDABOT] bump ytanikin/pr-conventional-commits from 1.4.2 to 1.5.1. ([#2835](https://github.com/XRPLF/clio/pull/2835))
|
||||
- Reduced delay in ETL taskman. ([#2802](https://github.com/XRPLF/clio/pull/2802))
|
||||
- Added systemd file to the Debian package. ([#2844](https://github.com/XRPLF/clio/pull/2844))
|
||||
- Switched to `xrpl` version 3.0.0. ([#2843](https://github.com/XRPLF/clio/pull/2843))
|
||||
- Added a Debian package to the Github release. ([#2850](https://github.com/XRPLF/clio/pull/2850))
|
||||
- Added a script to regenerate the Conan lockfile. ([#2849](https://github.com/XRPLF/clio/pull/2849))
|
||||
- [DEPENDABOT] bump tj-actions/changed-files from 46.0.5 to 47.0.1. ([#2853](https://github.com/XRPLF/clio/pull/2853))
|
||||
- [DEPENDABOT] bump peter-evans/create-pull-request from 7.0.11 to 8.0.0. ([#2854](https://github.com/XRPLF/clio/pull/2854))
|
||||
- [DEPENDABOT] bump actions/download-artifact from 6.0.0 to 7.0.0. ([#2855](https://github.com/XRPLF/clio/pull/2855))
|
||||
- [DEPENDABOT] bump actions/upload-artifact from 5.0.0 to 6.0.0. ([#2856](https://github.com/XRPLF/clio/pull/2856))
|
||||
- [DEPENDABOT] bump codecov/codecov-action from 5.5.1 to 5.5.2. ([#2857](https://github.com/XRPLF/clio/pull/2857))
|
||||
- [DEPENDABOT] bump actions/upload-artifact from 5.0.0 to 6.0.0 in /.github/actions/code-coverage. ([#2858](https://github.com/XRPLF/clio/pull/2858))
|
||||
- Updated shared Github actions. ([#2852](https://github.com/XRPLF/clio/pull/2852))
|
||||
- Removed unnecessary creation of build directory in CI. ([#2867](https://github.com/XRPLF/clio/pull/2867))
|
||||
- [DEPENDABOT] bump docker/setup-buildx-action from 3.11.1 to 3.12.0 in /.github/actions/build-docker-image. ([#2872](https://github.com/XRPLF/clio/pull/2872))
|
||||
- [DEPENDABOT] bump docker/setup-buildx-action from 3.11.1 to 3.12.0. ([#2870](https://github.com/XRPLF/clio/pull/2870))
|
||||
- [DEPENDABOT] bump actions/cache from 4.3.0 to 5.0.1. ([#2871](https://github.com/XRPLF/clio/pull/2871))
|
||||
- Updated prepare-runner in Github actions and workflows. ([#2889](https://github.com/XRPLF/clio/pull/2889))
|
||||
- Fixed branch name and commit SHA for GitHub PRs. ([#2888](https://github.com/XRPLF/clio/pull/2888))
|
||||
- Updated CI to show `ccache` stats. ([#2902](https://github.com/XRPLF/clio/pull/2902))
|
||||
- Changed build process to pass version explicitly instead of relying on tags. ([#2904](https://github.com/XRPLF/clio/pull/2904))
|
||||
- Updated `gtest` and `spdlog`. ([#2908](https://github.com/XRPLF/clio/pull/2908))
|
||||
- Updated tooling in Docker images. ([#2907](https://github.com/XRPLF/clio/pull/2907))
|
||||
- Updated CI workflows to use new Docker images and GitHub actions. ([#2909](https://github.com/XRPLF/clio/pull/2909))
|
||||
- Updated CI to use actual build date instead of date of last commit. ([#2911](https://github.com/XRPLF/clio/pull/2911))
|
||||
- Updated CI to use environment variable for `BUILD_TYPE` in `reusable-build.yml`. ([#2913](https://github.com/XRPLF/clio/pull/2913))
|
||||
- Changed build date format. ([#2914](https://github.com/XRPLF/clio/pull/2914))
|
||||
- Updated CI to restart colima on macOS. ([#2923](https://github.com/XRPLF/clio/pull/2923))
|
||||
- Reverted "refactor: Add writing command to etl::SystemState". ([#2860](https://github.com/XRPLF/clio/pull/2860))
|
||||
|
||||
## Contributors
|
||||
|
||||
The following people contributed directly to this release:
|
||||
|
||||
- [@godexsoft](https://github.com/godexsoft)
|
||||
- [@mathbunnyru](https://github.com/mathbunnyru)
|
||||
- [@kuznetsss](https://github.com/kuznetsss)
|
||||
- [@yinyiqian1](https://github.com/yinyiqian1)
|
||||
- [@emreariyurek](https://github.com/emreariyurek)
|
||||
- [@PeterChen13579](https://github.com/PeterChen13579)
|
||||
- [@bthomee](https://github.com/bthomee)
|
||||
|
||||
## Feedback
|
||||
|
||||
To report an issue or propose a new idea, please [open an issue](https://github.com/XRPLF/clio/issues).
|
||||
76
blog/2026/rippled-3.1.0.md
Normal file
76
blog/2026/rippled-3.1.0.md
Normal file
@@ -0,0 +1,76 @@
|
||||
---
|
||||
category: 2026
|
||||
date: "2026-01-28"
|
||||
template: '../../@theme/templates/blogpost'
|
||||
seo:
|
||||
title: Introducing XRP Ledger version 3.1.0
|
||||
description: rippled version 3.1.0 is now available. This version introduces new amendments and bug fixes.
|
||||
labels:
|
||||
- rippled Release Notes
|
||||
markdown:
|
||||
editPage:
|
||||
hide: true
|
||||
---
|
||||
# Introducing XRP Ledger version 3.1.0
|
||||
|
||||
Version 3.1.0 of `rippled`, the reference server implementation of the XRP Ledger protocol, is now available. This release introduces Single Asset Vaults, the Lending Protocol, and bug fixes.
|
||||
|
||||
|
||||
## Action Required
|
||||
|
||||
If you run an XRP Ledger server, upgrade to version 3.1.0 as soon as possible to ensure service continuity.
|
||||
|
||||
|
||||
## Install / Upgrade
|
||||
|
||||
On supported platforms, see the [instructions on installing or updating `rippled`](../../docs/infrastructure/installation/index.md).
|
||||
|
||||
| Package | SHA-256 |
|
||||
|:--------|:--------|
|
||||
| [RPM for Red Hat / CentOS (x86-64)](https://repos.ripple.com/repos/rippled-rpm/stable/rippled-3.1.0-1.el9.x86_64.rpm) | `8ac8c529718566e6ebef3cb177d170fda1efc81ee08c4ea99d7e8fa3db0a2c70` |
|
||||
| [DEB for Ubuntu / Debian (x86-64)](https://repos.ripple.com/repos/rippled-deb/pool/stable/rippled_3.1.0-1_amd64.deb) | `58574a2299db2edf567e09efa25504677cdc66e4fa26f8a84322ab05f3a02996` |
|
||||
|
||||
For other platforms, please [build from source](https://github.com/XRPLF/rippled/blob/master/BUILD.md). The most recent commit in the git log should be the change setting the version:
|
||||
|
||||
```text
|
||||
commit d325f20c76fa798d0286d25e80b126ec0a2ee679
|
||||
Author: Ed Hennis <ed@ripple.com>
|
||||
Date: Tue Jan 27 21:13:06 2026 -0400
|
||||
|
||||
Set version to 3.1.0 (#6284)
|
||||
```
|
||||
|
||||
|
||||
## Full Changelog
|
||||
|
||||
|
||||
### Amendments
|
||||
|
||||
- **SingleAssetVault**: Adds vaults, which pool a single asset for use with the Lending Protocol. ([#5632](https://github.com/XRPLF/rippled/pull/5632))
|
||||
- **LendingProtocol**: Adds the ability to create loans on the XRP Ledger. Loan brokers can create fixed-term, uncollateralized loans using the pooled funds from a Single Asset Vault. The protocol is highly configurable, enabling loan brokers to tune risk appetite, depostitor protections, and economic incentives. ([#5632](https://github.com/XRPLF/rippled/pull/5632))
|
||||
- **fixBatchInnerSigs**: Fixes an issue where inner transactions of a `Batch` transaction would be flagged as having valid signatures. Inner transactions never have valid signatures. ([#6069](https://github.com/XRPLF/rippled/pull/6069))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Expand `Number` to support full integer range. ([#6192](https://github.com/XRPLF/rippled/pull/6192))
|
||||
- Fix: Reorder Batch Preflight Errors. ([#6176](https://github.com/XRPLF/rippled/pull/6176))
|
||||
- Fix dependencies so clio can use libxrpl. ([#6251](https://github.com/XRPLF/rippled/pull/6251))
|
||||
- Fix: Remove DEFAULT fields that change to the default in associateAsset (was Add Vault creation tests for showing valid range for AssetsMaximum). ([#6259](https://github.com/XRPLF/rippled/pull/6259))
|
||||
|
||||
|
||||
## Credits
|
||||
|
||||
The following RippleX teams and GitHub users contributed to this release:
|
||||
|
||||
- RippleX Engineering
|
||||
- RippleX Docs
|
||||
- RippleX Product
|
||||
- @dangell7
|
||||
|
||||
|
||||
## Bug Bounties and Responsible Disclosures
|
||||
|
||||
We welcome reviews of the `rippled` code and urge researchers to responsibly disclose any issues they may find.
|
||||
|
||||
To report a bug, please send a detailed report to: <bugs@xrpl.org>
|
||||
@@ -7,6 +7,11 @@
|
||||
page: index.page.tsx
|
||||
expanded: true
|
||||
items:
|
||||
- group: '2026'
|
||||
expanded: false
|
||||
items:
|
||||
- page: 2026/rippled-3.1.0.md
|
||||
- page: 2026/clio-2.7.0.md
|
||||
- group: '2025'
|
||||
expanded: false
|
||||
items:
|
||||
|
||||
@@ -1317,6 +1317,61 @@ const events = [
|
||||
image: require("../static/img/events/hackathon-kaigi.png"),
|
||||
end_date: "December 06, 2025",
|
||||
},
|
||||
{
|
||||
name: "XRP Community Day EMEA",
|
||||
description:
|
||||
"Join the EMEA XRP community on February 11, 2026 for XRP Community Day, a global virtual event celebrating innovation, utility, and growth across the XRP ecosystem.",
|
||||
type: "meetup",
|
||||
link: "https://luma.com/w118fmkh?utm_source=xrplorg",
|
||||
location: "Virtual - X Spaces",
|
||||
date: "February 11, 2026",
|
||||
image: require("../static/img/events/emea_xrplorg.png"),
|
||||
end_date: "February 11, 2026",
|
||||
},
|
||||
{
|
||||
name: "XRP Community Day Americas",
|
||||
description:
|
||||
"Join the Americas XRP community on February 11, 2026 for XRP Community Day, a global virtual event celebrating innovation, utility, and growth across the XRP ecosystem.",
|
||||
type: "meetup",
|
||||
link: "https://luma.com/1powvqnc?utm_source=xrplorg",
|
||||
location: "Virtual - X Spaces",
|
||||
date: "February 11, 2026",
|
||||
image: require("../static/img/events/amer_xrplorg.png"),
|
||||
end_date: "February 11, 2026",
|
||||
},
|
||||
{
|
||||
name: "XRP Community Day APAC",
|
||||
description:
|
||||
"Join the APAC XRP community on February 12 for XRP Community Day, a global virtual event celebrating innovation, utility, and growth across the XRP ecosystem.",
|
||||
type: "meetup",
|
||||
link: "https://luma.com/ckzg3l3r?utm_source=xrplorg",
|
||||
location: "Virtual - X Spaces",
|
||||
date: "February 12, 2026",
|
||||
image: require("../static/img/events/apac_xrplorg.png"),
|
||||
end_date: "February 12, 2026",
|
||||
},
|
||||
{
|
||||
name: "Building On The XRP Ledger",
|
||||
description:
|
||||
"This 2-day intensive hands-on training is designed for developers who are curious to learn about XRP Ledger. Meet your peers, share insights, and join a community of builders.",
|
||||
type: "meetup",
|
||||
link: "https://luma.com/lxb5ttsc",
|
||||
location: "Paris, France",
|
||||
date: "January 26 - 27, 2026",
|
||||
image: require("../static/img/events/building-xrpl.png"),
|
||||
end_date: "January 27, 2026",
|
||||
},
|
||||
{
|
||||
name: "XRPL Meetup in London",
|
||||
description:
|
||||
"Calling all blockchain and XRP Ledger enthusiasts in London! Join XRPL Meetups to share knowledge, build real-life connections, and foster communities centered around blockchain and XRP Ledger. We're establishing local “XRPL Hubs” across Europe, and we want you to be a part of it!",
|
||||
type: "meetup",
|
||||
link: "https://luma.com/xshnm19t",
|
||||
location: "London, UK",
|
||||
date: "February 18, 2026",
|
||||
image: require("../static/img/events/meetup-london.png"),
|
||||
end_date: "February 18, 2026",
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -1398,33 +1453,33 @@ export default function Events() {
|
||||
<div className="pr-2 col">
|
||||
<img
|
||||
alt="xrp ledger events hero"
|
||||
src={require("../static/img/events/xrp-community-night.png")}
|
||||
src={require("../static/img/events/xrpl-hero.png")}
|
||||
className="w-100"
|
||||
/>
|
||||
</div>
|
||||
<div className="pt-5 pr-2 col">
|
||||
<div className="d-flex flex-column-reverse">
|
||||
<h2 className="mb-8 h4 h2-sm">
|
||||
{translate("XRP Community Night NYC")}
|
||||
{translate("XRP Community Night Denver")}
|
||||
</h2>
|
||||
<h6 className="mb-3 eyebrow">{translate("Save the Date")}</h6>
|
||||
</div>
|
||||
<p className="mb-4">
|
||||
{translate(
|
||||
"Join the XRP community in NYC—meet builders, users, and projects innovating on the XRP Ledger."
|
||||
"Attending ETHDenver? Join us for an evening with the XRP community in Denver. Connect with the users, builders and projects innovating with and utilizing XRP."
|
||||
)}
|
||||
</p>
|
||||
<div className=" my-3 event-small-gray">
|
||||
{translate("Location: New York, NY")}
|
||||
{translate("Location: Denver, CO")}
|
||||
</div>
|
||||
<div className="py-2 my-3 event-small-gray">
|
||||
{translate("November 5, 2025")}
|
||||
{translate("February 18, 2026")}
|
||||
</div>
|
||||
<div className="d-lg-block">
|
||||
<a
|
||||
className="btn btn-primary btn-arrow-out"
|
||||
target="_blank"
|
||||
href="https://lu.ma/g5uja58m?utm_source=xrpleventspage"
|
||||
href="https://luma.com/chz145tf?utm_source=xprlorg"
|
||||
>
|
||||
{translate("Register Now")}
|
||||
</a>
|
||||
|
||||
@@ -406,6 +406,78 @@ const events = [
|
||||
start_date: "November 14, 2025",
|
||||
end_date: "December 06, 2025",
|
||||
},
|
||||
{
|
||||
name: "XRP Community Day EMEA",
|
||||
description:
|
||||
"Join the EMEA XRP community on February 11, 2026 for XRP Community Day, a global virtual event celebrating innovation, utility, and growth across the XRP ecosystem.",
|
||||
type: "meetup",
|
||||
link: "https://luma.com/w118fmkh?utm_source=xrplorg",
|
||||
location: "Virtual - X Spaces",
|
||||
date: "February 11, 2026",
|
||||
image: require("../static/img/events/emea_xrplorg.png"),
|
||||
start_date: "February 11, 2026",
|
||||
end_date: "February 11, 2026",
|
||||
},
|
||||
{
|
||||
name: "XRP Community Day Americas",
|
||||
description:
|
||||
"Join the Americas XRP community on February 11, 2026 for XRP Community Day, a global virtual event celebrating innovation, utility, and growth across the XRP ecosystem.",
|
||||
type: "meetup",
|
||||
link: "https://luma.com/1powvqnc?utm_source=xrplorg",
|
||||
location: "Virtual - X Spaces",
|
||||
date: "February 11, 2026",
|
||||
image: require("../static/img/events/amer_xrplorg.png"),
|
||||
start_date: "February 11, 2026",
|
||||
end_date: "February 11, 2026",
|
||||
},
|
||||
{
|
||||
name: "XRP Community Day APAC",
|
||||
description:
|
||||
"Join the APAC XRP community on February 12 for XRP Community Day, a global virtual event celebrating innovation, utility, and growth across the XRP ecosystem.",
|
||||
type: "meetup",
|
||||
link: "https://luma.com/ckzg3l3r?utm_source=xrplorg",
|
||||
location: "Virtual - X Spaces",
|
||||
date: "February 12, 2026",
|
||||
image: require("../static/img/events/apac_xrplorg.png"),
|
||||
start_date: "February 12, 2026",
|
||||
end_date: "February 12, 2026",
|
||||
},
|
||||
{
|
||||
name: "Building On The XRP Ledger",
|
||||
description:
|
||||
"This 2-day intensive hands-on training is designed for developers who are curious to learn about XRP Ledger. Meet your peers, share insights, and join a community of builders.",
|
||||
type: "meetup",
|
||||
link: "https://luma.com/lxb5ttsc",
|
||||
location: "Paris, France",
|
||||
date: "January 26 - 27, 2026",
|
||||
image: require("../static/img/events/building-xrpl.png"),
|
||||
start_date: "January 26, 2026",
|
||||
end_date: "January 27, 2026",
|
||||
},
|
||||
{
|
||||
name: "XRPL Meetup in London",
|
||||
description:
|
||||
"Calling all blockchain and XRP Ledger enthusiasts in London! Join XRPL Meetups to share knowledge, build real-life connections, and foster communities centered around blockchain and XRP Ledger. We're establishing local “XRPL Hubs” across Europe, and we want you to be a part of it!",
|
||||
type: "meetup",
|
||||
link: "https://luma.com/xshnm19t",
|
||||
location: "London, UK",
|
||||
date: "February 18, 2026",
|
||||
image: require("../static/img/events/meetup-london.png"),
|
||||
start_date: "February 18, 2026",
|
||||
end_date: "February 18, 2026",
|
||||
},
|
||||
{
|
||||
name: "XRP Community Night Denver",
|
||||
description:
|
||||
"Attending ETHDenver? Join us for an evening with the XRP community in Denver. Connect with the users, builders and projects innovating with and utilizing XRP.",
|
||||
type: "meetup",
|
||||
link: "https://luma.com/chz145tf?utm_source=xprlorg",
|
||||
location: "Denver, CO",
|
||||
date: "February 18, 2026",
|
||||
image: require("../static/img/events/denver_xrplorg.png"),
|
||||
start_date: "February 18, 2026",
|
||||
end_date: "February 18, 2026",
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
[AccountSet transactions]: /docs/references/protocol/transactions/types/accountset.md
|
||||
[AccountSet]: /docs/references/protocol/transactions/types/accountset.md
|
||||
[Address]: /docs/references/protocol/data-types/basic-data-types.md#addresses
|
||||
[Amendments entry]: /docs/concepts/networks-and-servers/amendments.md
|
||||
[Amendments object]: /docs/concepts/networks-and-servers/amendments.md
|
||||
[Amendments entry]: /docs/references/protocol/ledger-data/ledger-entry-types/amendments.md
|
||||
[Amendments object]: /docs/references/protocol/ledger-data/ledger-entry-types/amendments.md
|
||||
[Batch amendment]: /resources/known-amendments.md#batch
|
||||
[Batch]: /docs/references/protocol/transactions/types/batch.md
|
||||
[Batch transaction]: /docs/references/protocol/transactions/types/batch.md
|
||||
@@ -128,6 +128,15 @@
|
||||
[LedgerStateFix transaction]: /docs/references/protocol/transactions/types/ledgerstatefix.md
|
||||
[LedgerStateFix transactions]: /docs/references/protocol/transactions/types/ledgerstatefix.md
|
||||
[LedgerStateFix]: /docs/references/protocol/transactions/types/ledgerstatefix.md
|
||||
[LoanBrokerCoverClawback transaction]: /docs/references/protocol/transactions/types/loanbrokercoverclawback.md
|
||||
[LoanBrokerCoverDeposit transaction]: /docs/references/protocol/transactions/types/loanbrokercoverdeposit.md
|
||||
[LoanBrokerCoverWithdraw transaction]: /docs/references/protocol/transactions/types/loanbrokercoverwithdraw.md
|
||||
[LoanBrokerDelete transaction]: /docs/references/protocol/transactions/types/loanbrokerdelete.md
|
||||
[LoanBrokerSet transaction]: /docs/references/protocol/transactions/types/loanbrokerset.md
|
||||
[LoanDelete transaction]: /docs/references/protocol/transactions/types/loandelete.md
|
||||
[LoanManage transaction]: /docs/references/protocol/transactions/types/loanmanage.md
|
||||
[LoanPay transaction]: /docs/references/protocol/transactions/types/loanpay.md
|
||||
[LoanSet transaction]: /docs/references/protocol/transactions/types/loanset.md
|
||||
[Marker]: /docs/references/http-websocket-apis/api-conventions/markers-and-pagination.md
|
||||
[MPTokenIssuanceSet]: /docs/references/protocol/transactions/types/mptokenissuanceset.md
|
||||
[MPTokenIssuanceSet transaction]: /docs/references/protocol/transactions/types/mptokenissuanceset.md
|
||||
@@ -135,6 +144,7 @@
|
||||
[MPTokensV1 amendment]: /resources/known-amendments.md#mptokensv1
|
||||
[MultiSign amendment]: /resources/known-amendments.md#multisign
|
||||
[MultiSignReserve amendment]: /resources/known-amendments.md#multisignreserve
|
||||
[NFT]: /docs/references/protocol/data-types/nftoken.md
|
||||
[NFTokenAcceptOffer transaction]: /docs/references/protocol/transactions/types/nftokenacceptoffer.md
|
||||
[NFTokenAcceptOffer transactions]: /docs/references/protocol/transactions/types/nftokenacceptoffer.md
|
||||
[NFTokenAcceptOffer]: /docs/references/protocol/transactions/types/nftokenacceptoffer.md
|
||||
@@ -155,6 +165,7 @@
|
||||
[NFTokenPage entry]: /docs/references/protocol/ledger-data/ledger-entry-types/nftokenpage.md
|
||||
[NFTokenPage object]: /docs/references/protocol/ledger-data/ledger-entry-types/nftokenpage.md
|
||||
[NFToken]: /docs/references/protocol/data-types/nftoken.md
|
||||
[Negative UNL]: /docs/concepts/consensus-protocol/negative-unl.md
|
||||
[NegativeUNL amendment]: /resources/known-amendments.md#negativeunl
|
||||
[NegativeUNL entry]: /docs/references/protocol/ledger-data/ledger-entry-types/negativeunl.md
|
||||
[NegativeUNL object]: /docs/references/protocol/ledger-data/ledger-entry-types/negativeunl.md
|
||||
@@ -248,6 +259,13 @@
|
||||
[UNLModify pseudo-transaction]: /docs/references/protocol/transactions/pseudo-transaction-types/unlmodify.md
|
||||
[UNLModify pseudo-transactions]: /docs/references/protocol/transactions/pseudo-transaction-types/unlmodify.md
|
||||
[UNLModify]: /docs/references/protocol/transactions/pseudo-transaction-types/unlmodify.md
|
||||
[Vault entry]: /docs/references/protocol/ledger-data/ledger-entry-types/vault.md
|
||||
[VaultCreate transaction]: /docs/references/protocol/transactions/types/vaultcreate.md
|
||||
[VaultDelete transaction]: /docs/references/protocol/transactions/types/vaultdelete.md
|
||||
[VaultDeposit transaction]: /docs/references/protocol/transactions/types/vaultdeposit.md
|
||||
[VaultSet transaction]: /docs/references/protocol/transactions/types/vaultset.md
|
||||
[VaultWithdraw transaction]: /docs/references/protocol/transactions/types/vaultwithdraw.md
|
||||
[VaultClawback transaction]: /docs/references/protocol/transactions/types/vaultclawback.md
|
||||
[XChainAddAccountCreateAttestation transaction]: /docs/references/protocol/transactions/types/xchainaddaccountcreateattestation.md
|
||||
[XChainAddAccountCreateAttestation transactions]: /docs/references/protocol/transactions/types/xchainaddaccountcreateattestation.md
|
||||
[XChainAddAccountCreateAttestation]: /docs/references/protocol/transactions/types/xchainaddaccountcreateattestation.md
|
||||
@@ -266,6 +284,7 @@
|
||||
[XChainOwnedClaimID entry]: /docs/references/protocol/ledger-data/ledger-entry-types/xchainownedclaimid
|
||||
[XRP, in drops]: /docs/references/protocol/data-types/basic-data-types.md#specifying-currency-amounts
|
||||
[XRPFees amendment]: /resources/known-amendments.md#xrpfees
|
||||
[AccountID]: /docs/references/protocol/binary-format/#accountid-fields
|
||||
[account_channels command]: /docs/references/http-websocket-apis/public-api-methods/account-methods/account_channels.md
|
||||
[account_channels method]: /docs/references/http-websocket-apis/public-api-methods/account-methods/account_channels.md
|
||||
[account_currencies command]: /docs/references/http-websocket-apis/public-api-methods/account-methods/account_currencies.md
|
||||
@@ -295,6 +314,7 @@
|
||||
[channel_verify command]: /docs/references/http-websocket-apis/public-api-methods/payment-channel-methods/channel_verify.md
|
||||
[channel_verify method]: /docs/references/http-websocket-apis/public-api-methods/payment-channel-methods/channel_verify.md
|
||||
[common fields]: /docs/references/protocol/transactions/common-fields.md
|
||||
[common ledger entry fields]: /docs/references/protocol/ledger-data/common-fields/
|
||||
[connect command]: /docs/references/http-websocket-apis/admin-api-methods/peer-management-methods/connect.md
|
||||
[connect method]: /docs/references/http-websocket-apis/admin-api-methods/peer-management-methods/connect.md
|
||||
[consensus_info command]: /docs/references/http-websocket-apis/admin-api-methods/status-and-debugging-methods/consensus_info.md
|
||||
@@ -309,6 +329,7 @@
|
||||
[fee command]: /docs/references/http-websocket-apis/public-api-methods/server-info-methods/fee.md
|
||||
[fee levels]: /docs/concepts/transactions/transaction-cost.md#fee-levels
|
||||
[fee method]: /docs/references/http-websocket-apis/public-api-methods/server-info-methods/fee.md
|
||||
[fee voting]: /docs/concepts/consensus-protocol/fee-voting.md
|
||||
[fetch_info command]: /docs/references/http-websocket-apis/admin-api-methods/status-and-debugging-methods/fetch_info.md
|
||||
[fetch_info method]: /docs/references/http-websocket-apis/admin-api-methods/status-and-debugging-methods/fetch_info.md
|
||||
[fix1201 amendment]: /resources/known-amendments.md#fix1201
|
||||
@@ -341,17 +362,20 @@
|
||||
[fixRemoveNFTokenAutoTrustLine amendment]: /resources/known-amendments.md#fixremovenftokenautotrustline
|
||||
[fixTakerDryOfferRemoval amendment]: /resources/known-amendments.md#fixtakerdryofferremoval
|
||||
[fixTrustLinesToSelf amendment]: /resources/known-amendments.md#fixtrustlinestoself
|
||||
[flags field]: /docs/references/protocol/transactions/common-fields#flags-field
|
||||
[get_aggregate_price command]: /docs/references/http-websocket-apis/public-api-methods/path-and-order-book-methods/get_aggregate_price.md
|
||||
[get_aggregate_price method]: /docs/references/http-websocket-apis/public-api-methods/path-and-order-book-methods/get_aggregate_price.md
|
||||
[gateway_balances command]: /docs/references/http-websocket-apis/public-api-methods/account-methods/gateway_balances.md
|
||||
[gateway_balances method]: /docs/references/http-websocket-apis/public-api-methods/account-methods/gateway_balances.md
|
||||
[get_counts command]: /docs/references/http-websocket-apis/admin-api-methods/status-and-debugging-methods/get_counts.md
|
||||
[get_counts method]: /docs/references/http-websocket-apis/admin-api-methods/status-and-debugging-methods/get_counts.md
|
||||
[Get Started Using JavaScript]: /docs/tutorials/javascript/build-apps/get-started.md
|
||||
[hexadecimal]: https://en.wikipedia.org/wiki/Hexadecimal
|
||||
[identifying hash]: /docs/concepts/transactions/index.md#identifying-transactions
|
||||
[json command]: /docs/references/http-websocket-apis/public-api-methods/utility-methods/json.md
|
||||
[json method]: /docs/references/http-websocket-apis/public-api-methods/utility-methods/json.md
|
||||
[ledger command]: /docs/references/http-websocket-apis/public-api-methods/ledger-methods/ledger.md
|
||||
[ledger entry ID]: /docs/references/protocol/ledger-data/common-fields.md#ledger-entry-id
|
||||
[ledger format]: /docs/references/protocol/ledger-data/ledger-entry-types/index.md
|
||||
[ledger index]: /docs/references/protocol/data-types/basic-data-types.md#ledger-index
|
||||
[ledger method]: /docs/references/http-websocket-apis/public-api-methods/ledger-methods/ledger.md
|
||||
@@ -369,6 +393,13 @@
|
||||
[ledger_entry method]: /docs/references/http-websocket-apis/public-api-methods/ledger-methods/ledger_entry.md
|
||||
[ledger_request command]: /docs/references/http-websocket-apis/admin-api-methods/logging-and-data-management-methods/ledger_request.md
|
||||
[ledger_request method]: /docs/references/http-websocket-apis/admin-api-methods/logging-and-data-management-methods/ledger_request.md
|
||||
[Lending Protocol]: /docs/concepts/tokens/lending-protocol.md
|
||||
[Loan]: /docs/references/protocol/ledger-data/ledger-entry-types/loan.md
|
||||
[Loan entry]: /docs/references/protocol/ledger-data/ledger-entry-types/loan.md
|
||||
[Loan ledger entry]: /docs/references/protocol/ledger-data/ledger-entry-types/loan.md
|
||||
[LoanBroker]: /docs/references/protocol/ledger-data/ledger-entry-types/loanbroker.md
|
||||
[LoanBroker entry]: /docs/references/protocol/ledger-data/ledger-entry-types/loanbroker.md
|
||||
[LoanBroker ledger entry]: /docs/references/protocol/ledger-data/ledger-entry-types/loanbroker.md
|
||||
[log_level command]: /docs/references/http-websocket-apis/admin-api-methods/logging-and-data-management-methods/log_level.md
|
||||
[log_level method]: /docs/references/http-websocket-apis/admin-api-methods/logging-and-data-management-methods/log_level.md
|
||||
[logrotate command]: /docs/references/http-websocket-apis/admin-api-methods/logging-and-data-management-methods/logrotate.md
|
||||
@@ -404,10 +435,12 @@
|
||||
[public servers]: /docs/tutorials/public-servers.md
|
||||
[random command]: /docs/references/http-websocket-apis/public-api-methods/utility-methods/random.md
|
||||
[random method]: /docs/references/http-websocket-apis/public-api-methods/utility-methods/random.md
|
||||
[reserves]: /docs/concepts/accounts/reserves.md
|
||||
[result code]: /docs/references/protocol/transactions/transaction-results/index.md
|
||||
[ripple-lib]: https://github.com/XRPLF/xrpl.js
|
||||
[ripple_path_find command]: /docs/references/http-websocket-apis/public-api-methods/path-and-order-book-methods/ripple_path_find.md
|
||||
[ripple_path_find method]: /docs/references/http-websocket-apis/public-api-methods/path-and-order-book-methods/ripple_path_find.md
|
||||
[Ripple Epoch]: /docs/references/protocol/data-types/basic-data-types.md#specifying-time
|
||||
[seconds since the Ripple Epoch]: /docs/references/protocol/data-types/basic-data-types.md#specifying-time
|
||||
[server_definitions method]: /docs/references/http-websocket-apis/public-api-methods/server-info-methods/server_definitions.md
|
||||
[server_info command]: /docs/references/http-websocket-apis/public-api-methods/server-info-methods/server_info.md
|
||||
@@ -432,6 +465,7 @@
|
||||
[transaction cost]: /docs/concepts/transactions/transaction-cost.md
|
||||
[transaction_entry command]: /docs/references/http-websocket-apis/public-api-methods/transaction-methods/transaction_entry.md
|
||||
[transaction_entry method]: /docs/references/http-websocket-apis/public-api-methods/transaction-methods/transaction_entry.md
|
||||
[transaction result codes]: /docs/references/protocol/transactions/transaction-results
|
||||
[tx command]: /docs/references/http-websocket-apis/public-api-methods/transaction-methods/tx.md
|
||||
[tx method]: /docs/references/http-websocket-apis/public-api-methods/transaction-methods/tx.md
|
||||
[tx_history command]: /docs/references/http-websocket-apis/public-api-methods/transaction-methods/tx_history.md
|
||||
@@ -447,5 +481,8 @@
|
||||
[validator_list_sites method]: /docs/references/http-websocket-apis/admin-api-methods/status-and-debugging-methods/validator_list_sites.md
|
||||
[validators command]: /docs/references/http-websocket-apis/admin-api-methods/status-and-debugging-methods/validators.md
|
||||
[validators method]: /docs/references/http-websocket-apis/admin-api-methods/status-and-debugging-methods/validators.md
|
||||
[vault_info command]: /docs/references/http-websocket-apis/public-api-methods/vault-methods/vault_info.md
|
||||
[vault_info method]: /docs/references/http-websocket-apis/public-api-methods/vault-methods/vault_info.md
|
||||
[wallet_propose command]: /docs/references/http-websocket-apis/admin-api-methods/key-generation-methods/wallet_propose.md
|
||||
[wallet_propose method]: /docs/references/http-websocket-apis/admin-api-methods/key-generation-methods/wallet_propose.md
|
||||
[xrpl.js library]: https://github.com/XRPLF/xrpl.js
|
||||
|
||||
@@ -10,7 +10,7 @@ status: not_enabled
|
||||
|
||||
Permission delegation is the function of granting various permissions to another account to send permissions on behalf of your account. You can use permission delegation to enable flexible security paradigms such as role-based access control, instead of or alongside techniques such as [multi-signing](./multi-signing.md).
|
||||
|
||||
{% amendment-disclaimer name="PermissionDelegation" /%}
|
||||
{% amendment-disclaimer name="PermissionDelegation" /%}
|
||||
|
||||
|
||||
## Background: The Need for Permission Delegation
|
||||
|
||||
33
docs/concepts/accounts/pseudo-accounts.md
Normal file
33
docs/concepts/accounts/pseudo-accounts.md
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
seo:
|
||||
description: A pseudo-account is a special type of XRPL account that holds assets on behalf of an on-chain protocol.
|
||||
labels:
|
||||
- Single Asset Vault
|
||||
- AMM
|
||||
- Lending Protocol
|
||||
status: not_enabled
|
||||
---
|
||||
|
||||
# Pseudo-Accounts
|
||||
|
||||
The XRP Ledger is an account-based blockchain where assets like XRP, trust line tokens, and Multi-Purpose Tokens (MPTs) are held by accounts, and are represented on-chain by an [AccountRoot](../../references/protocol/ledger-data/ledger-entry-types/accountroot) ledger entry. However, certain use cases require assets to be transferable to and from an object, which is why a pseudo-account is needed.
|
||||
|
||||
A pseudo-account is a special type of account that holds assets on behalf of an on-chain protocol. Use cases for pseudo-accounts include:
|
||||
|
||||
- **Automated Market Makers (AMM)**: The [XLS-30 amendment](../../../resources/known-amendments#amm) introduced pseudo-accounts for AMMs by adding the `AMMID` field to the `AccountRoot` ledger entry. This field links a pseudo-account to an AMM instance, allowing it to track XRP and token balances in the pool and issue `LPTokens` on behalf of the AMM instance.
|
||||
|
||||
- **Single Asset Vaults**: A single asset vault pseudo-account is used to store deposited funds and issue MPT shares. A new `VaultID` field is introduced in the `AccountRoot` ledger entry, which links the pseudo-account with the vault.
|
||||
|
||||
- **Lending Protocol**: The Lending Protocol also uses the single asset vault's pseudo-account, with each `LoanBroker` tracked in the pseudo-account's owner directory. The pseudo-account holds first-loss capital that protects vault depositors from loan defaults, as well as the loan funds themselves.
|
||||
|
||||
A pseudo-account has strict limitations. It cannot receive payments from other accounts, cannot send transactions since it has no signing authority, and exists solely to store or issue assets.
|
||||
|
||||
## Reserve Requirements
|
||||
|
||||
The cost of creating a pseudo-account depends on whether it is owned and controlled by another account:
|
||||
|
||||
- **Owned pseudo-accounts**: For objects like a `Vault` where a single account owns and controls the associated pseudo-account, the creation transaction increases the owner's XRP reserve by one [incremental owner reserve](../accounts/reserves#base-reserve-and-owner-reserve) (currently {% $env.PUBLIC_OWNER_RESERVE %}). This is in addition to any other reserve requirements of the transaction (for example, the Vault object itself).
|
||||
|
||||
- **Unowned pseudo-accounts**: For objects like an `AMM` that are not owned by any account, the creation transaction must charge a special, higher-than-normal transaction fee. This fee must be at least the value of one incremental owner reserve. This amount is burned, compensating for the permanent ledger space without tying the reserve to a specific owner.
|
||||
|
||||
{% raw-partial file="/docs/_snippets/common-links.md" /%}
|
||||
202
docs/concepts/tokens/lending-protocol.md
Normal file
202
docs/concepts/tokens/lending-protocol.md
Normal file
@@ -0,0 +1,202 @@
|
||||
---
|
||||
seo:
|
||||
description: The XRPL Lending Protocol enables on-chain, uncollateralized fixed-term loans.
|
||||
labels:
|
||||
- Decentralized Finance
|
||||
- Lending Protocol
|
||||
status: not_enabled
|
||||
---
|
||||
# Lending Protocol
|
||||
|
||||
The Lending Protocol is an XRP Ledger DeFi primitive that enables on-chain, fixed-term, uncollateralized loans using pooled funds from a [Single Asset Vault](./single-asset-vaults.md). The protocol is highly configurable, enabling loan brokers to easily tune risk appetite, depostitor protections, and economic incentives.
|
||||
|
||||
The implementation relies on off-chain underwriting and risk management to assess the creditworthiness of borrowers, but offers peer-to-peer loans without intermediaries like banks or financial institutions. First-loss capital protection is used to help offset losses from loan defaults.
|
||||
|
||||
The current implementation of the lending protocol doesn't include automated on-chain collateral and liquidation management, instead focusing on on-chain credit origination.
|
||||
|
||||
To ensure compliance needs are met, asset issuers can [claw back](../../references/protocol/transactions/types/clawback.md) funds from the vault associated with the lending protocol. Issuers can also [freeze](./fungible-tokens/freezes.md) individual accounts or issue a global freeze.
|
||||
|
||||
{% amendment-disclaimer name="LendingProtocol" /%}
|
||||
|
||||
## Protocol Flow
|
||||
|
||||
There are three parties involved in the process of creating a loan:
|
||||
|
||||
- **Loan Brokers**: Create asset vaults and manage associated loans.
|
||||
- **Depositors**: Add assets to vaults.
|
||||
- **Borrowers**: Receive loans, making repayments as defined by their loan terms.
|
||||
|
||||
[{% inline-svg file="../../img/lending-protocol-diagram.svg" /%}](../../img/lending-protocol-diagram.svg "Diagram: The lifecycle of a loan.")
|
||||
|
||||
The lifecycle of a loan is as follows:
|
||||
|
||||
1. A loan broker creates a vault.
|
||||
2. Depositors add assets to the vault.
|
||||
3. (Optional) The loan broker deposits first-loss capital.
|
||||
4. A loan broker and borrower create a loan, defining the terms of the loan, and the requested principal (excluding fees) is transferred to the borrower.
|
||||
5. If payments are missed, the loan enters a grace period. Once the grace period expires, the loan broker has the option to default the loan.
|
||||
6. The loan is deleted when matured or defaulted.
|
||||
7. (Optional) The loan broker can withdraw first-loss capital.
|
||||
8. After all loans are paid, the loan broker can delete the `LoanBroker` ledger entry, and then the corresponding `Vault` ledger entry.
|
||||
|
||||
|
||||
## Accounting
|
||||
|
||||
### Risk Management
|
||||
|
||||
#### First-Loss Capital
|
||||
|
||||
First-Loss Capital is an optional mechanism to mitigate the risks associated with lending. To protect investors' assets, a loan broker can deposit assets as first-loss capital, which acts as a buffer in the event of loan defaults. The first-loss capital is placed into the vault to cover a percentage of losses from missed payments.
|
||||
|
||||
Three parameters control the First-Loss Capital:
|
||||
|
||||
- `CoverAvailable`: The total amount of cover deposited by the lending protocol owner.
|
||||
- `CoverRateMinimum`: The percentage of debt that must be covered by `CoverAvailable`.
|
||||
- `CoverRateLiquidation`: The maximum percentage of the minimum required cover _(DebtTotal x CoverRateMinimum)_ that will be placed in the asset vault to cover a loan default.
|
||||
|
||||
Whenever the available cover falls below the minimum required:
|
||||
|
||||
- The loan broker can't issue new loans.
|
||||
- The loan broker can't receive fees. All fees are added to the First-Loss Capital to cover the deficit.
|
||||
|
||||
Below is an example of how first-loss capital is used to cover a loan default:
|
||||
|
||||
```
|
||||
** Initial States **
|
||||
|
||||
-- Vault --
|
||||
AssetsTotal = 100,090 Tokens
|
||||
AssetsAvailable = 99,000 Tokens
|
||||
SharesTotal = 100,000 Tokens
|
||||
|
||||
-- Lending Protocol --
|
||||
DebtTotal = 1,090 Tokens
|
||||
CoverRateMinimum = 0.1 (10%)
|
||||
CoverRateLiquidation = 0.1 (10%)
|
||||
CoverAvailable = 1,000 Tokens
|
||||
|
||||
-- Loan --
|
||||
PrincipleOutstanding = 1,000 Tokens
|
||||
InterestOutstanding = 90 Tokens
|
||||
|
||||
|
||||
# First-Loss Capital liquidation maths
|
||||
|
||||
DefaultAmount = PrincipleOutstanding + InterestOutstanding
|
||||
= 1,000 + 90
|
||||
= 1,090
|
||||
|
||||
# The amount of the default that the first-loss capital scheme will cover
|
||||
DefaultCovered = min((DebtTotal x CoverRateMinimum) x CoverRateLiquidation, DefaultAmount)
|
||||
= min((1,090 * 0.1) * 0.1, 1,090) = min(10.9, 1,090)
|
||||
= 10.9 Tokens
|
||||
|
||||
Loss = DefaultAmount - DefaultCovered
|
||||
= 1,090 - 10.9
|
||||
= 1,079.1 Tokens
|
||||
|
||||
FundsReturned = DefaultCovered
|
||||
= 10.9
|
||||
|
||||
# Note, Loss + FundsReturned MUST be equal to PrincipleOutstanding + InterestOutstanding
|
||||
|
||||
** State Changes **
|
||||
|
||||
-- Vault --
|
||||
AssetsTotal = AssetsTotal - Loss
|
||||
= 100,090 - 1,079.1
|
||||
= 99,010.9 Tokens
|
||||
|
||||
AssetsAvailable = AssetsAvailable + FundsReturned
|
||||
= 99,000 + 10.9
|
||||
= 99,010.9 Tokens
|
||||
|
||||
SharesTotal = (UNCHANGED)
|
||||
|
||||
-- Lending Protocol --
|
||||
DebtTotal = DebtTotal - PrincipleOutstanding + InterestOutstanding
|
||||
= 1,090 - (1,000 + 90)
|
||||
= 0 Tokens
|
||||
|
||||
CoverAvailable = CoverAvailable - DefaultCovered
|
||||
= 1,000 - 10.9
|
||||
= 989.1 Tokens
|
||||
```
|
||||
|
||||
#### Impairment
|
||||
|
||||
If the loan broker discovers a borrower can't make an upcoming payment, impairment allows the loan broker to register a "paper loss" with the vault. The impairment mechanism moves the due date of the next payment to the time the loan is impaired, allowing the loan to default more quickly. However, if the borrower makes a payment before that date, the impairment status is automatically cleared.
|
||||
|
||||
|
||||
### Compliance
|
||||
|
||||
#### Clawback
|
||||
|
||||
Issuers (trust line token or MPT, not XRP) can claw back funds from First-Loss Capital. To ensure there is always a minimum amount of capital available to protect depositors, issuers can't claw back the entire available amount. Instead, they can claw back up to a minimum amount of First-Loss Capital that the loan broker must maintain for the lending protocol; the minimum amount is calculated as `LoanBroker.DebtTotal * LoanBroker.CoverRateMinimum`.
|
||||
|
||||
#### Freeze
|
||||
|
||||
Freezing is a mechanism by which an asset issuer (trust line token or MPT, not XRP) prevents an account from sending their issued asset. _Deep freeze_ takes this a step further by preventing an account from sending _and_ receiving issued assets. Issuers can also enact a _global freeze_, which prevents everyone from sending or receiving their issued asset.
|
||||
|
||||
{% admonition type="info" name="Note" %}
|
||||
In all freeze scenarios, assets can be sent back to the issuer.
|
||||
{% /admonition %}
|
||||
|
||||
If a borrower has their account frozen or deep frozen, they can't make loan payments. This doesn't absolve a borrower of their repayment obligations, and they will eventually default on their loan.
|
||||
|
||||
Freezing a borrower's account won't affect a loan broker's functions, but it will prevent them from receiving any lending protocol fees. However, issuers can freeze a loan broker's _pseudo-account_ and prevent the loan broker from creating new loans; existing loans won't be affected. A deep freeze on a loan broker's _pseudo-account_ also prevents loans from being repaid.
|
||||
|
||||
|
||||
### Interest Rates
|
||||
|
||||
There are three interest rates associated with a loan:
|
||||
|
||||
- **Interest Rate**: The regular interest rate based on the principal amount. It is the cost of borrowing funds.
|
||||
- **Late Interest Rate**: A higher interest rate charged for a late payment.
|
||||
- **Full Payment Rate**: An interest rate charged for repaying the total loan early.
|
||||
|
||||
|
||||
### Fees
|
||||
|
||||
The lending protocol charges a number of fees that the loan broker can configure. The protocol won't charge these fees if the loan broker hasn't deposited enough first-loss capital.
|
||||
|
||||
- **Management Fee**: This is a percentage of interest charged by the loan broker. Vault depositors pay this fee.
|
||||
- **Loan Origination Fee**: A fee paid to the loan broker, taken from the principal amount loaned out.
|
||||
- **Loan Service Fee**: A fee charged on top of each loan payment.
|
||||
- **Late Payment Fee**: A fee paid on top of a late payment.
|
||||
- **Early Payment Fee**: A fee paid on top of an early payment.
|
||||
|
||||
|
||||
## Loan Payment Processing
|
||||
|
||||
Loan payments are evaluated and processed around three criteria: amount, timing, and specified flags. The combination of these criteria determine how funds are applied to the loan's principal, interest, and associated fees.
|
||||
|
||||
Each payment consists of four components:
|
||||
|
||||
- **Principal**: The portion that reduces the outstanding loan principle.
|
||||
- **Interest**: The portion that covers the cost of borrowing for the period.
|
||||
- **Fees**: The portion that covers any applicable service fees, management fees, late payment fees, or other charges.
|
||||
- **ValueChange**: The amount by which the payment changes the loan balance.
|
||||
|
||||
When the loan payment is submitted, the lending protocol then checks these parameters:
|
||||
|
||||
- **Timing**: Is the payment on time or late?
|
||||
- **Amount**: Does the payment amount meet the minimum required amount, or exceed it?
|
||||
|
||||
Based on the timing and transaction flags, the lending protocol processes the payment as one of four types:
|
||||
|
||||
- **On-Time Payments**: If the payment is on-time, it's further classified into these payment scenarios:
|
||||
- **Sequential Periodic Payments**: The payment is applied to as many complete payment cycles as possible; cycles are calculated as the amount due each payment period (including fees).
|
||||
- **Overpayments**: After all possible cycles are fully paid, any remaining amount is treated as an overpayment and applied to the principal. This type of payment requires the `lsfLoanOverpayment` flag to be enabled on the `Loan` ledger entry, as well as the `tfLoanOverpayment` flag to be enabled on the `LoanPay` transaction. If these flags are missing, the excess amount is ignored.
|
||||
- **Full Early Repayment**: The payment has the `tfLoanFullPayment` flag set, and the amount covers the remainder of the loan (including fees).
|
||||
- **Late Payments**: The payment is late on a payment cycle. Late payments must be for an exact amount, calculated as:
|
||||
|
||||
`totalDue = periodicPayment + loanServiceFee + latePaymentFee + latePaymentInterest`
|
||||
|
||||
Overpayments aren't permitted on late payments; any excess amount is ignored.
|
||||
|
||||
{% admonition type="info" name="Note" %}
|
||||
In scenarios where excess payment amounts are "ignored", the transaction succeeds, but the borrower is only charged on the expected amount.
|
||||
{% /admonition %}
|
||||
|
||||
{% raw-partial file="/docs/_snippets/common-links.md" /%}
|
||||
251
docs/concepts/tokens/single-asset-vaults.md
Normal file
251
docs/concepts/tokens/single-asset-vaults.md
Normal file
@@ -0,0 +1,251 @@
|
||||
---
|
||||
seo:
|
||||
description: Single asset vaults aggregate assets from multiple depositors and make them available to other on-chain protocols.
|
||||
labels:
|
||||
- Single Asset Vault
|
||||
status: not_enabled
|
||||
---
|
||||
|
||||
# Single Asset Vaults
|
||||
|
||||
A single asset vault is an XRP Ledger primitive that aggregates assets from multiple depositors and makes them available to other on-chain protocols, such as the Lending Protocol. A vault asset can be [XRP](../../introduction/what-is-xrp.md), a [trust line token](../tokens/fungible-tokens/index.md), or an [MPT (Multi-Purpose Token)](../tokens/fungible-tokens/multi-purpose-tokens.md).
|
||||
|
||||
A Vault Owner account manages the vault and can create, update, or delete it as needed. When creating a vault, the Vault Owner can also specify whether shares are transferable or non-transferable. Non-transferable shares cannot be transferred to any other account, and can only be redeemed.
|
||||
|
||||
{% amendment-disclaimer name="SingleAssetVault" /%}
|
||||
|
||||
## Public vs. Private Vaults
|
||||
|
||||
A vault can be **public** or **private**, depending on the required level of access control.
|
||||
|
||||
In a public vault, anyone can deposit or redeem liquidity as long as they hold sufficient shares. In contrast, a private vault restricts access, allowing only depositors with the necessary [Credentials](../../concepts/decentralized-storage/credentials.md), managed through [Permissioned Domains](./decentralized-exchange/permissioned-domains.md), to deposit assets.
|
||||
|
||||
{% admonition type="warning" name="Warning" %}
|
||||
If a depositor's credentials expire, they can no longer deposit assets in a private vault, but can always redeem their existing shares.
|
||||
{% /admonition %}
|
||||
|
||||
To prevent the Vault Owner from locking funds away, any shareholder in a private vault can redeem their shares for assets.
|
||||
|
||||
Choosing between a public or private vault depends on your use case. For example, if depositor identity verification is required, use a private vault and issue credentials only to verified accounts.
|
||||
|
||||
## Vault Share Distribution and Redemption
|
||||
|
||||
Depositors can deposit assets to receive shares, which represent their proportional ownership of the vault, or redeem shares for assets.
|
||||
|
||||
[{% inline-svg file="../../img/single-asset-vault-img.svg" /%}](../../img/single-asset-vault-img.svg "Diagram: an example of an asset being deposited into the vault and shares being redeemed.")
|
||||
|
||||
Since the XRP Ledger is an account-based blockchain, all assets must be held by an account. A `Vault` ledger entry cannot hold assets directly, so a [pseudo-account](../accounts/pseudo-accounts.md) is created to hold assets on its behalf. This stand-alone account cannot receive funds or send transactions, and exists solely to store assets and issue shares.
|
||||
|
||||
Each share is represented on-chain as an MPT, issued by the vault's pseudo-account. Since MPTs can only exist as whole number units, the vault uses a `Scale` setting to convert fractional asset amounts into whole number shares.
|
||||
|
||||
The scale behavior varies based on the type of asset held by the vault:
|
||||
|
||||
- **XRP**: Uses a fixed scale that aligns with XRP's native structure, where one share represents one drop.
|
||||
- **Trust Line Token**: Allows configurable precision (default preserves 6 decimal places).
|
||||
- **MPT**: Uses a 1-to-1 relationship between MPT units and shares.
|
||||
|
||||
Depending on the connected protocol, vault shares may be yield-bearing, meaning shareholders could redeem shares for more or less liquidity than they originally deposited. This is because the total asset balance in the vault can grow or shrink over time, affecting the value of each share. However, the vault asset (e.g., USDC, XRP) does not generate yield on its own.
|
||||
|
||||
The value of each share depends on the total assets in the vault:
|
||||
|
||||
- If the vault earns yield over time, shares represent a larger claim, allowing depositors to redeem them for more assets.
|
||||
- If the vault incurs losses, shares hold less value, resulting in lower redemptions.
|
||||
|
||||
A vault could generate yield through mechanisms like lending or staking, with yield paid in the same asset deposited. The specific logic for this depends on how the connected on-chain protocol generates yield. For example, if a vault is used by a lending protocol, it could earn yield from interest paid by borrowers.
|
||||
|
||||
### Exchange Algorithm
|
||||
|
||||
A single asset vault uses an **exchange algorithm** to define how assets convert into shares during deposits and how shares convert back into assets during redemptions.
|
||||
|
||||
A vault's total value can fluctuate due to factors like _unrealized losses_, which impact the exchange rate for deposits and redemptions. To ensure fairness, the algorithm adjusts the exchange rate dynamically, so depositors receive shares or redeem them for assets at a rate that accurately reflects the vault’s true value.
|
||||
|
||||
#### Unrealized Loss
|
||||
|
||||
To prevent depositors from exploiting potential losses by redeeming shares early and shifting the full loss onto the remaining depositors, the vault tracks unrealized losses (or paper loss) using the `LossUnrealized` attribute in the `Vault` ledger entry.
|
||||
|
||||
Because the unrealized loss temporarily decreases the vault's value, a malicious depositor may take advantage of this by depositing assets at a lowered price and redeeming shares once the price increases.
|
||||
|
||||
For example, consider a vault with a total value of $1.0m and total shares of 1.0m. Let's assume the unrealized loss for the vault is $900k:
|
||||
|
||||
1. The new exchange rate is calculated as:
|
||||
|
||||
```js
|
||||
// ExchangeRate = (AssetsTotal - LossUnrealized) / SharesTotal
|
||||
exchangeRate = (1,000,000 - 900,000) / 1,000,000
|
||||
```
|
||||
|
||||
The exchange rate value is now **0.1**.
|
||||
|
||||
2. After the unrealized loss is cleared, the new effective exchange rate would be:
|
||||
|
||||
```js
|
||||
// ExchangeRate = AssetsTotal / SharesTotal
|
||||
exchangeRate = 1,000,000 / 1,000,000
|
||||
```
|
||||
|
||||
The exchange rate is now **1.0**.
|
||||
|
||||
A depositor could deposit $100k assets at a 0.1 exchange rate and get 1.0m shares. Once the unrealized loss is cleared, their shares would be worth $1.0m.
|
||||
|
||||
To mitigate this, the vault uses separate exchange rates for deposits and redemptions.
|
||||
|
||||
#### Exchange Rates
|
||||
|
||||
A single asset vault uses **two distinct exchange rates**:
|
||||
|
||||
- **Deposit Exchange Rate**: Protects new depositors from prior losses and ensures fair share allocation.
|
||||
- **Withdrawal Exchange Rate**: Ensures all shareholders share losses proportionally. Whether redeeming shares or withdrawing assets, the vault always calculates payouts using the actual current value (total assets minus losses), so depositors get their fair share of what's actually in the vault.
|
||||
- **Redemptions**: The vault burns shares so the depositor can receive proportional assets.
|
||||
- **Withdrawals**: The vault determines the shares to burn based on the requested asset amount.
|
||||
|
||||
These exchange rates ensure fairness and prevent manipulation, maintaining the integrity of deposits and redemptions.
|
||||
|
||||
To understand how the exchange rates are applied, here are the key variables used in the calculations:
|
||||
|
||||
- `Γ_assets`: The total balance of assets held within the vault.
|
||||
- `Γ_shares`: The total number of shares currently issued by the vault.
|
||||
- `Δ_assets`: The amount of assets being deposited, withdrawn, or redeemed.
|
||||
- `Δ_shares`: The number of shares being issued or burned.
|
||||
- `l`: The vault's total unrealized loss.
|
||||
- `σ`: The scaling factor (σ = 10<sup>Scale</sup>) used to convert fractional assets into whole number shares.
|
||||
|
||||
{% tabs %}
|
||||
{% tab label="Deposit" %}
|
||||
The vault computes the number of shares a depositor will receive as follows:
|
||||
|
||||
- **Initial Deposit (Empty Vault)**: For the first deposit into an empty vault, shares are calculated using the scaling factor to properly represent fractional assets as whole numbers.
|
||||
|
||||
```js
|
||||
Δ_shares = Δ_assets * σ // σ = 10^Scale
|
||||
```
|
||||
|
||||
- **Subsequent Deposits**: For all other deposits, shares are calculated proportionally. The resulting share value is rounded **down** to the nearest whole number.
|
||||
|
||||
```js
|
||||
Δ_shares = (Δ_assets * Γ_shares) / Γ_assets
|
||||
```
|
||||
Because the share amount is rounded down, the actual assets taken from the depositor are recalculated. This ensures the depositor isn't overcharged and that new shares are valued against the vault's true value, accounting for any unrealized loss:
|
||||
|
||||
```js
|
||||
Δ_assets = (Δ_shares * (Γ_assets - l)) / Γ_shares
|
||||
```
|
||||
|
||||
After a successful deposit, the _total assets_ and _total shares_ values are updated like so:
|
||||
|
||||
```js
|
||||
Γ_assets = Γ_assets + Δ_assets // New balance of assets in the vault.
|
||||
Γ_shares = Γ_shares + Δ_shares // New share balance in the vault.
|
||||
```
|
||||
{% /tab %}
|
||||
|
||||
{% tab label="Redeem" %}
|
||||
The vault computes the number of assets returned by burning shares as follows:
|
||||
|
||||
```js
|
||||
Δ_assets = (Δ_shares * (Γ_assets - l)) / Γ_shares
|
||||
```
|
||||
|
||||
After a successful redemption, the _total assets_ and _total shares_ values are updated like so:
|
||||
|
||||
```js
|
||||
Γ_assets = Γ_assets - Δ_assets // New balance of assets in the vault.
|
||||
Γ_shares = Γ_shares - Δ_shares // New share balance in the vault.
|
||||
```
|
||||
|
||||
{% /tab %}
|
||||
|
||||
{% tab label="Withdraw" %}
|
||||
When a depositor requests a specific asset amount, the vault uses a two-step process to determine the final payout:
|
||||
|
||||
1. The requested asset amount (`Δ_assets_requested`) is converted into shares.
|
||||
|
||||
```js
|
||||
Δ_shares = (Δ_assets_requested * Γ_shares) / (Γ_assets - l)
|
||||
```
|
||||
|
||||
The calculated share amount is rounded to the **nearest** whole number.
|
||||
|
||||
2. The rounded number of shares is used to calculate the final asset payout (`Δ_assets_out`), using the same logic as a redemption.
|
||||
|
||||
```js
|
||||
Δ_assets_out = (Δ_shares * (Γ_assets - l)) / Γ_shares
|
||||
```
|
||||
|
||||
Due to rounding in step 1, the final payout may differ slightly from the requested amount.
|
||||
|
||||
After a successful withdrawal, the _total asset_ and _total share_ values are updated like so:
|
||||
|
||||
```js
|
||||
Γ_assets = Γ_assets - Δ_assets_out // New balance of assets in the vault.
|
||||
Γ_shares = Γ_shares - Δ_shares // New share balance in the vault.
|
||||
```
|
||||
|
||||
{% /tab %}
|
||||
{% /tabs %}
|
||||
|
||||
### Can a Depositor Transfer Shares to Another Account?
|
||||
|
||||
Vault shares are a first-class asset, meaning that they can be transferred and used in other on-ledger protocols that support MPTs. However, the payee (or the receiver) must have permission to hold both the shares and the underlying asset.
|
||||
|
||||
For example, if a private vault holds USDC, the destination account must belong to the vault’s Permissioned Domain and have permission to hold USDC. Any compliance mechanisms applied to USDC also apply to the shares. If the USDC issuer freezes the payee’s trust line, the payee cannot receive shares representing USDC.
|
||||
|
||||
{% admonition type="info" name="Note" %}
|
||||
It is important to remember that a vault must be **configured** to allow share transfers, or this will not be possible.
|
||||
{% /admonition %}
|
||||
|
||||
A depositor can transfer vault shares to another account by making a [Payment](../../references/protocol/transactions/types/payment) transaction. Nothing changes in the way the payment transaction is submitted for transferring vault shares. However, there are new failure scenarios to watch out for if the transaction fails:
|
||||
|
||||
- The vault is private and the payee lacks credentials in the vault's permissioned domain.
|
||||
- The vault shares are configured as non-transferable.
|
||||
- There is a global freeze (trust line tokens) or lock (MPTs) on the underlying asset.
|
||||
- The underlying asset is an MPT and is locked for the payer, payee, or vault pseudo-account.
|
||||
- The underlying asset is a trust line token and the trust line is frozen between the issuer and the payer, payee, or vault pseudo-account.
|
||||
|
||||
If the transfer succeeds and the payee already holds vault shares, their balance increases. Otherwise, a new MPT entry is created for their account.
|
||||
|
||||
## Compliance
|
||||
|
||||
### Frozen Assets
|
||||
|
||||
The issuer of a vault asset can enact a [freeze](./fungible-tokens/freezes) for trust line tokens or [lock an MPT](./fungible-tokens/deep-freeze#how-does-mpt-freeze/lock-behavior-differ-from-iou). When a vault asset is frozen:
|
||||
|
||||
1. Withdrawals can only be made to the asset’s issuer.
|
||||
2. The asset cannot be deposited into the vault.
|
||||
3. Its corresponding shares also cannot be transferred.
|
||||
|
||||
### Clawback
|
||||
|
||||
An asset issuer can perform a [Clawback](../../use-cases/tokenization/stablecoin-issuer#clawback) on vault assets by forcing redemption of shares held by an account. This exchanges the holder's shares for the underlying assets, which are sent directly to the issuer. This mechanism allows asset issuers to recover their issued assets from vault depositors when necessary for fraud prevention or regulatory compliance.
|
||||
|
||||
## Why Use a Single Asset Vault?
|
||||
|
||||
With a single asset vault you don't have to manage liquidity at the protocol level. Instead, you can use the vault to handle deposits, redemptions, and asset tracking separately.
|
||||
|
||||
Vaults handle asset-to-share conversion, ensure accurate pricing, and eliminate the need to add custom logic to calculate exchange rates or account for unrealized losses.
|
||||
|
||||
Depending on the connected on-chain protocol, vaults can be applied to various use cases, such as:
|
||||
|
||||
- Lending markets
|
||||
- Aggregators
|
||||
- Yield-bearing tokens
|
||||
- Asset management
|
||||
|
||||
The only supported use cases right now are _asset management_ and [_lending markets_](./lending-protocol.md).
|
||||
|
||||
{% raw-partial file="/docs/_snippets/common-links.md" /%}
|
||||
|
||||
## See Also
|
||||
|
||||
- **Concepts:**
|
||||
- [Credentials](../../concepts/decentralized-storage/credentials.md) - Define access requirements for private vaults.
|
||||
- [Permissioned Domains](../tokens/decentralized-exchange/permissioned-domains.md) - Control access to private vaults.
|
||||
- [Pseudo-Accounts](../accounts/pseudo-accounts.md) - Special accounts that hold assets on behalf of on-chain protocols.
|
||||
- **References:**
|
||||
- [Vault entry][] - Data structure on the ledger that records vault information.
|
||||
- [VaultClawback transaction][] - Allow asset issuers to recover assets from the vault.
|
||||
- [VaultCreate transaction][] - Create a new vault for aggregating assets.
|
||||
- [VaultDelete transaction][] - Delete an existing vault entry.
|
||||
- [VaultDeposit transaction][] - Add assets to a vault in exchange for shares.
|
||||
- [VaultSet transaction][] - Update the configuration of an existing vault.
|
||||
- [VaultWithdraw transaction][] - Redeem liquidity from a vault.
|
||||
- [vault_info method][] - Retrieve information about a vault and its shares.
|
||||
353
docs/img/_sources/get-escrow-sequence.uxf
Normal file
353
docs/img/_sources/get-escrow-sequence.uxf
Normal file
@@ -0,0 +1,353 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="14.2">
|
||||
<zoom_level>10</zoom_level>
|
||||
<element>
|
||||
<id>UMLObject</id>
|
||||
<coordinates>
|
||||
<x>20</x>
|
||||
<y>300</y>
|
||||
<w>160</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Escrow ledger entry
|
||||
--
|
||||
Account
|
||||
PreviousTxnID
|
||||
...</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>170</x>
|
||||
<y>330</y>
|
||||
<w>210</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<.
|
||||
look up transaction
|
||||
by Previous TxnID</panel_attributes>
|
||||
<additional_attributes>190.0;20.0;10.0;20.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLObject</id>
|
||||
<coordinates>
|
||||
<x>360</x>
|
||||
<y>300</y>
|
||||
<w>160</w>
|
||||
<h>140</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Transaction
|
||||
--
|
||||
tx_json
|
||||
TransactionType
|
||||
Sequence
|
||||
...
|
||||
meta
|
||||
AffectedNodes
|
||||
...
|
||||
halign=left</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>420</x>
|
||||
<y>520</y>
|
||||
<w>40</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>type=decision</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>430</x>
|
||||
<y>430</y>
|
||||
<w>270</w>
|
||||
<h>110</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
Is TransactionType == EscrowCreate?</panel_attributes>
|
||||
<additional_attributes>10.0;90.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>450</x>
|
||||
<y>520</y>
|
||||
<w>120</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
Yes</panel_attributes>
|
||||
<additional_attributes>100.0;20.0;10.0;20.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>610</x>
|
||||
<y>880</y>
|
||||
<w>20</w>
|
||||
<h>20</h>
|
||||
</coordinates>
|
||||
<panel_attributes>type=final
|
||||
</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>300</x>
|
||||
<y>520</y>
|
||||
<w>140</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
No</panel_attributes>
|
||||
<additional_attributes>10.0;20.0;120.0;20.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>160</x>
|
||||
<y>490</y>
|
||||
<w>150</w>
|
||||
<h>100</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Check metadata for the same Escrow.
|
||||
|
||||
Get the prior PreviousTxnID.
|
||||
style=wordwrap</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>190</x>
|
||||
<y>340</y>
|
||||
<w>30</w>
|
||||
<h>170</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=.></panel_attributes>
|
||||
<additional_attributes>10.0;150.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>430</x>
|
||||
<y>740</y>
|
||||
<w>170</w>
|
||||
<h>100</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Use the escrow's Account and this transaction's Sequence number to finish or cancel the escrow.
|
||||
style=wordwrap</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>500</x>
|
||||
<y>830</y>
|
||||
<w>130</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>110.0;60.0;10.0;60.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>80</x>
|
||||
<y>110</y>
|
||||
<w>790</w>
|
||||
<h>210</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
r2=No, or yes but this escrow is from before that</panel_attributes>
|
||||
<additional_attributes>10.0;190.0;10.0;20.0;770.0;20.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>860</x>
|
||||
<y>20</y>
|
||||
<w>20</w>
|
||||
<h>20</h>
|
||||
</coordinates>
|
||||
<panel_attributes>type=initial</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>600</x>
|
||||
<y>640</y>
|
||||
<w>40</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>type=decision</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>550</x>
|
||||
<y>500</y>
|
||||
<w>150</w>
|
||||
<h>90</h>
|
||||
</coordinates>
|
||||
<panel_attributes>This is the transaction that created the escrow.
|
||||
style=wordwrap</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>610</x>
|
||||
<y>580</y>
|
||||
<w>140</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
Is Sequence == 0?</panel_attributes>
|
||||
<additional_attributes>10.0;60.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>500</x>
|
||||
<y>640</y>
|
||||
<w>120</w>
|
||||
<h>120</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
r2=No</panel_attributes>
|
||||
<additional_attributes>10.0;100.0;10.0;20.0;100.0;20.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>640</x>
|
||||
<y>740</y>
|
||||
<w>170</w>
|
||||
<h>110</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Use the escrow's Account and this transaction's TicketSequence number to finish or cancel the escrow.
|
||||
style=wordwrap</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>630</x>
|
||||
<y>640</y>
|
||||
<w>120</w>
|
||||
<h>120</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
r2=Yes</panel_attributes>
|
||||
<additional_attributes>100.0;100.0;100.0;20.0;10.0;20.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>620</x>
|
||||
<y>840</y>
|
||||
<w>130</w>
|
||||
<h>70</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>10.0;50.0;110.0;50.0;110.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>860</x>
|
||||
<y>190</y>
|
||||
<w>30</w>
|
||||
<h>740</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=..</panel_attributes>
|
||||
<additional_attributes>10.0;720.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>850</x>
|
||||
<y>110</y>
|
||||
<w>40</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>bg=green
|
||||
type=decision</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>860</x>
|
||||
<y>30</y>
|
||||
<w>340</w>
|
||||
<h>100</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
Is the IncludeKeyletFields amendment enabled?
|
||||
(new in rippled 3.0.0)
|
||||
|
||||
</panel_attributes>
|
||||
<additional_attributes>10.0;80.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>880</x>
|
||||
<y>90</y>
|
||||
<w>250</w>
|
||||
<h>220</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
r2=Yes, and this escrow was \ncreated after it went live</panel_attributes>
|
||||
<additional_attributes>230.0;200.0;230.0;40.0;10.0;40.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLObject</id>
|
||||
<coordinates>
|
||||
<x>1030</x>
|
||||
<y>290</y>
|
||||
<w>160</w>
|
||||
<h>100</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Escrow ledger entry
|
||||
--
|
||||
Account
|
||||
Sequence
|
||||
PreviousTxnID
|
||||
...</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>1030</x>
|
||||
<y>460</y>
|
||||
<w>170</w>
|
||||
<h>100</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Use the escrow's Account and Sequence fields to finish or cancel the escrow.
|
||||
style=wordwrap</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>1100</x>
|
||||
<y>380</y>
|
||||
<w>30</w>
|
||||
<h>100</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>10.0;80.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
</diagram>
|
||||
31
docs/img/lending-protocol-diagram.svg
Normal file
31
docs/img/lending-protocol-diagram.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 100 KiB |
1
docs/img/single-asset-vault-img.svg
Normal file
1
docs/img/single-asset-vault-img.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 39 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user