mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2026-03-07 05:02:25 +00:00
Compare commits
167 Commits
prettier
...
copilot/or
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a9bd7adcb | ||
|
|
2680344850 | ||
|
|
16364ea2d5 | ||
|
|
27c25dbb12 | ||
|
|
61fc160523 | ||
|
|
dc3db2c4f2 | ||
|
|
3ca8de9646 | ||
|
|
2ca8706e41 | ||
|
|
dc0778b666 | ||
|
|
7268a0e52e | ||
|
|
025c262f3e | ||
|
|
f26c5921b8 | ||
|
|
4094d1f76a | ||
|
|
62288d6c3b | ||
|
|
f5f08d8690 | ||
|
|
88c28dfd05 | ||
|
|
c297fc5960 | ||
|
|
fa9ddb8d67 | ||
|
|
3c14520ad0 | ||
|
|
a83e6e3a1a | ||
|
|
79e800baae | ||
|
|
646d4a7381 | ||
|
|
62238e2ba8 | ||
|
|
f211351f4c | ||
|
|
7c41d016db | ||
|
|
0c6283624b | ||
|
|
7a4041865a | ||
|
|
a2c7afb400 | ||
|
|
8750c196b9 | ||
|
|
91c7014676 | ||
|
|
37ca34a5a1 | ||
|
|
4d4ce6b9e1 | ||
|
|
c8f5f8456c | ||
|
|
43e61b4844 | ||
|
|
fbbd88a069 | ||
|
|
a57c4b7d76 | ||
|
|
0c63250bdf | ||
|
|
60d7292eb6 | ||
|
|
10f57ddd43 | ||
|
|
2cbd652135 | ||
|
|
636f175ada | ||
|
|
36d1448047 | ||
|
|
575615487a | ||
|
|
b12112187e | ||
|
|
cffcf05da6 | ||
|
|
c2dd33cf37 | ||
|
|
9c729d9223 | ||
|
|
a7e2464d46 | ||
|
|
9af8e7849e | ||
|
|
43c2bec558 | ||
|
|
65f7ded0cf | ||
|
|
a3ed1f2c34 | ||
|
|
d4a5f752d7 | ||
|
|
adbf7dbb2f | ||
|
|
21bd1991e6 | ||
|
|
b2d86aef14 | ||
|
|
28e4927131 | ||
|
|
c62d5090d0 | ||
|
|
19ec38e7d8 | ||
|
|
f119214cea | ||
|
|
69d4113536 | ||
|
|
f5988554db | ||
|
|
5ad87dee4b | ||
|
|
66caa79289 | ||
|
|
ff75fc0af9 | ||
|
|
1e2f9ea0b0 | ||
|
|
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 |
38
.github/CODEOWNERS
vendored
Normal file
38
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# CODEOWNERS
|
||||
# Defines code ownership for automatic review assignment.
|
||||
# The last matching pattern takes precedence.
|
||||
# See: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
|
||||
|
||||
# Global default — core maintainers review everything
|
||||
* @XRPLF/docs-maintainers
|
||||
|
||||
# Concepts and narrative docs
|
||||
/docs/concepts/ @XRPLF/docs-maintainers
|
||||
|
||||
# Tutorials
|
||||
/docs/tutorials/ @XRPLF/docs-maintainers
|
||||
|
||||
# API reference
|
||||
/docs/references/ @XRPLF/docs-maintainers
|
||||
|
||||
# Infrastructure / node docs
|
||||
/docs/infrastructure/ @XRPLF/docs-maintainers
|
||||
|
||||
# Code samples — require technical review
|
||||
/_code-samples/ @XRPLF/docs-maintainers
|
||||
|
||||
# API examples
|
||||
/_api-examples/ @XRPLF/docs-maintainers
|
||||
|
||||
# Site theme and web tooling
|
||||
/@theme/ @XRPLF/docs-maintainers
|
||||
/styles/ @XRPLF/docs-maintainers
|
||||
|
||||
# Localization files
|
||||
/@l10n/ @XRPLF/docs-maintainers
|
||||
|
||||
# CI/CD and project configuration — maintainer-only
|
||||
/.github/ @XRPLF/docs-maintainers
|
||||
/redocly.yaml @XRPLF/docs-maintainers
|
||||
/package.json @XRPLF/docs-maintainers
|
||||
/package-lock.json @XRPLF/docs-maintainers
|
||||
67
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
67
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
name: "Bug Report"
|
||||
description: Report a typo, broken link, incorrect information, or other documentation error
|
||||
title: "[Bug]: "
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for helping improve the XRP Ledger documentation! Please fill out this form as completely as possible.
|
||||
|
||||
- type: input
|
||||
id: page-url
|
||||
attributes:
|
||||
label: Affected Page URL
|
||||
description: The URL of the page with the issue (e.g. https://xrpl.org/docs/...)
|
||||
placeholder: "https://xrpl.org/docs/..."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: bug-type
|
||||
attributes:
|
||||
label: Type of Issue
|
||||
description: What kind of problem did you find?
|
||||
options:
|
||||
- Typo or grammar error
|
||||
- Broken or incorrect link
|
||||
- Incorrect technical information
|
||||
- Outdated content
|
||||
- Missing content
|
||||
- Formatting or display issue
|
||||
- Other
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: Describe the problem clearly. Include what is wrong and what it should say instead.
|
||||
placeholder: "The page states X, but it should say Y because..."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected Content
|
||||
description: What should the correct content say?
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: input
|
||||
id: source-reference
|
||||
attributes:
|
||||
label: Source Reference (optional)
|
||||
description: Link to source code, specification, or other reference that confirms the correct information
|
||||
placeholder: "https://github.com/XRPLF/rippled/..."
|
||||
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: Checklist
|
||||
options:
|
||||
- label: I have searched existing issues to confirm this has not already been reported
|
||||
required: true
|
||||
- label: I have verified this issue exists on the live site (not just locally)
|
||||
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: XRP Ledger Developer Discord
|
||||
url: https://discord.gg/xrpl
|
||||
about: Ask questions and discuss XRP Ledger development with the community
|
||||
- name: XRPL.org Feedback
|
||||
url: https://xrpl.org/about/contact
|
||||
about: General feedback about the XRP Ledger portal
|
||||
86
.github/ISSUE_TEMPLATE/content_update.yml
vendored
Normal file
86
.github/ISSUE_TEMPLATE/content_update.yml
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
name: "Content Update"
|
||||
description: Request an update, addition, or improvement to existing documentation
|
||||
title: "[Content]: "
|
||||
labels: ["content updates"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Use this template to request changes to existing documentation content — for example, adding new details, updating outdated information, or improving clarity.
|
||||
|
||||
- type: input
|
||||
id: page-url
|
||||
attributes:
|
||||
label: Affected Page URL
|
||||
description: URL of the page that needs updating (if applicable)
|
||||
placeholder: "https://xrpl.org/docs/..."
|
||||
|
||||
- type: dropdown
|
||||
id: update-type
|
||||
attributes:
|
||||
label: Type of Update
|
||||
options:
|
||||
- Add missing information
|
||||
- Update outdated content
|
||||
- Improve clarity or readability
|
||||
- Reorganize or restructure content
|
||||
- Add examples or code samples
|
||||
- Other
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: content-area
|
||||
attributes:
|
||||
label: Content Area
|
||||
description: Which area of the documentation does this affect?
|
||||
options:
|
||||
- Concepts
|
||||
- Tutorials
|
||||
- References / API
|
||||
- Infrastructure / Nodes
|
||||
- Tokenization / NFTs
|
||||
- DEX / AMM
|
||||
- Payment Channels / Escrow
|
||||
- Accounts / Wallets
|
||||
- Localization / Translation
|
||||
- Site tooling
|
||||
- Other
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: Describe what needs to be changed and why. Be as specific as possible.
|
||||
placeholder: "The documentation for X needs to be updated because..."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: source-reference
|
||||
attributes:
|
||||
label: Source / Reference
|
||||
description: Link to the rippled source, amendment details, XLS proposal, or other authoritative reference
|
||||
placeholder: "https://github.com/XRPLF/rippled/..."
|
||||
|
||||
- type: dropdown
|
||||
id: amendment-status
|
||||
attributes:
|
||||
label: Amendment Status (if applicable)
|
||||
description: If this relates to a protocol amendment, what is its status?
|
||||
options:
|
||||
- "N/A"
|
||||
- In development (not yet proposed)
|
||||
- Proposed (in open voting)
|
||||
- Enabled on Mainnet
|
||||
- Enabled on Devnet/Testnet only
|
||||
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: Checklist
|
||||
options:
|
||||
- label: I have searched existing issues to avoid duplicates
|
||||
required: true
|
||||
66
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
66
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
name: "Feature Request"
|
||||
description: Suggest a new page, section, tool, or site feature
|
||||
title: "[Feature]: "
|
||||
labels: ["enhancement"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Use this template to suggest a new documentation page, site feature, or tooling improvement for the XRP Ledger Developer Portal.
|
||||
|
||||
- type: dropdown
|
||||
id: feature-type
|
||||
attributes:
|
||||
label: Feature Type
|
||||
options:
|
||||
- New documentation page or section
|
||||
- New interactive tool or code sample
|
||||
- Site navigation or UX improvement
|
||||
- Developer tooling or CI/CD improvement
|
||||
- Localization support
|
||||
- Other
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: problem
|
||||
attributes:
|
||||
label: Problem to Solve
|
||||
description: Describe the problem or gap this feature would address. Who would benefit?
|
||||
placeholder: "As a developer building on the XRP Ledger, I need..."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Proposed Solution
|
||||
description: Describe what you'd like to see added or changed.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternatives Considered
|
||||
description: Have you considered any alternative approaches?
|
||||
|
||||
- type: dropdown
|
||||
id: priority
|
||||
attributes:
|
||||
label: Priority (your assessment)
|
||||
options:
|
||||
- Low – nice to have
|
||||
- Medium – would significantly improve the docs
|
||||
- High – blocks common developer workflows
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: Checklist
|
||||
options:
|
||||
- label: I have searched existing issues to avoid duplicates
|
||||
required: true
|
||||
- label: I am willing to contribute a PR for this feature
|
||||
52
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
52
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
## Description
|
||||
|
||||
<!-- Provide a clear, concise description of what this PR does. -->
|
||||
|
||||
Fixes #<!-- issue number -->
|
||||
|
||||
## Type of Change
|
||||
|
||||
<!-- Check all that apply -->
|
||||
- [ ] Bug fix (documentation typo, broken link, incorrect information)
|
||||
- [ ] Content update (new information, updated existing docs)
|
||||
- [ ] New page or section
|
||||
- [ ] Site feature / tooling change
|
||||
- [ ] Localization / translation
|
||||
- [ ] Refactoring (no functional change)
|
||||
|
||||
## RACI Confirmation
|
||||
|
||||
This project follows a RACI model for contributions. Please confirm the following:
|
||||
|
||||
| Role | Description | Confirmed |
|
||||
|------|-------------|-----------|
|
||||
| **R – Responsible** | I am the author of these changes and have completed the work described above | - [ ] |
|
||||
| **A – Accountable** | I understand that a maintainer must approve this PR before it can be merged | - [ ] |
|
||||
| **C – Consulted** | I have tagged relevant subject-matter experts as reviewers (if applicable) | - [ ] |
|
||||
| **I – Informed** | The linked issue keeps stakeholders informed of this change | - [ ] |
|
||||
|
||||
> See [RACI Model](.github/project-management/RACI.md) for full role definitions.
|
||||
|
||||
## Review Checklist
|
||||
|
||||
**Author (Responsible)**
|
||||
- [ ] PR is linked to an open issue
|
||||
- [ ] Changes are accurate and technically correct
|
||||
- [ ] Content follows the [style guide](https://xrpl.org/resources/contribute-documentation/)
|
||||
- [ ] All links work and point to correct targets
|
||||
- [ ] Code samples (if any) have been tested
|
||||
- [ ] Localization impact considered (does this need translation updates?)
|
||||
|
||||
**Reviewer (Accountable / Consulted)**
|
||||
- [ ] Technical accuracy verified
|
||||
- [ ] Writing is clear and follows style guidelines
|
||||
- [ ] No broken links or missing references
|
||||
- [ ] No security-sensitive information inadvertently exposed
|
||||
|
||||
## Screenshots (if applicable)
|
||||
|
||||
<!-- Add before/after screenshots for UI or formatting changes -->
|
||||
|
||||
## Additional Notes
|
||||
|
||||
<!-- Any context, decisions made, or follow-up items -->
|
||||
80
.github/labeler.yml
vendored
Normal file
80
.github/labeler.yml
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
# Auto-labeler configuration for pull_request_target events.
|
||||
# Labels are applied based on which files are changed in the PR.
|
||||
# See: https://github.com/actions/labeler
|
||||
|
||||
"content updates":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- "docs/**/*.md"
|
||||
- "docs/**/*.mdx"
|
||||
- "docs/**/*.page.tsx"
|
||||
|
||||
"web dev":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- "@theme/**"
|
||||
- "styles/**"
|
||||
- "*.tsx"
|
||||
- "*.ts"
|
||||
- "shared/**"
|
||||
|
||||
"docs-tooling":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- ".github/**"
|
||||
- "redocly.yaml"
|
||||
- "package.json"
|
||||
- "package-lock.json"
|
||||
- "tsconfig.json"
|
||||
- "sidebars.yaml"
|
||||
- "redirects.yaml"
|
||||
|
||||
"localization":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- "@l10n/**"
|
||||
- "translations.yaml"
|
||||
- "**/*.ja.md"
|
||||
- "**/*.es-ES.md"
|
||||
|
||||
"javascript":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- "_code-samples/**/*.js"
|
||||
- "_code-samples/**/*.mjs"
|
||||
- "_code-samples/**/*.cjs"
|
||||
- "docs/tutorials/**/*javascript*"
|
||||
- "docs/tutorials/**/*js*"
|
||||
|
||||
"python":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- "_code-samples/**/*.py"
|
||||
- "docs/tutorials/**/*python*"
|
||||
|
||||
"java":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- "_code-samples/**/*.java"
|
||||
- "docs/tutorials/**/*java*"
|
||||
|
||||
"tokenization":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- "docs/**/*nft*"
|
||||
- "docs/**/*token*"
|
||||
- "docs/**/*fungible*"
|
||||
- "docs/tutorials/nfts/**"
|
||||
- "docs/concepts/tokens/**"
|
||||
|
||||
"infra":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- "docs/infrastructure/**"
|
||||
|
||||
"organization":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- "sidebars.yaml"
|
||||
- "top-nav.yaml"
|
||||
- "redirects.yaml"
|
||||
179
.github/project-management/RACI.md
vendored
Normal file
179
.github/project-management/RACI.md
vendored
Normal file
@@ -0,0 +1,179 @@
|
||||
# RACI Model — XRP Ledger Developer Portal
|
||||
|
||||
This document defines the **RACI model** used to manage contributions to the XRP Ledger Developer Portal. RACI ensures every task has clear ownership, appropriate oversight, and proper communication for all stakeholders.
|
||||
|
||||
---
|
||||
|
||||
## What is RACI?
|
||||
|
||||
| Letter | Role | Description |
|
||||
|--------|------|-------------|
|
||||
| **R** | **Responsible** | The person who does the work. Every issue and PR must have exactly one responsible party. |
|
||||
| **A** | **Accountable** | The person ultimately answerable for the outcome. Must approve work before it is merged. There is always exactly one accountable person per change. |
|
||||
| **C** | **Consulted** | Subject-matter experts whose input is needed before or during the work. Two-way communication. |
|
||||
| **I** | **Informed** | Stakeholders kept up to date on decisions and outcomes. One-way communication. |
|
||||
|
||||
---
|
||||
|
||||
## Role Mapping for This Project
|
||||
|
||||
### R – Responsible (Contributors)
|
||||
|
||||
- **Community contributors** — anyone opening issues or submitting PRs
|
||||
- **Assigned issue owners** — maintainers or contributors assigned to an issue
|
||||
- Responsible parties create PRs, write content, and address review feedback
|
||||
- A single contributor should be assigned `Responsible` per issue/PR
|
||||
|
||||
### A – Accountable (Maintainers / CODEOWNERS)
|
||||
|
||||
- The **`@XRPLF/docs-maintainers`** team is accountable for all merged changes
|
||||
- Enforced via [CODEOWNERS](../CODEOWNERS): every PR requires at least **one approval** from a code owner before it can be merged
|
||||
- Maintainers may delegate review to subject-matter experts (Consulted) but remain accountable for the final merge decision
|
||||
- Branch protection rules require:
|
||||
- ✅ At least **1 approving review** from a CODEOWNER
|
||||
- ✅ All **status checks pass** (CI workflows)
|
||||
- ✅ **No unresolved conversations**
|
||||
|
||||
### C – Consulted (Subject-Matter Experts)
|
||||
|
||||
Depending on the content area, the relevant experts should be tagged as reviewers:
|
||||
|
||||
| Content Area | Who to Consult |
|
||||
|---|---|
|
||||
| Protocol / core XRP Ledger mechanics | Protocol engineers (`@XRPLF/rippled` team members) |
|
||||
| Smart contracts / Hooks | Hooks developers |
|
||||
| NFT / tokenization | Tokenization working group |
|
||||
| AMM / DeFi | DeFi working group |
|
||||
| Client libraries (xrpl.js, xrpl-py, xrpl4j) | Respective library maintainers |
|
||||
| Localization | Translation contributors for the target language |
|
||||
| Site tooling / Redocly | Redocly configuration owners |
|
||||
|
||||
Tag SMEs using `@username` in PR descriptions or inline review comments.
|
||||
|
||||
### I – Informed (Stakeholders)
|
||||
|
||||
The following parties are automatically informed via GitHub notifications:
|
||||
|
||||
- **Issue reporters** — notified of comments and resolution
|
||||
- **PR watchers** — subscribed to PR updates
|
||||
- **Repository watchers** — receive notifications for all activity
|
||||
- **Linked issues** — cross-referenced via `Fixes #<number>` in PR descriptions
|
||||
|
||||
---
|
||||
|
||||
## RACI by Activity Type
|
||||
|
||||
| Activity | R (Does the Work) | A (Approves) | C (Consulted) | I (Informed) |
|
||||
|---|---|---|---|---|
|
||||
| Report a bug or issue | Community contributor | Maintainer (triage) | — | Repo watchers |
|
||||
| Fix a documentation bug | Community contributor / Maintainer | CODEOWNER | SME if technical | Issue reporter |
|
||||
| Write a new doc page | Assigned contributor | CODEOWNER | Protocol SME + Tech writer | Community |
|
||||
| Update API reference | Assigned contributor | CODEOWNER | Protocol engineer | Developers |
|
||||
| Add/update code sample | Contributor | CODEOWNER | Library maintainer | Developers |
|
||||
| Merge a PR | — | CODEOWNER | — | PR author, watchers |
|
||||
| Triage issues | Maintainer | Lead maintainer | — | Issue reporter |
|
||||
| Release / deploy | CI/CD (automated) | Lead maintainer | — | Stakeholders |
|
||||
| Update site tooling | Maintainer | CODEOWNER | Redocly config owner | All contributors |
|
||||
|
||||
---
|
||||
|
||||
## Workflow Summary
|
||||
|
||||
```
|
||||
Community Contributor (R)
|
||||
│
|
||||
├─ Opens Issue ──────────────────────► Auto-triage labels applied
|
||||
│ Maintainer triages & prioritizes
|
||||
│
|
||||
└─ Opens Pull Request ────────────────► PR Validation check runs
|
||||
│ Auto-labels applied
|
||||
│ Greeting for new contributors
|
||||
│
|
||||
├─ Tags SME reviewers (C) ───────► SMEs leave review comments
|
||||
│
|
||||
└─ Maintainer reviews (A) ───────► Approves or requests changes
|
||||
│
|
||||
└─ All checks pass ─────────► PR merged by Accountable maintainer
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Project Board
|
||||
|
||||
The XRP Ledger Developer Portal uses a **GitHub Project board** to track issue and PR status. The board has the following columns:
|
||||
|
||||
| Column | Description |
|
||||
|---|---|
|
||||
| **📋 Backlog** | Issues that are accepted but not yet scheduled |
|
||||
| **🔍 Needs Triage** | New issues awaiting maintainer review |
|
||||
| **📅 Planned** | Issues scheduled for an upcoming milestone |
|
||||
| **🚧 In Progress** | Issues with a linked open PR or active assignee |
|
||||
| **👀 In Review** | PRs awaiting review or with pending change requests |
|
||||
| **✅ Done** | Merged PRs and closed issues |
|
||||
|
||||
> **Setup**: Maintainers can create and configure the board at:
|
||||
> [organization-level project](https://github.com/orgs/XRPLF/projects)
|
||||
> or
|
||||
> [repository-level project](https://github.com/XRPLF/xrpl-dev-portal/projects)
|
||||
|
||||
### Automation Rules (configure in GitHub Projects)
|
||||
|
||||
- **Issue opened** → Move to _Needs Triage_
|
||||
- **Label `stale` added** → Move to _Backlog_
|
||||
- **PR opened / linked to issue** → Move issue to _In Progress_
|
||||
- **PR review requested** → Move PR to _In Review_
|
||||
- **PR merged** → Move to _Done_ and close linked issue
|
||||
- **Issue closed** → Move to _Done_
|
||||
|
||||
---
|
||||
|
||||
## Branch Protection Requirements
|
||||
|
||||
To enforce the "at least one human review" requirement, configure branch protection on `master`:
|
||||
|
||||
1. Go to **Settings → Branches → Branch protection rules**
|
||||
2. Add a rule for `master` (or your default branch)
|
||||
3. Enable:
|
||||
- ✅ **Require a pull request before merging**
|
||||
- ✅ **Require approvals** — set to **1** (minimum)
|
||||
- ✅ **Require review from Code Owners** (enforces CODEOWNERS file)
|
||||
- ✅ **Require status checks to pass before merging**
|
||||
- Add: `validate-pr` (from `pr-check.yml`)
|
||||
- ✅ **Require conversation resolution before merging**
|
||||
- ✅ **Do not allow bypassing the above settings** (for non-admins)
|
||||
|
||||
---
|
||||
|
||||
## Labels Reference
|
||||
|
||||
| Label | Description | Who Applies |
|
||||
|---|---|---|
|
||||
| `bug` | Typo, broken link, or incorrect info | Auto-triage / contributor |
|
||||
| `content updates` | Updates to existing documentation | Auto-triage / maintainer |
|
||||
| `enhancement` | New pages or features | Auto-triage / maintainer |
|
||||
| `good first issue` | Suitable for new contributors | Maintainer |
|
||||
| `help wanted` | Community contributions welcome | Maintainer |
|
||||
| `needs triage` | Awaiting maintainer review | Auto-triage |
|
||||
| `stale` | No activity for 90+ days | Stale bot |
|
||||
| `wip` | Work in progress, not ready for review | Contributor |
|
||||
| `tokenization` | NFT/token-related content | Auto-triage |
|
||||
| `infra` | Validator/node/server content | Auto-triage |
|
||||
| `web dev` | Site tooling, styles, templates | Auto-triage |
|
||||
| `organization` | Navigation, structure, architecture | Auto-triage |
|
||||
| `docs-tooling` | CI/CD, build tooling | Auto-triage |
|
||||
| `localization` | Translation and i18n | Auto-triage |
|
||||
| `javascript` | JavaScript code samples/tutorials | Auto-triage |
|
||||
| `python` | Python code samples/tutorials | Auto-triage |
|
||||
|
||||
---
|
||||
|
||||
## Contributing Quick Reference
|
||||
|
||||
1. **Find an issue** — Browse the [project board](https://github.com/XRPLF/xrpl-dev-portal/issues) or open a new one using a template
|
||||
2. **Assign yourself** — Comment "I'll work on this" or ask a maintainer to assign you
|
||||
3. **Fork & branch** — Create a branch from `master`
|
||||
4. **Make changes** — Follow the [style guide](https://xrpl.org/resources/contribute-documentation/)
|
||||
5. **Open a PR** — Fill out the PR template completely, including RACI confirmation
|
||||
6. **Tag reviewers** — Add SMEs as reviewers for technical accuracy
|
||||
7. **Address feedback** — Respond to review comments and push updates
|
||||
8. **Merge** — A maintainer (Accountable) will merge once all checks pass
|
||||
19
.github/workflows/auto-label.yml
vendored
Normal file
19
.github/workflows/auto-label.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
name: Auto-Label Pull Requests
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
label:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/labeler@v5
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
configuration-path: .github/labeler.yml
|
||||
sync-labels: true
|
||||
92
.github/workflows/greet-contributor.yml
vendored
Normal file
92
.github/workflows/greet-contributor.yml
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
name: Greet New Contributors
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
pull_request_target:
|
||||
types: [opened]
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
greet:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Greet first-time issue reporter
|
||||
if: github.event_name == 'issues'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const creator = context.payload.issue.user.login;
|
||||
|
||||
// Check if this is their first issue in the repo
|
||||
const { data: issues } = await github.rest.issues.listForRepo({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
creator: creator,
|
||||
state: 'all',
|
||||
});
|
||||
|
||||
// If only 1 issue exists, it's the one they just opened
|
||||
if (issues.length <= 1) {
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.issue.number,
|
||||
body: [
|
||||
`👋 Welcome to the XRP Ledger Developer Portal, @${creator}! Thanks for opening your first issue.`,
|
||||
'',
|
||||
'Here are a few things to know:',
|
||||
'- A maintainer will triage this issue and add appropriate labels',
|
||||
'- If you\'d like to fix this yourself, check out our [Contributing Guide](https://xrpl.org/resources/contribute-documentation/)',
|
||||
'- Join the conversation on [XRPL Discord](https://discord.gg/xrpl) if you have questions',
|
||||
'',
|
||||
'We appreciate your contribution to the XRP Ledger community! 🚀',
|
||||
].join('\n'),
|
||||
});
|
||||
}
|
||||
|
||||
- name: Greet first-time PR contributor
|
||||
if: github.event_name == 'pull_request_target'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const creator = context.payload.pull_request.user.login;
|
||||
|
||||
// Check previous merged PRs from this user
|
||||
const { data: prs } = await github.rest.pulls.list({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
state: 'all',
|
||||
});
|
||||
|
||||
const userPRs = prs.filter(pr => pr.user.login === creator);
|
||||
|
||||
// If this is their first PR
|
||||
if (userPRs.length <= 1) {
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.pull_request.number,
|
||||
body: [
|
||||
`🎉 Welcome, @${creator}! Thanks for submitting your first pull request to the XRP Ledger Developer Portal.`,
|
||||
'',
|
||||
'Here\'s what happens next:',
|
||||
'1. 🔍 Automated checks will run on your PR',
|
||||
'2. 👀 A maintainer will review your changes (this may take a few days)',
|
||||
'3. 💬 You may receive feedback or requests for changes',
|
||||
'4. ✅ Once approved by a maintainer, your PR will be merged',
|
||||
'',
|
||||
'Please make sure your PR:',
|
||||
'- Has a clear description of what was changed and why',
|
||||
'- Is linked to an open issue (e.g. `Fixes #123`)',
|
||||
'- Follows our [style guide](https://xrpl.org/resources/contribute-documentation/)',
|
||||
'',
|
||||
'Thank you for contributing to the XRP Ledger community! 🙏',
|
||||
].join('\n'),
|
||||
});
|
||||
}
|
||||
97
.github/workflows/issue-triage.yml
vendored
Normal file
97
.github/workflows/issue-triage.yml
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
name: Issue Triage
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened, reopened]
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
triage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Auto-label based on issue title and body
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const issue = context.payload.issue;
|
||||
const title = (issue.title || '').toLowerCase();
|
||||
const body = (issue.body || '').toLowerCase();
|
||||
const text = title + ' ' + body;
|
||||
const labelsToAdd = new Set();
|
||||
|
||||
// --- keyword → label mapping ---
|
||||
const rules = [
|
||||
// Content areas
|
||||
{ patterns: ['nft', 'nonfungible', 'non-fungible', 'token', 'mpt', 'fungible'], label: 'tokenization' },
|
||||
{ patterns: ['amm', 'dex', 'offer', 'liquidity', 'pool'], label: 'defi' },
|
||||
{ patterns: ['escrow', 'payment channel', 'check'], label: 'content updates' },
|
||||
{ patterns: ['tutorial', 'how to', 'how-to', 'walkthrough', 'guide'], label: 'content updates' },
|
||||
{ patterns: ['api', 'rpc', 'websocket', 'method', 'command', 'response field'], label: 'content updates' },
|
||||
{ patterns: ['amendment', 'feature flag'], label: 'content updates' },
|
||||
{ patterns: ['rippled', 'validator', 'node', 'server', 'peer'], label: 'infra' },
|
||||
{ patterns: ['javascript', 'js ', 'node.js', 'typescript'], label: 'javascript' },
|
||||
{ patterns: ['python'], label: 'python' },
|
||||
{ patterns: ['java', 'xrpl4j'], label: 'java' },
|
||||
{ patterns: ['navigate', 'menu', 'sidebar', 'landing page', 'homepage'], label: 'organization' },
|
||||
{ patterns: ['style', 'css', 'layout', 'theme', 'mobile', 'responsive'], label: 'web dev' },
|
||||
{ patterns: ['translate', 'translation', 'locali', 'japanese', 'spanish'], label: 'localization' },
|
||||
{ patterns: ['broken link', 'dead link', '404 error', 'page not found', 'typo', 'grammar', 'spelling'], label: 'bug' },
|
||||
{ patterns: ['redocly', 'build', 'ci ', 'ci/', 'workflow', 'lint', 'tooling'], label: 'docs-tooling' },
|
||||
];
|
||||
|
||||
for (const rule of rules) {
|
||||
if (rule.patterns.some(p => text.includes(p))) {
|
||||
labelsToAdd.add(rule.label);
|
||||
}
|
||||
}
|
||||
|
||||
// If no labels matched, add 'needs triage' so maintainers notice it
|
||||
if (labelsToAdd.size === 0) {
|
||||
labelsToAdd.add('needs triage');
|
||||
}
|
||||
|
||||
const existingLabels = (issue.labels || []).map(l => l.name);
|
||||
const newLabels = [...labelsToAdd].filter(l => !existingLabels.includes(l));
|
||||
|
||||
if (newLabels.length > 0) {
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
labels: newLabels,
|
||||
});
|
||||
console.log(`Added labels: ${newLabels.join(', ')}`);
|
||||
} else {
|
||||
console.log('No new labels to add.');
|
||||
}
|
||||
|
||||
- name: Request triage for unlabeled issues
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const issue = context.payload.issue;
|
||||
const labels = (issue.labels || []).map(l => l.name);
|
||||
|
||||
// If the only label is 'needs triage', add a comment directing maintainers
|
||||
if (labels.length === 1 && labels[0] === 'needs triage') {
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
body: [
|
||||
'👋 Thanks for opening this issue!',
|
||||
'',
|
||||
'This issue has been flagged for **maintainer triage** because it could not be automatically categorized.',
|
||||
'A maintainer will review it shortly to add labels and assess priority.',
|
||||
'',
|
||||
'In the meantime, you can help by:',
|
||||
'- Making sure the issue title clearly describes the problem',
|
||||
'- Adding a link to the affected page (for documentation issues)',
|
||||
'- Providing a reference to source code or specs (for technical accuracy issues)',
|
||||
].join('\n'),
|
||||
});
|
||||
}
|
||||
95
.github/workflows/pr-check.yml
vendored
Normal file
95
.github/workflows/pr-check.yml
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
name: PR Validation
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, edited, synchronize, reopened]
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
issues: read
|
||||
|
||||
jobs:
|
||||
validate-pr:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Validate PR description and linked issue
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const pr = context.payload.pull_request;
|
||||
const body = pr.body || '';
|
||||
const title = pr.title || '';
|
||||
const warnings = [];
|
||||
const errors = [];
|
||||
|
||||
// 1. PR must have a non-trivial description
|
||||
const descriptionSection = body.replace(/<!--[\s\S]*?-->/g, '').trim();
|
||||
if (descriptionSection.length < 30) {
|
||||
errors.push('❌ **Missing description**: Please provide a clear description of what this PR changes and why.');
|
||||
}
|
||||
|
||||
// 2. PR should reference an issue (Fixes/Closes/Resolves #N or mention #N)
|
||||
const issueRef = /(?:fix(?:es|ed)?|close[sd]?|resolve[sd]?)\s+#\d+|#\d+/i.test(body);
|
||||
if (!issueRef) {
|
||||
warnings.push('⚠️ **No linked issue detected**: Consider linking this PR to an issue using `Fixes #<number>` so progress is tracked on the project board.');
|
||||
}
|
||||
|
||||
// 3. RACI table must have at least Responsible checked
|
||||
// Simple check: if the RACI section exists, at least one checkbox should be filled
|
||||
if (body.includes('RACI') && !/- \[x\]/i.test(body)) {
|
||||
warnings.push('⚠️ **RACI checklist incomplete**: Please tick the checkboxes in the RACI Confirmation table.');
|
||||
}
|
||||
|
||||
// 4. Draft PRs skip hard errors
|
||||
const isDraft = pr.draft;
|
||||
|
||||
// Post a review comment only if there are issues
|
||||
if (errors.length > 0 || warnings.length > 0) {
|
||||
const lines = [
|
||||
'## 🤖 PR Validation Report',
|
||||
'',
|
||||
...errors,
|
||||
...warnings,
|
||||
'',
|
||||
isDraft ? '_This is a draft PR — errors above will need to be resolved before requesting review._'
|
||||
: '_Please address the items above before requesting a maintainer review._',
|
||||
'',
|
||||
'---',
|
||||
'_This comment is generated automatically. See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines._',
|
||||
];
|
||||
|
||||
// Check if we already posted a validation comment so we update rather than duplicate
|
||||
const { data: comments } = await github.rest.issues.listComments({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: pr.number,
|
||||
});
|
||||
|
||||
const botComment = comments.find(c =>
|
||||
c.user.type === 'Bot' && c.body.includes('PR Validation Report')
|
||||
);
|
||||
|
||||
const commentBody = lines.join('\n');
|
||||
|
||||
if (botComment) {
|
||||
await github.rest.issues.updateComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
comment_id: botComment.id,
|
||||
body: commentBody,
|
||||
});
|
||||
} else {
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: pr.number,
|
||||
body: commentBody,
|
||||
});
|
||||
}
|
||||
|
||||
// Fail the check if there are hard errors and this is not a draft
|
||||
if (errors.length > 0 && !isDraft) {
|
||||
core.setFailed(`PR validation failed: ${errors.join(' | ')}`);
|
||||
}
|
||||
}
|
||||
73
.github/workflows/stale.yml
vendored
Normal file
73
.github/workflows/stale.yml
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
name: Stale Issue & PR Management
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Runs daily at 01:00 UTC
|
||||
- cron: "0 1 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# ── Issues ────────────────────────────────────────────────────────
|
||||
days-before-issue-stale: 90
|
||||
days-before-issue-close: 14
|
||||
stale-issue-label: "stale"
|
||||
stale-issue-message: >
|
||||
This issue has been open for 90 days with no recent activity.
|
||||
It will be closed in 14 days unless someone comments or removes
|
||||
the `stale` label.
|
||||
|
||||
If this issue is still relevant, please:
|
||||
- Leave a comment with an update
|
||||
- Remove the `stale` label if you plan to work on it
|
||||
- Link it to an open PR if work is already in progress
|
||||
|
||||
close-issue-message: >
|
||||
This issue was closed due to inactivity (90 + 14 days).
|
||||
If you believe it is still relevant, please open a new issue
|
||||
and reference this one.
|
||||
|
||||
# Issues with these labels are never marked stale
|
||||
exempt-issue-labels: >
|
||||
pinned,
|
||||
security,
|
||||
good first issue,
|
||||
help wanted
|
||||
|
||||
# ── Pull Requests ─────────────────────────────────────────────────
|
||||
days-before-pr-stale: 30
|
||||
days-before-pr-close: 7
|
||||
stale-pr-label: "stale"
|
||||
stale-pr-message: >
|
||||
This pull request has been open for 30 days with no recent activity.
|
||||
It will be closed in 7 days unless there is new activity.
|
||||
|
||||
If this PR is still in progress:
|
||||
- Push an update or leave a comment
|
||||
- Remove the `stale` label to reset the timer
|
||||
|
||||
close-pr-message: >
|
||||
This pull request was closed due to inactivity (30 + 7 days).
|
||||
The branch has been preserved. Please open a new PR if you
|
||||
wish to continue this work.
|
||||
|
||||
exempt-pr-labels: >
|
||||
pinned,
|
||||
security,
|
||||
work in progress,
|
||||
wip
|
||||
|
||||
# Keep the stale label when the issue/PR becomes active again
|
||||
remove-stale-when-updated: true
|
||||
# Only count non-bot comments as activity
|
||||
operations-per-run: 100
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,6 +8,7 @@ yarn-error.log
|
||||
*.iml
|
||||
.venv/
|
||||
_code-samples/*/js/package-lock.json
|
||||
_code-samples/*/*/*[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もの準備金が必要になります。
|
||||
|
||||
| 準備金の種類 | 準備金の額 |
|
||||
|:--------------------|--------:|
|
||||
|
||||
@@ -75,10 +75,10 @@ Clioをインストールする前に、以下の条件を満たしている必
|
||||
|
||||
```
|
||||
gpg: WARNING: no command supplied. Trying to guess what you mean ...
|
||||
pub rsa3072 2019-02-14 [SC] [expires: 2026-02-17]
|
||||
C0010EC205B35A3310DC90DE395F97FFCCAFD9A2
|
||||
uid TechOps Team at Ripple <techops+rippled@ripple.com>
|
||||
sub rsa3072 2019-02-14 [E] [expires: 2026-02-17]
|
||||
pub ed25519 2026-02-16 [SC] [expires: 2033-02-14]
|
||||
E057C1CF72B0DF1A4559E8577DEE9236AB06FAA6
|
||||
uid TechOps Team at Ripple <techops+rippled@ripple.com>
|
||||
sub ed25519 2026-02-16 [S] [expires: 2029-02-15]
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@ labels:
|
||||
|
||||
```
|
||||
gpg: WARNING: no command supplied. Trying to guess what you mean ...
|
||||
pub rsa3072 2019-02-14 [SC] [expires: 2026-02-17]
|
||||
C0010EC205B35A3310DC90DE395F97FFCCAFD9A2
|
||||
uid TechOps Team at Ripple <techops+rippled@ripple.com>
|
||||
sub rsa3072 2019-02-14 [E] [expires: 2026-02-17]
|
||||
pub ed25519 2026-02-16 [SC] [expires: 2033-02-14]
|
||||
E057C1CF72B0DF1A4559E8577DEE9236AB06FAA6
|
||||
uid TechOps Team at Ripple <techops+rippled@ripple.com>
|
||||
sub ed25519 2026-02-16 [S] [expires: 2029-02-15]
|
||||
```
|
||||
|
||||
特に、フィンガープリントが一致することを確認してください。(上記の例では、フィンガープリントは三行目の`C001`で始まる部分です。)
|
||||
|
||||
@@ -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,3 +1,32 @@
|
||||
# Contributing
|
||||
|
||||
For information about how to contribute to this repository, see [Contribute Documentation (XRPL.org)](https://xrpl.org/resources/contribute-documentation/).
|
||||
For information about how to contribute to this repository, see [Contribute Documentation (XRPL.org)](https://xrpl.org/resources/contribute-documentation/).
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. **Report an issue** — Use one of the [issue templates](.github/ISSUE_TEMPLATE/) to report bugs, request content updates, or suggest new features.
|
||||
2. **Work on an issue** — Browse [open issues](https://github.com/XRPLF/xrpl-dev-portal/issues) with the `good first issue` or `help wanted` labels.
|
||||
3. **Submit a pull request** — Fill out the [PR template](.github/PULL_REQUEST_TEMPLATE.md) completely, including linking to the issue you are addressing.
|
||||
|
||||
## Review Process (RACI Model)
|
||||
|
||||
This project follows a [RACI model](.github/project-management/RACI.md) to manage contributions:
|
||||
|
||||
- **R – Responsible**: The contributor who authors the change
|
||||
- **A – Accountable**: A maintainer from `@XRPLF/docs-maintainers` who approves and merges
|
||||
- **C – Consulted**: Subject-matter experts tagged as reviewers for technical accuracy
|
||||
- **I – Informed**: Stakeholders notified via linked issues and PR comments
|
||||
|
||||
**At least one maintainer approval is required before any PR can be merged.**
|
||||
|
||||
## Automated Workflows
|
||||
|
||||
The following GitHub Actions workflows run automatically:
|
||||
|
||||
| Workflow | Trigger | Purpose |
|
||||
|---|---|---|
|
||||
| Issue Triage | New issue opened | Applies labels based on content |
|
||||
| PR Validation | PR opened/updated | Validates description and linked issue |
|
||||
| Auto-Label | PR opened/updated | Labels PRs based on changed file paths |
|
||||
| Stale Management | Daily | Marks and closes inactive issues/PRs |
|
||||
| Greet Contributor | First issue/PR | Welcomes new contributors |
|
||||
@@ -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: rn6CD8i3Yc3UGagSosZfegG7hpXxwgVAgz
|
||||
Borrower address: rN2PMxegkEMZHin78o7wSs1JeYjxAvAfvt
|
||||
LoanBrokerID: 3CDEA7CEB9F2ECDD76CD41A864F4E3B5DB9C91AEDBD0906EE466FDD21CCF49B5
|
||||
|
||||
=== Preparing LoanSet transaction ===
|
||||
|
||||
{
|
||||
"TransactionType": "LoanSet",
|
||||
"Account": "rn6CD8i3Yc3UGagSosZfegG7hpXxwgVAgz",
|
||||
"Counterparty": "rN2PMxegkEMZHin78o7wSs1JeYjxAvAfvt",
|
||||
"LoanBrokerID": "3CDEA7CEB9F2ECDD76CD41A864F4E3B5DB9C91AEDBD0906EE466FDD21CCF49B5",
|
||||
"PrincipalRequested": "1000",
|
||||
"InterestRate": 500,
|
||||
"PaymentTotal": 12,
|
||||
"PaymentInterval": 2592000,
|
||||
"GracePeriod": 604800,
|
||||
"LoanOriginationFee": "100",
|
||||
"LoanServiceFee": "10",
|
||||
"Flags": 0,
|
||||
"Sequence": 3670743,
|
||||
"LastLedgerSequence": 3673248,
|
||||
"Fee": "2"
|
||||
}
|
||||
|
||||
=== Adding loan broker signature ===
|
||||
|
||||
TxnSignature: F8B2F2AB960191991FC48120A48A089B479018A6469466E43E6F974E1345B32688D59D381E6BC18B6CA383235B708FE4FB44527C51E5B29BCDCC4A08C340A00A
|
||||
SigningPubKey: EDDABC72936FF734FA56D6C60C064D48C5DA9911C8B7C26C4AEAC06534B5D7C530
|
||||
|
||||
Signed loanSetTx for borrower to sign over:
|
||||
{
|
||||
"TransactionType": "LoanSet",
|
||||
"Flags": 0,
|
||||
"Sequence": 3670743,
|
||||
"LastLedgerSequence": 3673248,
|
||||
"PaymentInterval": 2592000,
|
||||
"GracePeriod": 604800,
|
||||
"PaymentTotal": 12,
|
||||
"InterestRate": 500,
|
||||
"LoanBrokerID": "3CDEA7CEB9F2ECDD76CD41A864F4E3B5DB9C91AEDBD0906EE466FDD21CCF49B5",
|
||||
"Fee": "2",
|
||||
"SigningPubKey": "EDDABC72936FF734FA56D6C60C064D48C5DA9911C8B7C26C4AEAC06534B5D7C530",
|
||||
"TxnSignature": "F8B2F2AB960191991FC48120A48A089B479018A6469466E43E6F974E1345B32688D59D381E6BC18B6CA383235B708FE4FB44527C51E5B29BCDCC4A08C340A00A",
|
||||
"Account": "rn6CD8i3Yc3UGagSosZfegG7hpXxwgVAgz",
|
||||
"Counterparty": "rN2PMxegkEMZHin78o7wSs1JeYjxAvAfvt",
|
||||
"LoanOriginationFee": "100",
|
||||
"LoanServiceFee": "10",
|
||||
"PrincipalRequested": "1000"
|
||||
}
|
||||
|
||||
=== Adding borrower signature ===
|
||||
|
||||
Borrower TxnSignature: 52E16B88F5640F637A05E59AB2BE0DBFE4FBE7F1D7580C2A39D4981F6066A7C42047A401B953CDAB4993954A85D73DE35F69317EE8279D23ECB4958AA10C0800
|
||||
Borrower SigningPubKey: EDE624A07899AEF826DF2A3E2A325F69BC1F169D23F08091E9042644D6B06D3D62
|
||||
|
||||
Fully signed LoanSet transaction:
|
||||
{
|
||||
"TransactionType": "LoanSet",
|
||||
"Flags": 0,
|
||||
"Sequence": 3670743,
|
||||
"LastLedgerSequence": 3673248,
|
||||
"PaymentInterval": 2592000,
|
||||
"GracePeriod": 604800,
|
||||
"PaymentTotal": 12,
|
||||
"InterestRate": 500,
|
||||
"LoanBrokerID": "3CDEA7CEB9F2ECDD76CD41A864F4E3B5DB9C91AEDBD0906EE466FDD21CCF49B5",
|
||||
"Fee": "2",
|
||||
"SigningPubKey": "EDDABC72936FF734FA56D6C60C064D48C5DA9911C8B7C26C4AEAC06534B5D7C530",
|
||||
"TxnSignature": "F8B2F2AB960191991FC48120A48A089B479018A6469466E43E6F974E1345B32688D59D381E6BC18B6CA383235B708FE4FB44527C51E5B29BCDCC4A08C340A00A",
|
||||
"Account": "rn6CD8i3Yc3UGagSosZfegG7hpXxwgVAgz",
|
||||
"Counterparty": "rN2PMxegkEMZHin78o7wSs1JeYjxAvAfvt",
|
||||
"LoanOriginationFee": "100",
|
||||
"LoanServiceFee": "10",
|
||||
"PrincipalRequested": "1000",
|
||||
"CounterpartySignature": {
|
||||
"SigningPubKey": "EDE624A07899AEF826DF2A3E2A325F69BC1F169D23F08091E9042644D6B06D3D62",
|
||||
"TxnSignature": "52E16B88F5640F637A05E59AB2BE0DBFE4FBE7F1D7580C2A39D4981F6066A7C42047A401B953CDAB4993954A85D73DE35F69317EE8279D23ECB4958AA10C0800"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting signed LoanSet transaction ===
|
||||
|
||||
Loan created successfully!
|
||||
|
||||
=== Loan Information ===
|
||||
|
||||
{
|
||||
"Borrower": "rN2PMxegkEMZHin78o7wSs1JeYjxAvAfvt",
|
||||
"GracePeriod": 604800,
|
||||
"InterestRate": 500,
|
||||
"LoanBrokerID": "3CDEA7CEB9F2ECDD76CD41A864F4E3B5DB9C91AEDBD0906EE466FDD21CCF49B5",
|
||||
"LoanOriginationFee": "100",
|
||||
"LoanSequence": 6,
|
||||
"LoanServiceFee": "10",
|
||||
"NextPaymentDueDate": 826862960,
|
||||
"PaymentInterval": 2592000,
|
||||
"PaymentRemaining": 12,
|
||||
"PeriodicPayment": "83.55610375293148956",
|
||||
"PrincipalOutstanding": "1000",
|
||||
"StartDate": 824270960,
|
||||
"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()
|
||||
95
_code-samples/lending-protocol/js/createLoan.js
Normal file
95
_code-samples/lending-protocol/js/createLoan.js
Normal file
@@ -0,0 +1,95 @@
|
||||
// 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 loanBrokerSigned = loanBroker.sign(loanSetTx)
|
||||
const loanBrokerSignedTx = xrpl.decode(loanBrokerSigned.tx_blob)
|
||||
|
||||
console.log(`TxnSignature: ${loanBrokerSignedTx.TxnSignature}`)
|
||||
console.log(`SigningPubKey: ${loanBrokerSignedTx.SigningPubKey}\n`)
|
||||
console.log(`Signed loanSetTx for borrower to sign over:\n${JSON.stringify(loanBrokerSignedTx, null, 2)}`)
|
||||
|
||||
// Borrower signs second
|
||||
console.log(`\n=== Adding borrower signature ===\n`)
|
||||
const fullySigned = xrpl.signLoanSetByCounterparty(borrower, loanBrokerSignedTx)
|
||||
|
||||
console.log(`Borrower TxnSignature: ${fullySigned.tx.CounterpartySignature.TxnSignature}`)
|
||||
console.log(`Borrower SigningPubKey: ${fullySigned.tx.CounterpartySignature.SigningPubKey}`)
|
||||
|
||||
// Validate the transaction structure before submitting.
|
||||
xrpl.validate(fullySigned.tx)
|
||||
console.log(`\nFully signed LoanSet transaction:\n${JSON.stringify(fullySigned.tx, null, 2)}`)
|
||||
|
||||
// Submit and wait for validation ----------------------
|
||||
console.log(`\n=== Submitting signed LoanSet transaction ===\n`)
|
||||
|
||||
const submitResponse = await client.submitAndWait(fullySigned.tx)
|
||||
|
||||
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()
|
||||
341
_code-samples/lending-protocol/js/lendingSetup.js
Normal file
341
_code-samples/lending-protocol/js/lendingSetup.js
Normal file
@@ -0,0 +1,341 @@
|
||||
// Setup script for lending protocol tutorials
|
||||
|
||||
import xrpl from 'xrpl'
|
||||
import fs from 'fs'
|
||||
|
||||
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 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/7\r')
|
||||
|
||||
// Create tickets for parallel transactions
|
||||
const extractTickets = (response) =>
|
||||
response.result.meta.AffectedNodes
|
||||
.filter(node => node.CreatedNode?.LedgerEntryType === 'Ticket')
|
||||
.map(node => node.CreatedNode.NewFields.TicketSequence)
|
||||
|
||||
const [ciTicketResponse, lbTicketResponse, brTicketResponse, dpTicketResponse] = await Promise.all([
|
||||
client.submitAndWait({
|
||||
TransactionType: 'TicketCreate',
|
||||
Account: credentialIssuer.address,
|
||||
TicketCount: 4
|
||||
}, { wallet: credentialIssuer, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'TicketCreate',
|
||||
Account: loanBroker.address,
|
||||
TicketCount: 4
|
||||
}, { wallet: loanBroker, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'TicketCreate',
|
||||
Account: borrower.address,
|
||||
TicketCount: 2
|
||||
}, { wallet: borrower, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'TicketCreate',
|
||||
Account: depositor.address,
|
||||
TicketCount: 2
|
||||
}, { wallet: depositor, autofill: true })
|
||||
])
|
||||
|
||||
const ciTickets = extractTickets(ciTicketResponse)
|
||||
const lbTickets = extractTickets(lbTicketResponse)
|
||||
const brTickets = extractTickets(brTicketResponse)
|
||||
const dpTickets = extractTickets(dpTicketResponse)
|
||||
|
||||
process.stdout.write('Setting up tutorial: 2/7\r')
|
||||
|
||||
// Issue MPT with depositor
|
||||
// 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 [mptIssuanceResponse, domainSetResponse] = await Promise.all([
|
||||
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: 'PermissionedDomainSet',
|
||||
Account: credentialIssuer.address,
|
||||
AcceptedCredentials: [
|
||||
{
|
||||
Credential: {
|
||||
Issuer: credentialIssuer.address,
|
||||
CredentialType: credentialType
|
||||
}
|
||||
}
|
||||
],
|
||||
Sequence: 0,
|
||||
TicketSequence: ciTickets[0]
|
||||
}, { wallet: credentialIssuer, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'CredentialCreate',
|
||||
Account: credentialIssuer.address,
|
||||
Subject: loanBroker.address,
|
||||
CredentialType: credentialType,
|
||||
Sequence: 0,
|
||||
TicketSequence: ciTickets[1]
|
||||
}, { wallet: credentialIssuer, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'CredentialCreate',
|
||||
Account: credentialIssuer.address,
|
||||
Subject: borrower.address,
|
||||
CredentialType: credentialType,
|
||||
Sequence: 0,
|
||||
TicketSequence: ciTickets[2]
|
||||
}, { wallet: credentialIssuer, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'CredentialCreate',
|
||||
Account: credentialIssuer.address,
|
||||
Subject: depositor.address,
|
||||
CredentialType: credentialType,
|
||||
Sequence: 0,
|
||||
TicketSequence: ciTickets[3]
|
||||
}, { wallet: credentialIssuer, autofill: true })
|
||||
])
|
||||
|
||||
// Extract MPT issuance ID
|
||||
const mptID = mptIssuanceResponse.result.meta.mpt_issuance_id
|
||||
|
||||
// Extract domain ID
|
||||
const domainID = domainSetResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.CreatedNode?.LedgerEntryType === 'PermissionedDomain'
|
||||
).CreatedNode.LedgerIndex
|
||||
|
||||
process.stdout.write('Setting up tutorial: 3/7\r')
|
||||
|
||||
// Accept credentials and authorize MPT for each account
|
||||
await Promise.all([
|
||||
client.submitAndWait({
|
||||
TransactionType: 'CredentialAccept',
|
||||
Account: loanBroker.address,
|
||||
Issuer: credentialIssuer.address,
|
||||
CredentialType: credentialType,
|
||||
Sequence: 0,
|
||||
TicketSequence: lbTickets[0]
|
||||
}, { wallet: loanBroker, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'MPTokenAuthorize',
|
||||
Account: loanBroker.address,
|
||||
MPTokenIssuanceID: mptID,
|
||||
Sequence: 0,
|
||||
TicketSequence: lbTickets[1]
|
||||
}, { wallet: loanBroker, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'CredentialAccept',
|
||||
Account: borrower.address,
|
||||
Issuer: credentialIssuer.address,
|
||||
CredentialType: credentialType,
|
||||
Sequence: 0,
|
||||
TicketSequence: brTickets[0]
|
||||
}, { wallet: borrower, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'MPTokenAuthorize',
|
||||
Account: borrower.address,
|
||||
MPTokenIssuanceID: mptID,
|
||||
Sequence: 0,
|
||||
TicketSequence: brTickets[1]
|
||||
}, { wallet: borrower, 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: 4/7\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: 'Payment',
|
||||
Account: depositor.address,
|
||||
Destination: loanBroker.address,
|
||||
Amount: {
|
||||
mpt_issuance_id: mptID,
|
||||
value: '5000'
|
||||
},
|
||||
Sequence: 0,
|
||||
TicketSequence: dpTickets[0]
|
||||
}, { wallet: depositor, autofill: true }),
|
||||
client.submitAndWait({
|
||||
TransactionType: 'Payment',
|
||||
Account: depositor.address,
|
||||
Destination: borrower.address,
|
||||
Amount: {
|
||||
mpt_issuance_id: mptID,
|
||||
value: '2500'
|
||||
},
|
||||
Sequence: 0,
|
||||
TicketSequence: dpTickets[1]
|
||||
}, { wallet: depositor, autofill: true })
|
||||
])
|
||||
|
||||
const vaultID = vaultCreateResponse.result.meta.AffectedNodes.find(node =>
|
||||
node.CreatedNode?.LedgerEntryType === 'Vault'
|
||||
).CreatedNode.LedgerIndex
|
||||
|
||||
process.stdout.write('Setting up tutorial: 5/7\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: 6/7\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, sign, and submit a LoanSet transaction
|
||||
async function createLoan (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 loanBrokerSigned = loanBroker.sign(loanSetTx)
|
||||
const loanBrokerSignedTx = xrpl.decode(loanBrokerSigned.tx_blob)
|
||||
|
||||
const fullySigned = xrpl.signLoanSetByCounterparty(borrower, loanBrokerSignedTx)
|
||||
const submitResponse = await client.submitAndWait(fullySigned.tx)
|
||||
|
||||
return submitResponse
|
||||
}
|
||||
|
||||
const [submitResponse1, submitResponse2] = await Promise.all([
|
||||
createLoan(lbTickets[2]),
|
||||
createLoan(lbTickets[3])
|
||||
])
|
||||
|
||||
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: 7/7\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.6.0"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
403
_code-samples/lending-protocol/py/README.md
Normal file
403
_code-samples/lending-protocol/py/README.md
Normal file
@@ -0,0 +1,403 @@
|
||||
# Lending Protocol Examples (Python)
|
||||
|
||||
This directory contains Python 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
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Create a Loan Broker
|
||||
|
||||
```sh
|
||||
python3 create_loan_broker.py
|
||||
```
|
||||
|
||||
The script should output the LoanBrokerSet transaction, loan broker ID, and loan broker pseudo-account:
|
||||
|
||||
```sh
|
||||
Loan broker/vault owner address: rBeEX3qQzP3UL5WMwZAzdPPpzckH73YvBn
|
||||
Vault ID: 2B71E8E1323BFC8F2AC27F8C217870B63921EFA0C02DF7BA8B099C7DC6A1D00F
|
||||
|
||||
=== Preparing LoanBrokerSet transaction ===
|
||||
|
||||
{
|
||||
"Account": "rBeEX3qQzP3UL5WMwZAzdPPpzckH73YvBn",
|
||||
"TransactionType": "LoanBrokerSet",
|
||||
"SigningPubKey": "",
|
||||
"VaultID": "2B71E8E1323BFC8F2AC27F8C217870B63921EFA0C02DF7BA8B099C7DC6A1D00F",
|
||||
"ManagementFeeRate": 1000
|
||||
}
|
||||
|
||||
=== Submitting LoanBrokerSet transaction ===
|
||||
|
||||
Loan broker created successfully!
|
||||
|
||||
=== Loan Broker Information ===
|
||||
|
||||
LoanBroker ID: 86911896026EA9DEAEFC1A7959BC05D8B1A1EC25B9960E8C54424B7DC41F8DA8
|
||||
LoanBroker Psuedo-Account Address: rPhpC2XGz7v5g2rPom7JSWJcic1cnkoBh9
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Claw Back First-loss Capital
|
||||
|
||||
```sh
|
||||
python3 cover_clawback.py
|
||||
```
|
||||
|
||||
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: rBeEX3qQzP3UL5WMwZAzdPPpzckH73YvBn
|
||||
MPT issuer address: rNzJg2EVwo56eAoBxz5WnTfmgoLbfaAT8d
|
||||
LoanBrokerID: 041E256F124841FF81DF105C62A72676BFD746975F86786166B689F304BE96E0
|
||||
MPT ID: 0037A8ED99701AFEC4BCC3A39299252CA41838059572E7F2
|
||||
|
||||
=== Cover Available ===
|
||||
|
||||
1000 TSTUSD
|
||||
|
||||
=== Preparing LoanBrokerCoverDeposit transaction ===
|
||||
|
||||
{
|
||||
"Account": "rBeEX3qQzP3UL5WMwZAzdPPpzckH73YvBn",
|
||||
"TransactionType": "LoanBrokerCoverDeposit",
|
||||
"SigningPubKey": "",
|
||||
"LoanBrokerID": "041E256F124841FF81DF105C62A72676BFD746975F86786166B689F304BE96E0",
|
||||
"Amount": {
|
||||
"mpt_issuance_id": "0037A8ED99701AFEC4BCC3A39299252CA41838059572E7F2",
|
||||
"value": "1000"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting LoanBrokerCoverDeposit transaction ===
|
||||
|
||||
Cover deposit successful!
|
||||
|
||||
=== Cover Available After Deposit ===
|
||||
|
||||
2000 TSTUSD
|
||||
|
||||
=== Verifying Asset Issuer ===
|
||||
|
||||
MPT issuer account verified: rNzJg2EVwo56eAoBxz5WnTfmgoLbfaAT8d. Proceeding to clawback.
|
||||
|
||||
=== Preparing LoanBrokerCoverClawback transaction ===
|
||||
|
||||
{
|
||||
"Account": "rNzJg2EVwo56eAoBxz5WnTfmgoLbfaAT8d",
|
||||
"TransactionType": "LoanBrokerCoverClawback",
|
||||
"SigningPubKey": "",
|
||||
"LoanBrokerID": "041E256F124841FF81DF105C62A72676BFD746975F86786166B689F304BE96E0",
|
||||
"Amount": {
|
||||
"mpt_issuance_id": "0037A8ED99701AFEC4BCC3A39299252CA41838059572E7F2",
|
||||
"value": "2000"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting LoanBrokerCoverClawback transaction ===
|
||||
|
||||
Successfully clawed back 2000 TSTUSD!
|
||||
|
||||
=== Final Cover Available After Clawback ===
|
||||
|
||||
0 TSTUSD
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Deposit and Withdraw First-loss Capital
|
||||
|
||||
```sh
|
||||
python3 cover_deposit_and_withdraw.py
|
||||
```
|
||||
|
||||
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: rBeEX3qQzP3UL5WMwZAzdPPpzckH73YvBn
|
||||
LoanBrokerID: 041E256F124841FF81DF105C62A72676BFD746975F86786166B689F304BE96E0
|
||||
MPT ID: 0037A8ED99701AFEC4BCC3A39299252CA41838059572E7F2
|
||||
|
||||
=== Preparing LoanBrokerCoverDeposit transaction ===
|
||||
|
||||
{
|
||||
"Account": "rBeEX3qQzP3UL5WMwZAzdPPpzckH73YvBn",
|
||||
"TransactionType": "LoanBrokerCoverDeposit",
|
||||
"SigningPubKey": "",
|
||||
"LoanBrokerID": "041E256F124841FF81DF105C62A72676BFD746975F86786166B689F304BE96E0",
|
||||
"Amount": {
|
||||
"mpt_issuance_id": "0037A8ED99701AFEC4BCC3A39299252CA41838059572E7F2",
|
||||
"value": "2000"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting LoanBrokerCoverDeposit transaction ===
|
||||
|
||||
Cover deposit successful!
|
||||
|
||||
=== Cover Balance ===
|
||||
|
||||
LoanBroker Pseudo-Account: rUrs1bkhQyh1nxE7u99H92U2Tg8Pogw1bZ
|
||||
Cover balance after deposit: 2000 TSTUSD
|
||||
|
||||
=== Preparing LoanBrokerCoverWithdraw transaction ===
|
||||
|
||||
{
|
||||
"Account": "rBeEX3qQzP3UL5WMwZAzdPPpzckH73YvBn",
|
||||
"TransactionType": "LoanBrokerCoverWithdraw",
|
||||
"SigningPubKey": "",
|
||||
"LoanBrokerID": "041E256F124841FF81DF105C62A72676BFD746975F86786166B689F304BE96E0",
|
||||
"Amount": {
|
||||
"mpt_issuance_id": "0037A8ED99701AFEC4BCC3A39299252CA41838059572E7F2",
|
||||
"value": "1000"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting LoanBrokerCoverWithdraw transaction ===
|
||||
|
||||
Cover withdraw successful!
|
||||
|
||||
=== Updated Cover Balance ===
|
||||
|
||||
LoanBroker Pseudo-Account: rUrs1bkhQyh1nxE7u99H92U2Tg8Pogw1bZ
|
||||
Cover balance after withdraw: 1000 TSTUSD
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Create a Loan
|
||||
|
||||
```sh
|
||||
python3 create_loan.py
|
||||
```
|
||||
|
||||
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: ra3aoaincCNBQ7uxvHDgFbtCbVw1VNQkZy
|
||||
Borrower address: raXnMyDFQWVhvVuyb2oK3oCLGZhemkLqKL
|
||||
LoanBrokerID: 61A1D6B0F019C5D5BD039AC3DBE2E31813471567854D07D278564E4E2463ABD2
|
||||
|
||||
=== Preparing LoanSet transaction ===
|
||||
|
||||
{
|
||||
"Account": "ra3aoaincCNBQ7uxvHDgFbtCbVw1VNQkZy",
|
||||
"TransactionType": "LoanSet",
|
||||
"Fee": "2",
|
||||
"Sequence": 3652181,
|
||||
"LastLedgerSequence": 3674792,
|
||||
"SigningPubKey": "",
|
||||
"LoanBrokerID": "61A1D6B0F019C5D5BD039AC3DBE2E31813471567854D07D278564E4E2463ABD2",
|
||||
"Counterparty": "raXnMyDFQWVhvVuyb2oK3oCLGZhemkLqKL",
|
||||
"LoanOriginationFee": "100",
|
||||
"LoanServiceFee": "10",
|
||||
"InterestRate": 500,
|
||||
"PrincipalRequested": "1000",
|
||||
"PaymentTotal": 12,
|
||||
"PaymentInterval": 2592000,
|
||||
"GracePeriod": 604800
|
||||
}
|
||||
|
||||
=== Adding loan broker signature ===
|
||||
|
||||
TxnSignature: 9756E70F33B359FAEA789D732E752401DE41CAB1A3711517B576DBFF4D89B6A01C234A379391C48B3D88CB031BD679A7EDE4F4BB67AA7297EEE25EA29FF6BD0D
|
||||
SigningPubKey: ED0DC8C222C4BB86CE07165CD0486C598B8146C3150EE40AF48921983DED98FA47
|
||||
|
||||
Signed loan_set_tx for borrower to sign over:
|
||||
{
|
||||
"Account": "ra3aoaincCNBQ7uxvHDgFbtCbVw1VNQkZy",
|
||||
"TransactionType": "LoanSet",
|
||||
"Fee": "2",
|
||||
"Sequence": 3652181,
|
||||
"LastLedgerSequence": 3674792,
|
||||
"SigningPubKey": "ED0DC8C222C4BB86CE07165CD0486C598B8146C3150EE40AF48921983DED98FA47",
|
||||
"TxnSignature": "9756E70F33B359FAEA789D732E752401DE41CAB1A3711517B576DBFF4D89B6A01C234A379391C48B3D88CB031BD679A7EDE4F4BB67AA7297EEE25EA29FF6BD0D",
|
||||
"LoanBrokerID": "61A1D6B0F019C5D5BD039AC3DBE2E31813471567854D07D278564E4E2463ABD2",
|
||||
"Counterparty": "raXnMyDFQWVhvVuyb2oK3oCLGZhemkLqKL",
|
||||
"LoanOriginationFee": "100",
|
||||
"LoanServiceFee": "10",
|
||||
"InterestRate": 500,
|
||||
"PrincipalRequested": "1000",
|
||||
"PaymentTotal": 12,
|
||||
"PaymentInterval": 2592000,
|
||||
"GracePeriod": 604800
|
||||
}
|
||||
|
||||
=== Adding borrower signature ===
|
||||
|
||||
Borrower TxnSignature: A0A515BFB131EDC7A8B74F7A66F9DA1DEE25B099373F581BDA340C95F918CEA91E3F4D2019A8DBAFEC53012038839FEA48436D61970B0834F6DDEA64B1776207
|
||||
Borrower SigningPubKey: ED36B94636EC0F98BB5F6EC58039E23A8C8F1521D2EC1B32C0422A86718C9B95DC
|
||||
|
||||
Fully signed LoanSet transaction:
|
||||
{
|
||||
"Account": "ra3aoaincCNBQ7uxvHDgFbtCbVw1VNQkZy",
|
||||
"TransactionType": "LoanSet",
|
||||
"Fee": "2",
|
||||
"Sequence": 3652181,
|
||||
"LastLedgerSequence": 3674792,
|
||||
"SigningPubKey": "ED0DC8C222C4BB86CE07165CD0486C598B8146C3150EE40AF48921983DED98FA47",
|
||||
"TxnSignature": "9756E70F33B359FAEA789D732E752401DE41CAB1A3711517B576DBFF4D89B6A01C234A379391C48B3D88CB031BD679A7EDE4F4BB67AA7297EEE25EA29FF6BD0D",
|
||||
"LoanBrokerID": "61A1D6B0F019C5D5BD039AC3DBE2E31813471567854D07D278564E4E2463ABD2",
|
||||
"Counterparty": "raXnMyDFQWVhvVuyb2oK3oCLGZhemkLqKL",
|
||||
"CounterpartySignature": {
|
||||
"SigningPubKey": "ED36B94636EC0F98BB5F6EC58039E23A8C8F1521D2EC1B32C0422A86718C9B95DC",
|
||||
"TxnSignature": "A0A515BFB131EDC7A8B74F7A66F9DA1DEE25B099373F581BDA340C95F918CEA91E3F4D2019A8DBAFEC53012038839FEA48436D61970B0834F6DDEA64B1776207"
|
||||
},
|
||||
"LoanOriginationFee": "100",
|
||||
"LoanServiceFee": "10",
|
||||
"InterestRate": 500,
|
||||
"PrincipalRequested": "1000",
|
||||
"PaymentTotal": 12,
|
||||
"PaymentInterval": 2592000,
|
||||
"GracePeriod": 604800
|
||||
}
|
||||
|
||||
=== Submitting signed LoanSet transaction ===
|
||||
|
||||
Loan created successfully!
|
||||
|
||||
=== Loan Information ===
|
||||
|
||||
{
|
||||
"Borrower": "raXnMyDFQWVhvVuyb2oK3oCLGZhemkLqKL",
|
||||
"GracePeriod": 604800,
|
||||
"InterestRate": 500,
|
||||
"LoanBrokerID": "61A1D6B0F019C5D5BD039AC3DBE2E31813471567854D07D278564E4E2463ABD2",
|
||||
"LoanOriginationFee": "100",
|
||||
"LoanSequence": 4,
|
||||
"LoanServiceFee": "10",
|
||||
"NextPaymentDueDate": 826867870,
|
||||
"PaymentInterval": 2592000,
|
||||
"PaymentRemaining": 12,
|
||||
"PeriodicPayment": "83.55610375293148956",
|
||||
"PrincipalOutstanding": "1000",
|
||||
"StartDate": 824275870,
|
||||
"TotalValueOutstanding": "1003"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Manage a Loan
|
||||
|
||||
```sh
|
||||
python3 loan_manage.py
|
||||
```
|
||||
|
||||
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: r9x3etrs2GZSF73vQ8endi9CWpKr5N2Rjn
|
||||
LoanID: E86DB385401D361A33DD74C8E1B44D7F996E9BA02724BCD44127F60BE057A322
|
||||
|
||||
=== Loan Status ===
|
||||
|
||||
Total Amount Owed: 1001 TSTUSD.
|
||||
Payment Due Date: 2026-03-14 02:01:51
|
||||
|
||||
=== Preparing LoanManage transaction to impair loan ===
|
||||
|
||||
{
|
||||
"Account": "r9x3etrs2GZSF73vQ8endi9CWpKr5N2Rjn",
|
||||
"TransactionType": "LoanManage",
|
||||
"Flags": 131072,
|
||||
"SigningPubKey": "",
|
||||
"LoanID": "E86DB385401D361A33DD74C8E1B44D7F996E9BA02724BCD44127F60BE057A322"
|
||||
}
|
||||
|
||||
=== Submitting LoanManage impairment transaction ===
|
||||
|
||||
Loan impaired successfully!
|
||||
New Payment Due Date: 2026-02-12 01:01:50
|
||||
Grace Period: 60 seconds
|
||||
|
||||
=== Countdown until loan can be defaulted ===
|
||||
|
||||
Grace period expired. Loan can now be defaulted.
|
||||
|
||||
=== Preparing LoanManage transaction to default loan ===
|
||||
|
||||
{
|
||||
"Account": "r9x3etrs2GZSF73vQ8endi9CWpKr5N2Rjn",
|
||||
"TransactionType": "LoanManage",
|
||||
"Flags": 65536,
|
||||
"SigningPubKey": "",
|
||||
"LoanID": "E86DB385401D361A33DD74C8E1B44D7F996E9BA02724BCD44127F60BE057A322"
|
||||
}
|
||||
|
||||
=== Submitting LoanManage default transaction ===
|
||||
|
||||
Loan defaulted successfully!
|
||||
|
||||
=== Checking final loan status ===
|
||||
|
||||
Final loan flags: ['TF_LOAN_DEFAULT', 'TF_LOAN_IMPAIR']
|
||||
```
|
||||
|
||||
## Pay a Loan
|
||||
|
||||
```sh
|
||||
python3 loan_pay.py
|
||||
```
|
||||
|
||||
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: raXnMyDFQWVhvVuyb2oK3oCLGZhemkLqKL
|
||||
LoanID: A9CC92540995E49B39E79883A22FF10A374BF2CB32763E89AA986B613E16D5FD
|
||||
MPT ID: 0037BA4C909352D28BF9580F1D536AF4F7E07649B5B6E116
|
||||
|
||||
=== Loan Status ===
|
||||
|
||||
Amount Owed: 1001 TSTUSD
|
||||
Loan Service Fee: 10 TSTUSD
|
||||
Total Payment Due (including fees): 1011 TSTUSD
|
||||
|
||||
=== Preparing LoanPay transaction ===
|
||||
|
||||
{
|
||||
"Account": "raXnMyDFQWVhvVuyb2oK3oCLGZhemkLqKL",
|
||||
"TransactionType": "LoanPay",
|
||||
"SigningPubKey": "",
|
||||
"LoanID": "A9CC92540995E49B39E79883A22FF10A374BF2CB32763E89AA986B613E16D5FD",
|
||||
"Amount": {
|
||||
"mpt_issuance_id": "0037BA4C909352D28BF9580F1D536AF4F7E07649B5B6E116",
|
||||
"value": "1011"
|
||||
}
|
||||
}
|
||||
|
||||
=== Submitting LoanPay transaction ===
|
||||
|
||||
Loan paid successfully!
|
||||
|
||||
=== Loan Status After Payment ===
|
||||
|
||||
Outstanding Loan Balance: Loan fully paid off!
|
||||
|
||||
=== Preparing LoanDelete transaction ===
|
||||
|
||||
{
|
||||
"Account": "raXnMyDFQWVhvVuyb2oK3oCLGZhemkLqKL",
|
||||
"TransactionType": "LoanDelete",
|
||||
"SigningPubKey": "",
|
||||
"LoanID": "A9CC92540995E49B39E79883A22FF10A374BF2CB32763E89AA986B613E16D5FD"
|
||||
}
|
||||
|
||||
=== Submitting LoanDelete transaction ===
|
||||
|
||||
Loan deleted successfully!
|
||||
|
||||
=== Verifying Loan Deletion ===
|
||||
|
||||
Loan has been successfully removed from the XRP Ledger!
|
||||
```
|
||||
124
_code-samples/lending-protocol/py/cover_clawback.py
Normal file
124
_code-samples/lending-protocol/py/cover_clawback.py
Normal file
@@ -0,0 +1,124 @@
|
||||
# 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 json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models import LedgerEntry, LoanBrokerCoverClawback, LoanBrokerCoverDeposit, MPTAmount
|
||||
from xrpl.transaction import submit_and_wait
|
||||
from xrpl.wallet import Wallet
|
||||
|
||||
# Set up client ----------------------
|
||||
client = JsonRpcClient("https://s.devnet.rippletest.net:51234")
|
||||
|
||||
# This step checks for the necessary setup data to run the lending protocol tutorials.
|
||||
# If missing, lending_setup.py will generate the data.
|
||||
if not os.path.exists("lending_setup.json"):
|
||||
print("\n=== Lending tutorial data doesn't exist. Running setup script... ===\n")
|
||||
subprocess.run([sys.executable, "lending_setup.py"], check=True)
|
||||
|
||||
# Load preconfigured accounts, loan_broker_id, and mpt_id.
|
||||
with open("lending_setup.json") as f:
|
||||
setup_data = json.load(f)
|
||||
|
||||
# You can replace these values with your own.
|
||||
loan_broker = Wallet.from_seed(setup_data["loan_broker"]["seed"])
|
||||
mpt_issuer = Wallet.from_seed(setup_data["depositor"]["seed"])
|
||||
loan_broker_id = setup_data["loan_broker_id"]
|
||||
mpt_id = setup_data["mpt_id"]
|
||||
|
||||
print(f"\nLoan broker address: {loan_broker.address}")
|
||||
print(f"MPT issuer address: {mpt_issuer.address}")
|
||||
print(f"LoanBrokerID: {loan_broker_id}")
|
||||
print(f"MPT ID: {mpt_id}")
|
||||
|
||||
# Check cover available ----------------------
|
||||
print("\n=== Cover Available ===\n")
|
||||
cover_info = client.request(LedgerEntry(
|
||||
index=loan_broker_id,
|
||||
ledger_index="validated",
|
||||
))
|
||||
|
||||
current_cover_available = cover_info.result["node"].get("CoverAvailable", "0")
|
||||
print(f"{current_cover_available} TSTUSD")
|
||||
|
||||
# Prepare LoanBrokerCoverDeposit transaction ----------------------
|
||||
print("\n=== Preparing LoanBrokerCoverDeposit transaction ===\n")
|
||||
cover_deposit_tx = LoanBrokerCoverDeposit(
|
||||
account=loan_broker.address,
|
||||
loan_broker_id=loan_broker_id,
|
||||
amount=MPTAmount(mpt_issuance_id=mpt_id, value="1000"),
|
||||
)
|
||||
|
||||
print(json.dumps(cover_deposit_tx.to_xrpl(), indent=2))
|
||||
|
||||
# Sign, submit, and wait for deposit validation ----------------------
|
||||
print("\n=== Submitting LoanBrokerCoverDeposit transaction ===\n")
|
||||
deposit_response = submit_and_wait(cover_deposit_tx, client, loan_broker)
|
||||
|
||||
if deposit_response.result["meta"]["TransactionResult"] != "tesSUCCESS":
|
||||
result_code = deposit_response.result["meta"]["TransactionResult"]
|
||||
print(f"Error: Unable to deposit cover: {result_code}")
|
||||
sys.exit(1)
|
||||
|
||||
print("Cover deposit successful!")
|
||||
|
||||
# Extract updated cover available after deposit ----------------------
|
||||
print("\n=== Cover Available After Deposit ===\n")
|
||||
loan_broker_node = next(
|
||||
node for node in deposit_response.result["meta"]["AffectedNodes"]
|
||||
if node.get("ModifiedNode", {}).get("LedgerEntryType") == "LoanBroker"
|
||||
)
|
||||
|
||||
current_cover_available = loan_broker_node["ModifiedNode"]["FinalFields"]["CoverAvailable"]
|
||||
print(f"{current_cover_available} TSTUSD")
|
||||
|
||||
# Verify issuer of cover asset matches ----------------------
|
||||
# Only the issuer of the asset can submit clawback transactions.
|
||||
# The asset must also have clawback enabled.
|
||||
print("\n=== Verifying Asset Issuer ===\n")
|
||||
asset_issuer_info = client.request(LedgerEntry(
|
||||
mpt_issuance=mpt_id,
|
||||
ledger_index="validated",
|
||||
))
|
||||
|
||||
if asset_issuer_info.result["node"]["Issuer"] != mpt_issuer.address:
|
||||
issuer = asset_issuer_info.result["node"]["Issuer"]
|
||||
print(f"Error: {issuer} does not match account ({mpt_issuer.address}) attempting clawback!")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"MPT issuer account verified: {mpt_issuer.address}. Proceeding to clawback.")
|
||||
|
||||
# Prepare LoanBrokerCoverClawback transaction ----------------------
|
||||
print("\n=== Preparing LoanBrokerCoverClawback transaction ===\n")
|
||||
cover_clawback_tx = LoanBrokerCoverClawback(
|
||||
account=mpt_issuer.address,
|
||||
loan_broker_id=loan_broker_id,
|
||||
amount=MPTAmount(mpt_issuance_id=mpt_id, value=current_cover_available),
|
||||
)
|
||||
|
||||
print(json.dumps(cover_clawback_tx.to_xrpl(), indent=2))
|
||||
|
||||
# Sign, submit, and wait for clawback validation ----------------------
|
||||
print("\n=== Submitting LoanBrokerCoverClawback transaction ===\n")
|
||||
clawback_response = submit_and_wait(cover_clawback_tx, client, mpt_issuer)
|
||||
|
||||
if clawback_response.result["meta"]["TransactionResult"] != "tesSUCCESS":
|
||||
result_code = clawback_response.result["meta"]["TransactionResult"]
|
||||
print(f"Error: Unable to clawback cover: {result_code}")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"Successfully clawed back {current_cover_available} TSTUSD!")
|
||||
|
||||
# Extract final cover available ----------------------
|
||||
print("\n=== Final Cover Available After Clawback ===\n")
|
||||
loan_broker_node = next(
|
||||
node for node in clawback_response.result["meta"]["AffectedNodes"]
|
||||
if node.get("ModifiedNode", {}).get("LedgerEntryType") == "LoanBroker"
|
||||
)
|
||||
|
||||
print(f"{loan_broker_node['ModifiedNode']['FinalFields'].get('CoverAvailable', '0')} TSTUSD")
|
||||
@@ -0,0 +1,95 @@
|
||||
# IMPORTANT: This example deposits and withdraws first-loss capital from a
|
||||
# preconfigured LoanBroker entry.
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models import LoanBrokerCoverDeposit, LoanBrokerCoverWithdraw, MPTAmount
|
||||
from xrpl.transaction import submit_and_wait
|
||||
from xrpl.wallet import Wallet
|
||||
|
||||
# Set up client ----------------------
|
||||
client = JsonRpcClient("https://s.devnet.rippletest.net:51234")
|
||||
|
||||
# This step checks for the necessary setup data to run the lending protocol tutorials.
|
||||
# If missing, lending_setup.py will generate the data.
|
||||
if not os.path.exists("lending_setup.json"):
|
||||
print("\n=== Lending tutorial data doesn't exist. Running setup script... ===\n")
|
||||
subprocess.run([sys.executable, "lending_setup.py"], check=True)
|
||||
|
||||
# Load preconfigured accounts and loan_broker_id.
|
||||
with open("lending_setup.json") as f:
|
||||
setup_data = json.load(f)
|
||||
|
||||
# You can replace these values with your own.
|
||||
loan_broker = Wallet.from_seed(setup_data["loan_broker"]["seed"])
|
||||
loan_broker_id = setup_data["loan_broker_id"]
|
||||
mpt_id = setup_data["mpt_id"]
|
||||
|
||||
print(f"\nLoan broker address: {loan_broker.address}")
|
||||
print(f"LoanBrokerID: {loan_broker_id}")
|
||||
print(f"MPT ID: {mpt_id}")
|
||||
|
||||
# Prepare LoanBrokerCoverDeposit transaction ----------------------
|
||||
print("\n=== Preparing LoanBrokerCoverDeposit transaction ===\n")
|
||||
cover_deposit_tx = LoanBrokerCoverDeposit(
|
||||
account=loan_broker.address,
|
||||
loan_broker_id=loan_broker_id,
|
||||
amount=MPTAmount(mpt_issuance_id=mpt_id, value="2000"),
|
||||
)
|
||||
|
||||
print(json.dumps(cover_deposit_tx.to_xrpl(), indent=2))
|
||||
|
||||
# Sign, submit, and wait for deposit validation ----------------------
|
||||
print("\n=== Submitting LoanBrokerCoverDeposit transaction ===\n")
|
||||
deposit_response = submit_and_wait(cover_deposit_tx, client, loan_broker)
|
||||
|
||||
if deposit_response.result["meta"]["TransactionResult"] != "tesSUCCESS":
|
||||
result_code = deposit_response.result["meta"]["TransactionResult"]
|
||||
print(f"Error: Unable to deposit cover: {result_code}")
|
||||
sys.exit(1)
|
||||
|
||||
print("Cover deposit successful!")
|
||||
|
||||
# Extract cover balance from the transaction result
|
||||
print("\n=== Cover Balance ===\n")
|
||||
loan_broker_node = next(
|
||||
node for node in deposit_response.result["meta"]["AffectedNodes"]
|
||||
if node.get("ModifiedNode", {}).get("LedgerEntryType") == "LoanBroker"
|
||||
)
|
||||
# First-loss capital is stored in the LoanBroker's pseudo-account.
|
||||
print(f"LoanBroker Pseudo-Account: {loan_broker_node['ModifiedNode']['FinalFields']['Account']}")
|
||||
print(f"Cover balance after deposit: {loan_broker_node['ModifiedNode']['FinalFields']['CoverAvailable']} TSTUSD")
|
||||
|
||||
# Prepare LoanBrokerCoverWithdraw transaction ----------------------
|
||||
print("\n=== Preparing LoanBrokerCoverWithdraw transaction ===\n")
|
||||
cover_withdraw_tx = LoanBrokerCoverWithdraw(
|
||||
account=loan_broker.address,
|
||||
loan_broker_id=loan_broker_id,
|
||||
amount=MPTAmount(mpt_issuance_id=mpt_id, value="1000"),
|
||||
)
|
||||
|
||||
print(json.dumps(cover_withdraw_tx.to_xrpl(), indent=2))
|
||||
|
||||
# Sign, submit, and wait for withdraw validation ----------------------
|
||||
print("\n=== Submitting LoanBrokerCoverWithdraw transaction ===\n")
|
||||
withdraw_response = submit_and_wait(cover_withdraw_tx, client, loan_broker)
|
||||
|
||||
if withdraw_response.result["meta"]["TransactionResult"] != "tesSUCCESS":
|
||||
result_code = withdraw_response.result["meta"]["TransactionResult"]
|
||||
print(f"Error: Unable to withdraw cover: {result_code}")
|
||||
sys.exit(1)
|
||||
|
||||
print("Cover withdraw successful!")
|
||||
|
||||
# Extract updated cover balance from the transaction result
|
||||
print("\n=== Updated Cover Balance ===\n")
|
||||
loan_broker_node = next(
|
||||
node for node in withdraw_response.result["meta"]["AffectedNodes"]
|
||||
if node.get("ModifiedNode", {}).get("LedgerEntryType") == "LoanBroker"
|
||||
)
|
||||
print(f"LoanBroker Pseudo-Account: {loan_broker_node['ModifiedNode']['FinalFields']['Account']}")
|
||||
print(f"Cover balance after withdraw: {loan_broker_node['ModifiedNode']['FinalFields']['CoverAvailable']} TSTUSD")
|
||||
89
_code-samples/lending-protocol/py/create_loan.py
Normal file
89
_code-samples/lending-protocol/py/create_loan.py
Normal file
@@ -0,0 +1,89 @@
|
||||
# IMPORTANT: This example creates a loan using a preconfigured
|
||||
# loan broker, borrower, and private vault.
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models import LoanSet
|
||||
from xrpl.transaction import autofill, sign, sign_loan_set_by_counterparty, submit_and_wait
|
||||
from xrpl.wallet import Wallet
|
||||
|
||||
# Set up client ----------------------
|
||||
client = JsonRpcClient("https://s.devnet.rippletest.net:51234")
|
||||
|
||||
# This step checks for the necessary setup data to run the lending protocol tutorials.
|
||||
# If missing, lending_setup.py will generate the data.
|
||||
if not os.path.exists("lending_setup.json"):
|
||||
print("\n=== Lending tutorial data doesn't exist. Running setup script... ===\n")
|
||||
subprocess.run([sys.executable, "lending_setup.py"], check=True)
|
||||
|
||||
# Load preconfigured accounts and loan_broker_id.
|
||||
with open("lending_setup.json") as f:
|
||||
setup_data = json.load(f)
|
||||
|
||||
# You can replace these values with your own.
|
||||
loan_broker = Wallet.from_seed(setup_data["loan_broker"]["seed"])
|
||||
borrower = Wallet.from_seed(setup_data["borrower"]["seed"])
|
||||
loan_broker_id = setup_data["loan_broker_id"]
|
||||
|
||||
print(f"\nLoan broker address: {loan_broker.address}")
|
||||
print(f"Borrower address: {borrower.address}")
|
||||
print(f"LoanBrokerID: {loan_broker_id}")
|
||||
|
||||
# Prepare LoanSet transaction ----------------------
|
||||
# Account and Counterparty accounts can be swapped, but determines signing order.
|
||||
# Account signs first, Counterparty signs second.
|
||||
print("\n=== Preparing LoanSet transaction ===\n")
|
||||
|
||||
loan_set_tx = autofill(LoanSet(
|
||||
account=loan_broker.address,
|
||||
counterparty=borrower.address,
|
||||
loan_broker_id=loan_broker_id,
|
||||
principal_requested="1000",
|
||||
interest_rate=500,
|
||||
payment_total=12,
|
||||
payment_interval=2592000,
|
||||
grace_period=604800,
|
||||
loan_origination_fee="100",
|
||||
loan_service_fee="10",
|
||||
), client)
|
||||
|
||||
print(json.dumps(loan_set_tx.to_xrpl(), indent=2))
|
||||
|
||||
# Loan broker signs first.
|
||||
print("\n=== Adding loan broker signature ===\n")
|
||||
loan_broker_signed = sign(loan_set_tx, loan_broker)
|
||||
|
||||
print(f"TxnSignature: {loan_broker_signed.txn_signature}")
|
||||
print(f"SigningPubKey: {loan_broker_signed.signing_pub_key}\n")
|
||||
print(f"Signed loan_set_tx for borrower to sign over:\n{json.dumps(loan_broker_signed.to_xrpl(), indent=2)}")
|
||||
|
||||
# Borrower signs second.
|
||||
print("\n=== Adding borrower signature ===\n")
|
||||
fully_signed = sign_loan_set_by_counterparty(borrower, loan_broker_signed)
|
||||
|
||||
print(f"Borrower TxnSignature: {fully_signed.tx.counterparty_signature.txn_signature}")
|
||||
print(f"Borrower SigningPubKey: {fully_signed.tx.counterparty_signature.signing_pub_key}")
|
||||
print(f"\nFully signed LoanSet transaction:\n{json.dumps(fully_signed.tx.to_xrpl(), indent=2)}")
|
||||
|
||||
# Submit and wait for validation ----------------------
|
||||
print("\n=== Submitting signed LoanSet transaction ===\n")
|
||||
submit_response = submit_and_wait(fully_signed.tx, client)
|
||||
|
||||
if submit_response.result["meta"]["TransactionResult"] != "tesSUCCESS":
|
||||
result_code = submit_response.result["meta"]["TransactionResult"]
|
||||
print(f"Error: Unable to create loan: {result_code}")
|
||||
sys.exit(1)
|
||||
|
||||
print("Loan created successfully!")
|
||||
|
||||
# Extract loan information from the transaction result.
|
||||
print("\n=== Loan Information ===\n")
|
||||
loan_node = next(
|
||||
node for node in submit_response.result["meta"]["AffectedNodes"]
|
||||
if node.get("CreatedNode", {}).get("LedgerEntryType") == "Loan"
|
||||
)
|
||||
print(json.dumps(loan_node["CreatedNode"]["NewFields"], indent=2))
|
||||
64
_code-samples/lending-protocol/py/create_loan_broker.py
Normal file
64
_code-samples/lending-protocol/py/create_loan_broker.py
Normal file
@@ -0,0 +1,64 @@
|
||||
# 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 vault_id
|
||||
# and loan_broker values with your own.
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models import LoanBrokerSet
|
||||
from xrpl.transaction import submit_and_wait
|
||||
from xrpl.wallet import Wallet
|
||||
|
||||
# Set up client ----------------------
|
||||
client = JsonRpcClient("https://s.devnet.rippletest.net:51234")
|
||||
|
||||
# This step checks for the necessary setup data to run the lending protocol tutorials.
|
||||
# If missing, lending_setup.py will generate the data.
|
||||
if not os.path.exists("lending_setup.json"):
|
||||
print("\n=== Lending tutorial data doesn't exist. Running setup script... ===\n")
|
||||
subprocess.run([sys.executable, "lending_setup.py"], check=True)
|
||||
|
||||
# Load preconfigured accounts and vault_id.
|
||||
with open("lending_setup.json") as f:
|
||||
setup_data = json.load(f)
|
||||
|
||||
# You can replace these values with your own.
|
||||
loan_broker = Wallet.from_seed(setup_data["loan_broker"]["seed"])
|
||||
vault_id = setup_data["vault_id"]
|
||||
|
||||
print(f"\nLoan broker/vault owner address: {loan_broker.address}")
|
||||
print(f"Vault ID: {vault_id}")
|
||||
|
||||
# Prepare LoanBrokerSet transaction ----------------------
|
||||
print("\n=== Preparing LoanBrokerSet transaction ===\n")
|
||||
loan_broker_set_tx = LoanBrokerSet(
|
||||
account=loan_broker.address,
|
||||
vault_id=vault_id,
|
||||
management_fee_rate=1000,
|
||||
)
|
||||
|
||||
print(json.dumps(loan_broker_set_tx.to_xrpl(), indent=2))
|
||||
|
||||
# Submit, sign, and wait for validation ----------------------
|
||||
print("\n=== Submitting LoanBrokerSet transaction ===\n")
|
||||
submit_response = submit_and_wait(loan_broker_set_tx, client, loan_broker)
|
||||
|
||||
if submit_response.result["meta"]["TransactionResult"] != "tesSUCCESS":
|
||||
result_code = submit_response.result["meta"]["TransactionResult"]
|
||||
print(f"Error: Unable to create loan broker: {result_code}")
|
||||
sys.exit(1)
|
||||
|
||||
print("Loan broker created successfully!")
|
||||
|
||||
# Extract loan broker information from the transaction result
|
||||
print("\n=== Loan Broker Information ===\n")
|
||||
loan_broker_node = next(
|
||||
node for node in submit_response.result["meta"]["AffectedNodes"]
|
||||
if node.get("CreatedNode", {}).get("LedgerEntryType") == "LoanBroker"
|
||||
)
|
||||
print(f"LoanBroker ID: {loan_broker_node['CreatedNode']['LedgerIndex']}")
|
||||
print(f"LoanBroker Psuedo-Account Address: {loan_broker_node['CreatedNode']['NewFields']['Account']}")
|
||||
416
_code-samples/lending-protocol/py/lending_setup.py
Normal file
416
_code-samples/lending-protocol/py/lending_setup.py
Normal file
@@ -0,0 +1,416 @@
|
||||
# Setup script for lending protocol tutorials
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
from xrpl.asyncio.clients import AsyncWebsocketClient
|
||||
from xrpl.asyncio.wallet import generate_faucet_wallet
|
||||
from xrpl.asyncio.transaction import submit_and_wait, autofill, sign
|
||||
from xrpl.transaction import sign_loan_set_by_counterparty
|
||||
from xrpl.models import (
|
||||
CredentialAccept,
|
||||
CredentialCreate,
|
||||
LoanBrokerSet,
|
||||
LoanSet,
|
||||
MPTAmount,
|
||||
MPTCurrency,
|
||||
MPTokenAuthorize,
|
||||
MPTokenIssuanceCreate,
|
||||
MPTokenIssuanceCreateFlag,
|
||||
Payment,
|
||||
PermissionedDomainSet,
|
||||
TicketCreate,
|
||||
VaultCreate,
|
||||
VaultDeposit,
|
||||
)
|
||||
from xrpl.models.transactions.vault_create import VaultCreateFlag
|
||||
from xrpl.models.transactions.deposit_preauth import Credential
|
||||
from xrpl.utils import encode_mptoken_metadata, str_to_hex
|
||||
|
||||
|
||||
async def main():
|
||||
async with AsyncWebsocketClient("wss://s.devnet.rippletest.net:51233") as client:
|
||||
|
||||
print("Setting up tutorial: 0/7", end="\r")
|
||||
|
||||
# Create and fund wallets
|
||||
loan_broker, borrower, depositor, credential_issuer = await asyncio.gather(
|
||||
generate_faucet_wallet(client),
|
||||
generate_faucet_wallet(client),
|
||||
generate_faucet_wallet(client),
|
||||
generate_faucet_wallet(client),
|
||||
)
|
||||
|
||||
print("Setting up tutorial: 1/7", end="\r")
|
||||
|
||||
# Create tickets for parallel transactions
|
||||
def extract_tickets(response):
|
||||
return [
|
||||
node["CreatedNode"]["NewFields"]["TicketSequence"]
|
||||
for node in response.result["meta"]["AffectedNodes"]
|
||||
if node.get("CreatedNode", {}).get("LedgerEntryType") == "Ticket"
|
||||
]
|
||||
|
||||
ci_ticket_response, lb_ticket_response, br_ticket_response, dp_ticket_response = (
|
||||
await asyncio.gather(
|
||||
submit_and_wait(
|
||||
TicketCreate(
|
||||
account=credential_issuer.address,
|
||||
ticket_count=4,
|
||||
),
|
||||
client,
|
||||
credential_issuer,
|
||||
),
|
||||
submit_and_wait(
|
||||
TicketCreate(
|
||||
account=loan_broker.address,
|
||||
ticket_count=4,
|
||||
),
|
||||
client,
|
||||
loan_broker,
|
||||
),
|
||||
submit_and_wait(
|
||||
TicketCreate(
|
||||
account=borrower.address,
|
||||
ticket_count=2,
|
||||
),
|
||||
client,
|
||||
borrower,
|
||||
),
|
||||
submit_and_wait(
|
||||
TicketCreate(
|
||||
account=depositor.address,
|
||||
ticket_count=2,
|
||||
),
|
||||
client,
|
||||
depositor,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
ci_tickets = extract_tickets(ci_ticket_response)
|
||||
lb_tickets = extract_tickets(lb_ticket_response)
|
||||
br_tickets = extract_tickets(br_ticket_response)
|
||||
dp_tickets = extract_tickets(dp_ticket_response)
|
||||
|
||||
print("Setting up tutorial: 2/7", end="\r")
|
||||
|
||||
# Issue MPT with depositor
|
||||
# Set up credentials and domain with credential_issuer
|
||||
credential_type = str_to_hex("KYC-Verified")
|
||||
|
||||
mpt_data = {
|
||||
"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",
|
||||
},
|
||||
}
|
||||
|
||||
mpt_issuance_response, domain_set_response, *_ = await asyncio.gather(
|
||||
submit_and_wait(
|
||||
MPTokenIssuanceCreate(
|
||||
account=depositor.address,
|
||||
maximum_amount="100000000",
|
||||
transfer_fee=0,
|
||||
flags=(
|
||||
MPTokenIssuanceCreateFlag.TF_MPT_CAN_TRANSFER
|
||||
| MPTokenIssuanceCreateFlag.TF_MPT_CAN_CLAWBACK
|
||||
| MPTokenIssuanceCreateFlag.TF_MPT_CAN_TRADE
|
||||
),
|
||||
mptoken_metadata=encode_mptoken_metadata(mpt_data),
|
||||
),
|
||||
client,
|
||||
depositor,
|
||||
),
|
||||
submit_and_wait(
|
||||
PermissionedDomainSet(
|
||||
account=credential_issuer.address,
|
||||
accepted_credentials=[
|
||||
Credential(
|
||||
issuer=credential_issuer.address,
|
||||
credential_type=credential_type,
|
||||
),
|
||||
],
|
||||
sequence=0,
|
||||
ticket_sequence=ci_tickets[0],
|
||||
),
|
||||
client,
|
||||
credential_issuer,
|
||||
),
|
||||
submit_and_wait(
|
||||
CredentialCreate(
|
||||
account=credential_issuer.address,
|
||||
subject=loan_broker.address,
|
||||
credential_type=credential_type,
|
||||
sequence=0,
|
||||
ticket_sequence=ci_tickets[1],
|
||||
),
|
||||
client,
|
||||
credential_issuer,
|
||||
),
|
||||
submit_and_wait(
|
||||
CredentialCreate(
|
||||
account=credential_issuer.address,
|
||||
subject=borrower.address,
|
||||
credential_type=credential_type,
|
||||
sequence=0,
|
||||
ticket_sequence=ci_tickets[2],
|
||||
),
|
||||
client,
|
||||
credential_issuer,
|
||||
),
|
||||
submit_and_wait(
|
||||
CredentialCreate(
|
||||
account=credential_issuer.address,
|
||||
subject=depositor.address,
|
||||
credential_type=credential_type,
|
||||
sequence=0,
|
||||
ticket_sequence=ci_tickets[3],
|
||||
),
|
||||
client,
|
||||
credential_issuer,
|
||||
),
|
||||
)
|
||||
|
||||
# Extract MPT issuance ID
|
||||
mpt_id = mpt_issuance_response.result["meta"]["mpt_issuance_id"]
|
||||
|
||||
# Extract domain ID
|
||||
domain_id = next(
|
||||
node["CreatedNode"]["LedgerIndex"]
|
||||
for node in domain_set_response.result["meta"]["AffectedNodes"]
|
||||
if node.get("CreatedNode", {}).get("LedgerEntryType") == "PermissionedDomain"
|
||||
)
|
||||
|
||||
print("Setting up tutorial: 3/7", end="\r")
|
||||
|
||||
# Accept credentials and authorize MPT for each account
|
||||
await asyncio.gather(
|
||||
submit_and_wait(
|
||||
CredentialAccept(
|
||||
account=loan_broker.address,
|
||||
issuer=credential_issuer.address,
|
||||
credential_type=credential_type,
|
||||
sequence=0,
|
||||
ticket_sequence=lb_tickets[0],
|
||||
),
|
||||
client,
|
||||
loan_broker,
|
||||
),
|
||||
submit_and_wait(
|
||||
MPTokenAuthorize(
|
||||
account=loan_broker.address,
|
||||
mptoken_issuance_id=mpt_id,
|
||||
sequence=0,
|
||||
ticket_sequence=lb_tickets[1],
|
||||
),
|
||||
client,
|
||||
loan_broker,
|
||||
),
|
||||
submit_and_wait(
|
||||
CredentialAccept(
|
||||
account=borrower.address,
|
||||
issuer=credential_issuer.address,
|
||||
credential_type=credential_type,
|
||||
sequence=0,
|
||||
ticket_sequence=br_tickets[0],
|
||||
),
|
||||
client,
|
||||
borrower,
|
||||
),
|
||||
submit_and_wait(
|
||||
MPTokenAuthorize(
|
||||
account=borrower.address,
|
||||
mptoken_issuance_id=mpt_id,
|
||||
sequence=0,
|
||||
ticket_sequence=br_tickets[1],
|
||||
),
|
||||
client,
|
||||
borrower,
|
||||
),
|
||||
# Depositor only needs to accept credentials
|
||||
submit_and_wait(
|
||||
CredentialAccept(
|
||||
account=depositor.address,
|
||||
issuer=credential_issuer.address,
|
||||
credential_type=credential_type,
|
||||
),
|
||||
client,
|
||||
depositor,
|
||||
),
|
||||
)
|
||||
|
||||
print("Setting up tutorial: 4/7", end="\r")
|
||||
|
||||
# Create private vault and distribute MPT to accounts
|
||||
vault_create_response, *_ = await asyncio.gather(
|
||||
submit_and_wait(
|
||||
VaultCreate(
|
||||
account=loan_broker.address,
|
||||
asset=MPTCurrency(mpt_issuance_id=mpt_id),
|
||||
flags=VaultCreateFlag.TF_VAULT_PRIVATE,
|
||||
domain_id=domain_id,
|
||||
),
|
||||
client,
|
||||
loan_broker,
|
||||
),
|
||||
submit_and_wait(
|
||||
Payment(
|
||||
account=depositor.address,
|
||||
destination=loan_broker.address,
|
||||
amount=MPTAmount(mpt_issuance_id=mpt_id, value="5000"),
|
||||
sequence=0,
|
||||
ticket_sequence=dp_tickets[0],
|
||||
),
|
||||
client,
|
||||
depositor,
|
||||
),
|
||||
submit_and_wait(
|
||||
Payment(
|
||||
account=depositor.address,
|
||||
destination=borrower.address,
|
||||
amount=MPTAmount(mpt_issuance_id=mpt_id, value="2500"),
|
||||
sequence=0,
|
||||
ticket_sequence=dp_tickets[1],
|
||||
),
|
||||
client,
|
||||
depositor,
|
||||
),
|
||||
)
|
||||
|
||||
vault_id = next(
|
||||
node["CreatedNode"]["LedgerIndex"]
|
||||
for node in vault_create_response.result["meta"]["AffectedNodes"]
|
||||
if node.get("CreatedNode", {}).get("LedgerEntryType") == "Vault"
|
||||
)
|
||||
|
||||
print("Setting up tutorial: 5/7", end="\r")
|
||||
|
||||
# Create LoanBroker and deposit MPT into vault
|
||||
loan_broker_set_response, _ = await asyncio.gather(
|
||||
submit_and_wait(
|
||||
LoanBrokerSet(
|
||||
account=loan_broker.address,
|
||||
vault_id=vault_id,
|
||||
),
|
||||
client,
|
||||
loan_broker,
|
||||
),
|
||||
submit_and_wait(
|
||||
VaultDeposit(
|
||||
account=depositor.address,
|
||||
vault_id=vault_id,
|
||||
amount=MPTAmount(mpt_issuance_id=mpt_id, value="50000000"),
|
||||
),
|
||||
client,
|
||||
depositor,
|
||||
),
|
||||
)
|
||||
|
||||
loan_broker_id = next(
|
||||
node["CreatedNode"]["LedgerIndex"]
|
||||
for node in loan_broker_set_response.result["meta"]["AffectedNodes"]
|
||||
if node.get("CreatedNode", {}).get("LedgerEntryType") == "LoanBroker"
|
||||
)
|
||||
|
||||
print("Setting up tutorial: 6/7", end="\r")
|
||||
|
||||
# Create 2 identical loans with complete repayment due in 30 days
|
||||
|
||||
# Helper function to create, sign, and submit a LoanSet transaction
|
||||
async def create_loan(ticket_sequence):
|
||||
loan_set_tx = await autofill(LoanSet(
|
||||
account=loan_broker.address,
|
||||
counterparty=borrower.address,
|
||||
loan_broker_id=loan_broker_id,
|
||||
principal_requested="1000",
|
||||
interest_rate=500,
|
||||
payment_total=1,
|
||||
payment_interval=2592000,
|
||||
loan_origination_fee="100",
|
||||
loan_service_fee="10",
|
||||
sequence=0,
|
||||
ticket_sequence=ticket_sequence,
|
||||
), client)
|
||||
|
||||
loan_broker_signed = sign(loan_set_tx, loan_broker)
|
||||
fully_signed = sign_loan_set_by_counterparty(borrower, loan_broker_signed)
|
||||
submit_response = await submit_and_wait(fully_signed.tx, client)
|
||||
|
||||
return submit_response
|
||||
|
||||
submit_response_1, submit_response_2 = await asyncio.gather(
|
||||
create_loan(lb_tickets[2]),
|
||||
create_loan(lb_tickets[3]),
|
||||
)
|
||||
|
||||
loan_id_1 = next(
|
||||
node["CreatedNode"]["LedgerIndex"]
|
||||
for node in submit_response_1.result["meta"]["AffectedNodes"]
|
||||
if node.get("CreatedNode", {}).get("LedgerEntryType") == "Loan"
|
||||
)
|
||||
|
||||
loan_id_2 = next(
|
||||
node["CreatedNode"]["LedgerIndex"]
|
||||
for node in submit_response_2.result["meta"]["AffectedNodes"]
|
||||
if node.get("CreatedNode", {}).get("LedgerEntryType") == "Loan"
|
||||
)
|
||||
|
||||
print("Setting up tutorial: 7/7", end="\r")
|
||||
|
||||
# Write setup data to JSON file
|
||||
setup_data = {
|
||||
"description": "This file is auto-generated by lending_setup.py. It stores XRPL account info for use in lending protocol tutorials.",
|
||||
"loan_broker": {
|
||||
"address": loan_broker.address,
|
||||
"seed": loan_broker.seed,
|
||||
},
|
||||
"borrower": {
|
||||
"address": borrower.address,
|
||||
"seed": borrower.seed,
|
||||
},
|
||||
"depositor": {
|
||||
"address": depositor.address,
|
||||
"seed": depositor.seed,
|
||||
},
|
||||
"credential_issuer": {
|
||||
"address": credential_issuer.address,
|
||||
"seed": credential_issuer.seed,
|
||||
},
|
||||
"domain_id": domain_id,
|
||||
"mpt_id": mpt_id,
|
||||
"vault_id": vault_id,
|
||||
"loan_broker_id": loan_broker_id,
|
||||
"loan_id_1": loan_id_1,
|
||||
"loan_id_2": loan_id_2,
|
||||
}
|
||||
|
||||
with open("lending_setup.json", "w") as f:
|
||||
json.dump(setup_data, f, indent=2)
|
||||
|
||||
print("Setting up tutorial: Complete!")
|
||||
|
||||
|
||||
asyncio.run(main())
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user