mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 04:05:49 +00:00
Information Architecture v3 (#1934)
* Update look up escrows to remove redundant info about lookups via sender/destination. Modify cancel expired escrow for brevity. * Cancel escrow: fix notes * Add draft of updated cancel-escrow.js. * Update intro to escrows. * Add Escrow Tutorial * Minor corrections * Fix headings, add HTML * Update escrow docs This commit re-createsf205a92db2with some adjustments: - Omit the accidentally-created dir full of junk - Fix some typos and one mistake in the Escrow limitations section - Add a table to the EscrowCreate ref to clarify valid combos of fields. * Concept info from send-a-time-held-escrow added to escrow.md * IA: Move "Consensus Network" files This re-creates some work from the original commit56fffe0b9f* Rewrite escrows article (re-created) This commit re-creates relevant work from the following commits:9a4a588f2bUpdate escrow.md context infoe1b017dc83Remove references to using escrow for interledger payments. * IA: Move "XRPL servers" files This re-creates some work from original commit7611979abf* IA: move "production readiness" files. Re-creates work from the following commit:692438693aMove tutorials to concepts * New intro articles Original commit:56fffe0b9f* IA: Reorg account concepts Re-creates some work from original commit56fffe0b9f* IA: reorg transaction concepts Original commits:9d4eff9940WIP - reorg accounts7611979abfWIP dir. reorg * IA: reorg consensus concepts Original commit:56fffe0b9f* IA: Reorg ledger docs Original commit:56fffe0b9f- Rephrased some details of the section * IA: rename issuing/operational addresses page Original commit:56fffe0b9f* Moving use cases * Fleshing out Use Cases Note, the dactyl-config.yml file has not been fully updated. * Clean up checks conceptual info. * Remove redundant checks use case section Original commit:3c29e9c05e* IA: move Dex under tokens Original commit:d08b3ba7d7* Touch up stablecoin issuer use case (#1856) * Consolidate stablecoin use case * Stablecoin issuer: cleanup progress through sending * Stablecoin issuer: reorg second half (Note: the dactyl-config.yml is not fully reconciled yet) * Move rippled and clio tutorials into infrastructure * Remove link to checks amendement. * Add note to account_objects.md about commandline interface type field. * Merge expiration case with lifecycle section. * Interoperability Use Cases * Add graphics to intro * Move escrow use cases to dedicated page. * Update use case page intros and corresponding concept info. * Clarify meaning of direct XRP payments. * Intro link updates * Payment use cases * Remove some unnecessary links in transactions section Original commit:e6fcf4a4dc* Link cleanup in Tokens section Original commit:9588dd5e70* Touch up 'Configure Peering' section Original commit:fc8f0990b8* Clean up links in accounts section Original commit:3da5fde7a8* Add NFT mkt use case * p2p payments: edits to Wallets * Clean up payments use cases * Refine history description * IA: use case cleanup * IA: reconcile servers, ledgers sections * IA: reconcile payment types, tx, tokens * IA: reconcile accounts section * IA: reconcile infra * IA: Fix most broken links * Full Docs Index: omit from sidebar * IA: fix up most broken links * fix Absolute path link to internal content * Quick updates to Software Ecosystem * Remove some absolute links to internal resources * Fix remaining broken links in JA target * Contributing: tweak formatting * Tutorials: fix some minor issues * remove interop use cases * remove intro image and personal references to dennis * alphabetize-transaction-nav * Remove unused files * Add QS escrow tutorials * IA: move ledgers, consensus protocol files around * IA: update nav for new page hierarchy * reordering of topics under new networks and servers top-nav * Move "Naming" to "What is XRP?" * Update dactyl-config.yml Remove xrp.md from the TOC. * Update list-xrp-as-an-exchange.md Update link to what-is-xrp * Update list-xrp-as-an-exchange.ja.md Change link to what-is-xrp * Update currency-formats.md Change link to what-is-xrp * Update currency-formats.ja.md Change link to what-is-xrp * Update cancel-an-expired-escrow.md Change link to what-is-xrp * Update paymentchannelfund.md Change link to what-is-xml * Update look-up-escrows.md Change link to what-is-xrp * Update tokens.md change link to what-is-xrp * Update use-payment-channels.md * Update send-a-time-held-escrow.md Update link to what-is-xml * fix broken links * Update parallel-networks.md Change link to what-is-xml * Update parallel-networks.ja.md * Update invariant-checking.md Remove link to xrp.html * Update invariant-checking.ja.md Remove link to xrp.html * Update transaction-cost.md Change link to what-is-xrp * Update transaction-cost.ja.md Change link to what-is-xrp * Update send-a-conditionally-held-escrow.md Change link to what-is-xrp * Update stablecoin-issuer.md Change link to what-is-xrp * Update tokens.ja.md Change link to what-is-xml * Update autobridging.ja.md Change link to what-is-xrp * Update currency-formats.md update text * reorganize infrastructure nav section * Update currency-formats.md Try removing link altogether. * Update currency-formats.ja.md Remove link to what-is-xrp.html * move commandline usage topic to infrastructure * initial intro rewrite * minor update to language * IA.v3: rm Production Readiness * Delete xrp.md * Update xrp link in snippet * Add redirect for old xrp.html URL * Small edits to 'What is XRP?' article * Add missing imgs * XRP - copy edit per @DennisDawson * restructure tutorials nav and pages * fix broken links * more broken link fixes * Algo trading: 1st draft * Algo trading: notes on taxes * Algo trading: edits per review * algo trading: fix broken link * Ledger structure: rewrite for accuracy and clarity * Update links to removed 'tree format' header * Ledger Structure: Update diagrams * Re-gen CSS for ledger structure changes * Ledger structure: edits per review * IA.v3: fix broken NFT links introduced by rebase * Desktop Wallet (py): update little stuff * Update some capacity/storage details * contribute doc nav update * fix image link in create diagram page * IAv3: Fix 'Ledgers' blurb * Update full history requirements with details from community members * add reviewer suggestions * Edits per @trippled review * Apply suggestions from peer review Co-authored-by: oeggert <117319296+oeggert@users.noreply.github.com> * FH: reword file size limit note per review * Update software ecosystem * updates per review * Minor tweaks to graphics * fixTypos * Update content/concepts/introduction/software-ecosystem.md Co-authored-by: Amarantha Kulkarni <amarantha-k@users.noreply.github.com> * Update content/concepts/introduction/software-ecosystem.md Co-authored-by: Amarantha Kulkarni <amarantha-k@users.noreply.github.com> * [JA] update AccountDelete cost * custom transactors doc * add doc to dactyl config * [JA] fix NonFungibleTokensV1_1 amendment status * [JA] update NFTokenOffer page * Remove old, unused XRP article (#2039) * add reviewer suggestions * Add tooling to check for file/nav consistency - From the repo top, run tool/check_file_consistency.py to look for Markdown files that exist in the "content/" directory but aren't used in the documentation. - New "enforce_filenames" filter prints a warning to console when building, if a file's path and filename don't match expectations based on its place in the nav and top heading. * File consistency checker: correctly handle filenames starting in _ * Remove unused old 'get started' and associated code * Create Resources section & reorg some files - Rename some files/folders based on their place in the nav - Move a bunch of non-documentation stuff, and docs on contributing code and/or docs to the new "Resources" section. - Known issue: nav spills into a second row on page widths between 993px-1110px. To be fixed in a later CSS update, maybe along with making the Resources dropdown multi-column. * Fix #2078 code tab bug CSS not built yet, to reduce merge conflicts. Won't have any effect until that happens. * fix Transaction JSON * [JA] translate contributing contents * fix contributing-to-documentation parent * fix contribute-code blurb * Top nav: add cols for Resources, fix broken links * CSS: fix top nav overflows * Fix broken link from redirect not in JA target * Top nav: add Infra to article types * Update contrib info & rename intro file * [ja] Update link to suggested first page to translate * [ja] fix contribute docs organization * Run private network with docker tutorial (#2065) * [NO-ISSUE] Run private network with docker tutorial Adds a tutorial page in the Infrastructure section on how to run a private XRPL network with Docker. Please let me know if you think this is a useful page to include for developers, whether the steps are clear or not, and if you have suggestions on what can be added to it. * Add minor link fixes and Japanese target * Apply suggestions from code review Co-authored-by: Amarantha Kulkarni <amarantha-k@users.noreply.github.com> * Add link to ripple-docker-testnet setup scripts in See Also section * Update repo URL --------- Co-authored-by: Amarantha Kulkarni <amarantha-k@users.noreply.github.com> * add intro gfx (#2036) * add intro gfx * Move graphic up * Update some graphics with their revised versions * Add updated version of the custodial vs non-custodial graphic --------- Co-authored-by: Amarantha Kulkarni <amarantha-k@users.noreply.github.com> Co-authored-by: Amarantha Kulkarni <akulkarni@ripple.com> * Update to reflect current UNL publishers * [ja] update contributing Co-authored-by: tequ <git@tequ.dev> * Incorporate feedback on "What is XRP" page. (#2099) * Add trademark info for XRP * Revert section to previous state * Fix broken link (#2101) --------- Co-authored-by: Oliver Eggert <oeggert@ripple.com> Co-authored-by: ddawson <dennis.s.dawson@gmail.com> Co-authored-by: Maria Shodunke <mshodunke@ripple.com> Co-authored-by: tequ <git@tequ.dev> Co-authored-by: oeggert <117319296+oeggert@users.noreply.github.com> Co-authored-by: Amarantha Kulkarni <amarantha-k@users.noreply.github.com> Co-authored-by: develoQ <develoQ.jp@gmail.com> Co-authored-by: Maria Shodunke <maria-robobug@users.noreply.github.com> Co-authored-by: Amarantha Kulkarni <akulkarni@ripple.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: authorize-minter.html
|
||||
parent: quickstart-javascript.html
|
||||
html: assign-an-authorized-minter-using-javascript.html
|
||||
parent: nfts-using-javascript.html
|
||||
blurb: Authorize another account to mint NFTs for you.
|
||||
labels:
|
||||
- Accounts
|
||||
@@ -8,8 +8,7 @@ labels:
|
||||
- XRP
|
||||
- NFTs, NFTokens
|
||||
---
|
||||
|
||||
# Assign an Authorized Minter
|
||||
# Assign an Authorized Minter Using JavaScript
|
||||
|
||||
You can assign another account permission to mint NFTs for you.
|
||||
|
||||
@@ -22,7 +21,7 @@ This example shows how to:
|
||||
|
||||
# Usage
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try the sample in your own browser.
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/){.github-code-download} archive to try the sample in your own browser.
|
||||
|
||||
## Get Accounts
|
||||
|
||||
@@ -205,7 +204,7 @@ Report success
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
This transaction blob is the same as the one used for the previous [`mintToken()` function](mint-and-burn-nfts.html#mint-token), with the addition of the `Issuer` field.
|
||||
This transaction blob is the same as the one used for the previous [`mintToken()` function](mint-and-burn-nfts-using-javascript.html#mint-token), with the addition of the `Issuer` field.
|
||||
|
||||
```javascript
|
||||
const tx_json = {
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: batch-minting.html
|
||||
parent: quickstart-javascript.html
|
||||
html: batch-mint-nfts-using-javascript.html
|
||||
parent: nfts-using-javascript.html
|
||||
blurb: Broker a sale between a sell offer and a buy offer.
|
||||
labels:
|
||||
- Accounts
|
||||
@@ -8,8 +8,7 @@ labels:
|
||||
- Broker
|
||||
- XRP
|
||||
---
|
||||
|
||||
# Batch Mint NFTs
|
||||
# Batch Mint NFTs Using JavaScript
|
||||
|
||||
You can create an application that mints multiple NFTs at one time. You can use a `for` loop to send one transaction after another.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: broker-sale.html
|
||||
parent: quickstart-javascript.html
|
||||
html: broker-an-nft-sale-using-javascript.html
|
||||
parent: nfts-using-javascript.html
|
||||
blurb: Broker a sale between a sell offer and a buy offer.
|
||||
labels:
|
||||
- Accounts
|
||||
@@ -8,8 +8,7 @@ labels:
|
||||
- Broker
|
||||
- XRP
|
||||
---
|
||||
|
||||
# Broker an NFT Sale
|
||||
# Broker an NFT Sale Using JavaScript
|
||||
|
||||
Earlier examples showed how to make buy and sell offers directly between two accounts. Another option is to use a third account as a broker for the sale. The broker acts on behalf of the NFT owner. The seller creates an offer with the broker account as its destination. The broker gathers and evaluates buy offers and chooses which one to accept, adding an agreed-upon fee for arranging the sale. When the broker account accepts a sell offer with a buy offer, the funds and ownership of the NFT are transferred simultaneously, completing the deal. This allows an account to act as a marketplace or personal agent for NFT creators and traders.
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
---
|
||||
html: create-accounts-send-xrp.html
|
||||
parent: quickstart-javascript.html
|
||||
blurb: Quickstart 1, create two accounts and transfer XRP between them.
|
||||
html: create-accounts-send-xrp-using-javascript.html
|
||||
parent: send-payments-using-javascript.html
|
||||
blurb: Create two accounts and transfer XRP between them.
|
||||
labels:
|
||||
- Accounts
|
||||
- Quickstart
|
||||
- Transaction Sending
|
||||
- XRP
|
||||
---
|
||||
# 1. Create Accounts and Send XRP
|
||||
# Create Accounts and Send XRP Using JavaScript
|
||||
|
||||
This example shows how to:
|
||||
|
||||
@@ -0,0 +1,661 @@
|
||||
---
|
||||
html: create-conditional-escrows-using-javascript.html
|
||||
parent: send-payments-using-javascript.html
|
||||
blurb: Create, finish, or cancel condition-based escrow transactions.
|
||||
labels:
|
||||
- Accounts
|
||||
- Quickstart
|
||||
- Transaction Sending
|
||||
- XRP
|
||||
---
|
||||
# Create Conditional Escrows Using JavaScript
|
||||
|
||||
This example shows how to:
|
||||
|
||||
1. Create escrow payments that become available when any account enters a fulfillment code.
|
||||
|
||||
2. Complete a conditional escrow transaction.
|
||||
|
||||
3. Cancel a conditional escrow transaction.
|
||||
|
||||
[](img/conditional-escrow1.png)
|
||||
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Download and expand the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive.
|
||||
|
||||
## Usage
|
||||
|
||||
### Create Escrow
|
||||
|
||||
You create a condition-based escrow using a fulfillment code associated with a condition code. Create the condition/fulfillment pair using the `five-bells-condition` application.
|
||||
|
||||
Install `five-bells-condition`:
|
||||
|
||||
1. In a terminal window, navigate to your local `Quickstart` directory (for convenience).
|
||||
2. Enter the command `npm install five-bells-condition`.
|
||||
|
||||
To create a condition/fulfillment pair:
|
||||
|
||||
1. In a terminal window, navigate to your `Quickstart` directory.
|
||||
2. Enter the command `node getConditionAndFulfillment.js`.
|
||||
3. Copy and save the generated Condition and Fulfillment pair.
|
||||
|
||||
[](img/conditional-escrow2.png)
|
||||
|
||||
To get test accounts:
|
||||
|
||||
1. Open `9.escrow-condition.html` in a browser
|
||||
2. Choose **Testnet** or **Devnet**.
|
||||
3. Get test accounts.
|
||||
1. If you have existing account seeds
|
||||
1. Paste account seeds in the **Seeds** field.
|
||||
2. Click **Get Accounts from Seeds**.
|
||||
2. If you do not have account seeds:
|
||||
1. Click **Get New Standby Account**.
|
||||
2. Click **Get New Operational Account**.
|
||||
|
||||
[](img/conditional-escrow3.png)
|
||||
|
||||
### Create Conditional Escrow:
|
||||
|
||||
When you create a conditional escrow, you need to specify the `Condition` value you generated above. You must also set a cancel date and time, after which the escrow is no longer available.
|
||||
|
||||
To create a conditional escrow:
|
||||
|
||||
1. Enter an **Amount** to transfer.
|
||||
2. Copy the **Operational Account** value.
|
||||
3. Paste it in the **Destination Account** field.
|
||||
4. Enter the **Escrow Condition** value.
|
||||
5. Enter the **Escrow Cancel (seconds)** value.
|
||||
6. Click **Create Escrow**.
|
||||
7. Copy and save the _Sequence Number_ of the escrow called out in the **Standby Result** field.
|
||||
|
||||
The escrow is created on the XRP Ledger instance, reserving your requested XRP amount plus the transaction cost.
|
||||
|
||||
When you create an escrow, capture and save the _Sequence Number_ so that you can use it to finish the escrow transaction.
|
||||
|
||||
[](img/conditional-escrow4.png)
|
||||
|
||||
## Finish Conditional Escrow
|
||||
|
||||
Any account can finish the conditional escrow any time before the _Escrow Cancel_ time. Following on the example above, you can use the _Sequence Number_ to finish the transaction once the Escrow Cancel time has passed.
|
||||
|
||||
To finish a time-based escrow:
|
||||
|
||||
1. Paste the sequence number in the Operational account **Escrow Sequence Number** field.
|
||||
2. Enter the `Fulfillment` code for the `Condition`.
|
||||
3. Click **Finish Conditional Escrow**.
|
||||
|
||||
The transaction completes and balances are updated for both the Standby and Operational accounts.
|
||||
|
||||
[](img/conditional-escrow5.png)
|
||||
|
||||
## Get Escrows
|
||||
|
||||
Click **Get Escrows** for either the Standby account or the Operational account to see their current list of escrows.
|
||||
|
||||
## Cancel Escrow
|
||||
|
||||
When the Escrow Cancel time passes, the escrow is no longer available to the recipient. The initiator of the escrow can reclaim the XRP, less the transaction fees. Any account can cancel an escrow once the cancel time has elapsed. Accounts that try to cancel the transaction prior to the **Escrow Cancel** time are charged the nominal transaction cost (12 drops), but the actual escrow cannot be cancelled until after the Escrow Cancel time.
|
||||
|
||||
## Oh No! I Forgot to Save the Sequence Number!
|
||||
|
||||
If you forget to save the sequence number, you can find it in the escrow transaction record.
|
||||
|
||||
1. Create a new escrow as described in [Create Escrow](#create-escrow), above.
|
||||
2. Click **Get Escrows** to get the escrow information.
|
||||
3. Copy the _PreviousTxnID_ value from the results.
|
||||

|
||||
4. Paste the _PreviousTxnID_ in the **Transaction to Look Up** field.
|
||||

|
||||
5. Click **Get Transaction**.
|
||||
6. Locate the _Sequence_ value in the results.
|
||||

|
||||
|
||||
# Code Walkthrough
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} in the source repository for this website.
|
||||
|
||||
## getConditionAndFulfillment.js
|
||||
|
||||
To generate a condition/fulfillment pair, use Node.js to run the `getConditionAndFulfillment.js` script.
|
||||
|
||||
```javascript
|
||||
function getConditionAndFulfillment() {
|
||||
```
|
||||
|
||||
Instantiate the `five-bells-condition` and `crypto` libraries.
|
||||
|
||||
```javascript
|
||||
const cc = require('five-bells-condition')
|
||||
const crypto = require('crypto')
|
||||
```
|
||||
|
||||
Create a random 32-byte seed string.
|
||||
|
||||
```javascript
|
||||
const preimageData = crypto.randomBytes(32)
|
||||
```
|
||||
|
||||
Create a fulfillment object.
|
||||
|
||||
```javascript
|
||||
const fulfillment = new cc.PreimageSha256()
|
||||
```
|
||||
|
||||
Generate a fulfillment code.
|
||||
|
||||
```javascript
|
||||
fulfillment.setPreimage(preimageData)
|
||||
```
|
||||
|
||||
Generate the condition value based on the fulfillment value.
|
||||
|
||||
```javascript
|
||||
const condition = fulfillment.getConditionBinary().toString('hex').toUpperCase()
|
||||
```
|
||||
|
||||
Return the condition.
|
||||
|
||||
```javascript
|
||||
console.log('Condition:', condition)
|
||||
```
|
||||
|
||||
Convert the fulfillment code to a hexadecimal string.
|
||||
|
||||
```javascript
|
||||
const fulfillment_hex = fulfillment.serializeBinary().toString('hex').toUpperCase()
|
||||
```
|
||||
|
||||
Return the fulfillment code. Keep it secret until you want to finish the escrow.
|
||||
|
||||
```javascript
|
||||
console.log('Fulfillment:', fulfillment_hex)
|
||||
}
|
||||
getConditionAndFulfillment()
|
||||
```
|
||||
|
||||
## ripplex9-escrow-condition.js
|
||||
|
||||
|
||||
### Create Conditional Escrow
|
||||
|
||||
```javascript
|
||||
async function createConditionalEscrow() {
|
||||
```
|
||||
|
||||
Connect to your preferred ledger.
|
||||
|
||||
```javascript
|
||||
results = "Connecting to the selected ledger.\n"
|
||||
standbyResultField.value = results
|
||||
let net = getNet()
|
||||
results = "Connecting to " + net + "....\n"
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
|
||||
results += "Connected. Creating conditional escrow.\n"
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
Instantiate the standby and operational wallets
|
||||
|
||||
```javascript
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
```
|
||||
|
||||
Capture the amount to send in the escrow.
|
||||
|
||||
```javascript
|
||||
const sendAmount = standbyAmountField.value
|
||||
```
|
||||
|
||||
Update the results field.
|
||||
|
||||
```javascript
|
||||
results += "\nstandby_wallet.address: = " + standby_wallet.address
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
Create a date value and add your requested number of seconds.
|
||||
|
||||
```javascript
|
||||
let escrow_cancel_date = new Date()
|
||||
escrow_cancel_date = addSeconds(parseInt(standbyEscrowCancelDateField.value))
|
||||
```
|
||||
|
||||
Prepare the `EscrowCreate` transaction.
|
||||
|
||||
```javascript
|
||||
const escrowTx = await client.autofill({
|
||||
"TransactionType": "EscrowCreate",
|
||||
"Account": standby_wallet.address,
|
||||
"Amount": xrpl.xrpToDrops(sendAmount),
|
||||
"Destination": standbyDestinationField.value,
|
||||
"CancelAfter": escrow_cancel_date,
|
||||
"Condition": standbyEscrowConditionField.value
|
||||
})
|
||||
```
|
||||
|
||||
Sign the transaction.
|
||||
|
||||
```javascript
|
||||
const signed = standby_wallet.sign(escrowTx)
|
||||
```
|
||||
|
||||
Submit the transaction and wait for the results.
|
||||
|
||||
```javascript
|
||||
const tx = await client.submitAndWait(signed.tx_blob)
|
||||
```
|
||||
|
||||
Report the results and update balance fields.
|
||||
|
||||
```javascript
|
||||
results += "\nSequence Number (Save!): " + JSON.stringify(tx.result.Sequence)
|
||||
results += "\n\nBalance changes: " +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
Disconnect from the XRPL
|
||||
|
||||
```javascript
|
||||
client.disconnect()
|
||||
|
||||
} // End of createTimeEscrow()
|
||||
```
|
||||
|
||||
### Finish Conditional Escrow
|
||||
|
||||
Finish the escrow by submitting the condition and fulfillment codes.
|
||||
|
||||
```javascript
|
||||
async function finishConditionalEscrow() {
|
||||
```
|
||||
|
||||
Connect to your preferred XRP Ledger instance.
|
||||
|
||||
```javascript
|
||||
results = "Connecting to the selected ledger.\n"
|
||||
operationalResultField.value = results
|
||||
let net = getNet()
|
||||
results += 'Connecting to ' + getNet() + '....'
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
results += "\nConnected. Finishing escrow.\n"
|
||||
operationalResultField.value = results
|
||||
```
|
||||
|
||||
Get the standby and operational account wallets.
|
||||
|
||||
```javascript
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const sendAmount = operationalAmountField.value
|
||||
|
||||
results += "\noperational_wallet.address: = " + operational_wallet.address
|
||||
operationalResultField.value = results
|
||||
```
|
||||
|
||||
Prepare the transaction.
|
||||
|
||||
```javascript
|
||||
const prepared = await client.autofill({
|
||||
"TransactionType": "EscrowFinish",
|
||||
"Account": operationalAccountField.value,
|
||||
"Owner": standbyAccountField.value,
|
||||
"OfferSequence": parseInt(operationalEscrowSequenceField.value),
|
||||
"Condition": standbyEscrowConditionField.value,
|
||||
"Fulfillment": operationalFulfillmentField.value
|
||||
})
|
||||
```
|
||||
|
||||
Sign the transaction.
|
||||
|
||||
```javascript
|
||||
|
||||
const signed = operational_wallet.sign(prepared)
|
||||
```
|
||||
|
||||
Submit the transaction and wait for the results.
|
||||
|
||||
```javascript
|
||||
const tx = await client.submitAndWait(signed.tx_blob)
|
||||
```
|
||||
|
||||
Report the results.
|
||||
|
||||
```javascript
|
||||
results += "\nBalance changes: " +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
operationalResultField.value = results
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
```
|
||||
|
||||
Disconnect from the XRPL.
|
||||
|
||||
```javascript
|
||||
client.disconnect()
|
||||
|
||||
} // End of finishEscrow()
|
||||
```
|
||||
|
||||
|
||||
## 9.escrow-condition.html
|
||||
|
||||
```html
|
||||
<html>
|
||||
<head>
|
||||
<title>Conditional Escrow Test Harness</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<style>
|
||||
body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
|
||||
h1{font-weight: bold;}
|
||||
input, button {padding: 6px;margin-bottom: 8px;}
|
||||
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
|
||||
td{vertical-align: middle;}
|
||||
</style>
|
||||
<script src='https://unpkg.com/xrpl@2.2.3'></script>
|
||||
<script src='ripplex1-send-xrp.js'></script>
|
||||
<script src='ripplex2-send-currency.js'></script>
|
||||
<script src='ripplex8-escrow.js'></script>
|
||||
<script src='ripplex9-escrow-condition.js'></script>
|
||||
</head>
|
||||
|
||||
<!-- ************************************************************** -->
|
||||
<!-- ********************** The Form ****************************** -->
|
||||
<!-- ************************************************************** -->
|
||||
|
||||
<body>
|
||||
<h1>Conditional Escrow Test Harness</h1>
|
||||
<form id="theForm">
|
||||
Choose your ledger instance:
|
||||
|
||||
<input type="radio" id="tn" name="server"
|
||||
value="wss://s.altnet.rippletest.net:51233" checked>
|
||||
<label for="tn">Testnet</label>
|
||||
|
||||
<input type="radio" id="dn" name="server"
|
||||
value="wss://s.devnet.rippletest.net:51233">
|
||||
<label for="dn">Devnet</label>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getAccountsFromSeeds()">Get Accounts From Seeds</button>
|
||||
<br/>
|
||||
<textarea id="seeds" cols="40" rows= "2"></textarea>
|
||||
<br/><br/>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccount('standby')">Get New Standby Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Standby Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Destination Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyDestinationField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Escrow Condition
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyEscrowConditionField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Escrow Cancel (seconds)
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyEscrowCancelDateField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Escrow Sequence Number
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyEscrowSequenceNumberField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td><button type="button" onClick="configureAccount('standby',document.querySelector('#standbyDefault').checked)">Configure Account</button></td>
|
||||
<td>
|
||||
<input type="checkbox" id="standbyDefault" checked="true"/>
|
||||
<label for="standbyDefault">Allow Rippling</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbySeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="left">
|
||||
<textarea id="standbyResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="sendXRP()">Send XRP ></button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/>
|
||||
<button type="button" onClick="createConditionalEscrow()">Create Conditional Escrow</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getStandbyEscrows()">Get Escrows</button>
|
||||
<br/>
|
||||
<button type="button" onClick="cancelEscrow()">Cancel Escrow</button>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="oPsendXRP()">< Send XRP</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/>
|
||||
<button type="button" onClick="finishConditionalEscrow()">Finish Conditional Escrow</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getOperationalEscrows()">Get Escrows</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getTransaction()">Get Transaction</button>
|
||||
</td>
|
||||
<td valign="top" align="right">
|
||||
<button type="button" onClick="getAccount('operational')">Get New Operational Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Operational Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Fulfillment Code
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalFulfillmentField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Escrow Sequence Number
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalEscrowSequenceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Transaction to Look Up
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalTransactionField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td align="right">
|
||||
<input type="checkbox" id="operationalDefault" checked="true"/>
|
||||
<label for="operationalDefault">Allow Rippling</label>
|
||||
<button type="button" onClick="configureAccount('operational',document.querySelector('#operationalDefault').checked)">Configure Account</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalSeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="right">
|
||||
<textarea id="operationalResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
@@ -0,0 +1,825 @@
|
||||
---
|
||||
html: create-time-based-escrows-using-javascript.html
|
||||
parent: send-payments-using-javascript.html
|
||||
blurb: Create, finish, or cancel time-based escrow transactions.
|
||||
labels:
|
||||
- Accounts
|
||||
- Quickstart
|
||||
- Transaction Sending
|
||||
- XRP
|
||||
---
|
||||
# Create Time-based Escrows Using JavaScript
|
||||
|
||||
This example shows how to:
|
||||
|
||||
|
||||
1. Create escrow payments that become available at a specified time and expire at a specified time.
|
||||
2. Finish an escrow payment.
|
||||
3. Retrieve information on escrows attached to an account.
|
||||
3. Cancel an escrow payment and return the XRP to the sending account.
|
||||
|
||||
|
||||
[](img/quickstart-escrow1.png)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/){.github-code-download}.
|
||||
|
||||
## Usage
|
||||
|
||||
To get test accounts:
|
||||
|
||||
1. Open `8.escrow.html` in a browser
|
||||
2. Choose **Testnet** or **Devnet**.
|
||||
3. Get test accounts.
|
||||
1. If you have existing account seeds
|
||||
1. Paste account seeds in the **Seeds** field.
|
||||
2. Click **Get Accounts from Seeds**.
|
||||
2. If you do not have account seeds:
|
||||
1. Click **Get New Standby Account**.
|
||||
2. Click **Get New Operational Account**.
|
||||
|
||||
[](img/quickstart-escrow2.png)
|
||||
|
||||
## Create Escrow
|
||||
|
||||
You can create a time-based escrow with a minimum time to finish the escrow and a cancel time after which the funds in escrow are no longer available to the recipient. This is a test harness: while a practical scenario might express time in days or weeks, this form lets you set the finish and cancel times in seconds so that you can quickly run through a variety of scenarios. (There are 86,400 seconds in a day, if you want to play with longer term escrows.)
|
||||
|
||||
To create a time-based escrow:
|
||||
|
||||
1. Enter an **Amount** to transfer.
|
||||
2. Copy the **Operational Account** value.
|
||||
3. Paste it in the **Destination Account** field.
|
||||
4. Set the **Escrow Finish (seconds)** value. For example, enter _10_.
|
||||
5. Set the **Escrow Cancel (seconds)** value. For example, enter _120_.
|
||||
6. Click **Create Escrow**.
|
||||
7. Copy the _Sequence Number_ of the escrow called out in the **Standby Result** field.
|
||||
|
||||
The escrow is created on the XRP Ledger instance, reserving 100 XRP plus the transaction cost. When you create an escrow, capture and save the **Sequence Number** so that you can use it to finish the escrow transaction.
|
||||
|
||||
[](img/quickstart-escrow3.png)
|
||||
|
||||
## Finish Escrow
|
||||
|
||||
The recipient of the XRP held in escrow can finish the transaction any time within the time window after the Escrow Finish date and time but before the Escrow Cancel date and time. Following on the example above, you can use the _Sequence Number_ to finish the transaction once 10 seconds have passed.
|
||||
|
||||
To finish a time-based escrow:
|
||||
|
||||
1. Paste the sequence number in the Operational account **Escrow Sequence Number** field.
|
||||
2. Click **Finish Escrow**.
|
||||
|
||||
The transaction completes and balances are updated for both the Standby and Operational accounts.
|
||||
|
||||
[](img/quickstart-escrow4.png)
|
||||
|
||||
## Get Escrows
|
||||
|
||||
Click **Get Escrows** for either the Standby account or the Operational account to see their current list of escrows. If you click the buttons now, there are no escrows at the moment.
|
||||
|
||||
For the purposes of this tutorial, follow the steps in [Create Escrow](#create-escrow), above, to create a new escrow transaction, perhaps setting **Escrow Cancel (seconds)** field to _600_ seconds to give you extra time to explore. Remember to capture the _Sequence Number_ from the transaction results.
|
||||
|
||||
Click **Get Escrows** for both the Standby and the Operational account. The `account_info` request returns the same `account_object` for both accounts, demonstrating the link between the accounts created by the escrow transaction.
|
||||
|
||||
[](img/quickstart-escrow5.png)
|
||||
|
||||
|
||||
## Cancel Escrow
|
||||
|
||||
When the Escrow Cancel time passes, the escrow is no longer available to the recipient. The initiator of the escrow can reclaim the XRP, less the transaction fees. If you try to cancel the transaction prior to the **Escrow Cancel** time, you are charged for the transaction, but the actual escrow cannot be cancelled until the time limit is reached.
|
||||
|
||||
You can wait the allotted time for the escrow you created in the previous step, then use it to try out the **Cancel Escrow** button
|
||||
|
||||
To cancel an expired escrow:
|
||||
|
||||
1. Enter the sequence number in the Standby **Escrow Sequence Number** field.
|
||||
2. Click **Cancel Escrow**.
|
||||
|
||||
The funds are returned to the Standby account, less the initial transaction fee.
|
||||
|
||||
[](img/quickstart-escrow6.png)
|
||||
|
||||
## Oh No! I Forgot to Save the Sequence Number!
|
||||
|
||||
If you forget to save the sequence number, you can find it in the escrow transaction record.
|
||||
|
||||
1. Create a new escrow as described in [Create Escrow](#create-escrow), above.
|
||||
2. Click **Get Escrows** to get the escrow information.
|
||||
3. Copy the _PreviousTxnID_ value from the results.
|
||||

|
||||
4. Paste the _PreviousTxnID_ in the **Transaction to Look Up** field.
|
||||

|
||||
5. Click **Get Transaction**.
|
||||
6. Locate the _Sequence_ value in the results.
|
||||

|
||||
|
||||
# Code Walkthrough
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} in the source repository for this website.
|
||||
|
||||
## ripple8-escrow.js
|
||||
|
||||
This example can be used with any XRP Ledger network, _Testnet_, or _Devnet_. You can update the code to choose different or additional XRP Ledger networks.
|
||||
|
||||
### Add Seconds to Date
|
||||
|
||||
This function accomplishes two things. It creates a new date object and adds the number of seconds taken from a form field. Then, it adjusts the date from the JavaScript format to the XRP Ledger format.
|
||||
|
||||
You provide the _numOfSeconds_ argument, the second parameter is a new Date object.
|
||||
```javascript
|
||||
function addSeconds(numOfSeconds, date = new Date()) {
|
||||
```
|
||||
|
||||
Set the _seconds_ value to the date seconds plus the number of seconds you provide.
|
||||
|
||||
```javascript
|
||||
date.setSeconds(date.getSeconds() + numOfSeconds);
|
||||
```
|
||||
|
||||
JavaScript dates are in milliseconds. Divide the date by 1000 to base it on seconds.
|
||||
|
||||
```javascript
|
||||
date = Math.floor(date / 1000)
|
||||
```
|
||||
|
||||
Subtract the number of seconds in the Ripple epoch to convert the value to an XRP Ledger compatible date value.
|
||||
|
||||
```javascript
|
||||
date = date - 946684800
|
||||
```
|
||||
|
||||
Return the result.
|
||||
|
||||
```javascript
|
||||
return date;
|
||||
}
|
||||
```
|
||||
|
||||
### Create Time-based Escrow
|
||||
|
||||
```javascript
|
||||
async function createTimeEscrow() {
|
||||
```
|
||||
|
||||
Instantiate two new date objects, then set the dates to the current date plus the set number of seconds for the finish and cancel dates.
|
||||
|
||||
```javascript
|
||||
let escrow_finish_date = new Date()
|
||||
let escrow_cancel_date = new Date()
|
||||
escrow_finish_date = addSeconds(parseInt(standbyEscrowFinishDateField.value))
|
||||
escrow_cancel_date = addSeconds(parseInt(standbyEscrowCancelDateField.value))
|
||||
```
|
||||
|
||||
Connect to the ledger.
|
||||
|
||||
```javascript
|
||||
results = "Connecting to the selected ledger.\n"
|
||||
standbyResultField.value = results
|
||||
let net = getNet()
|
||||
results = "Connecting to " + net + "....\n"
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
results += "Connected. Creating time-based escrow.\n"
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
Get the wallet information based on the account seed values.
|
||||
|
||||
```javascript
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const sendAmount = standbyAmountField.value
|
||||
results += "\nstandby_wallet.address: = " + standby_wallet.address
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
Define the `EscrowCreate` transaction, automatically filling values in common fields.
|
||||
|
||||
```javascript
|
||||
const escrowTx = await client.autofill({
|
||||
"TransactionType": "EscrowCreate",
|
||||
"Account": standby_wallet.address,
|
||||
"Amount": xrpl.xrpToDrops(sendAmount),
|
||||
"Destination": standbyDestinationField.value,
|
||||
"FinishAfter": escrow_finish_date,
|
||||
"CancelAfter": escrow_cancel_date
|
||||
})
|
||||
```
|
||||
|
||||
Sign the escrow transaction definition.
|
||||
|
||||
```javascript
|
||||
const signed = standby_wallet.sign(escrowTx)
|
||||
```
|
||||
|
||||
Submit the transaction.
|
||||
|
||||
```javascript
|
||||
const tx = await client.submitAndWait(signed.tx_blob)
|
||||
```
|
||||
|
||||
Report the results.
|
||||
|
||||
```javascript
|
||||
results += "\nSequence Number (Save!): " + JSON.stringify(tx.result.Sequence)
|
||||
results += "\n\nBalance changes: " +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
Disconnect from the XRP Ledger.
|
||||
|
||||
```javascript
|
||||
client.disconnect()
|
||||
} // End of createTimeEscrow()
|
||||
```
|
||||
|
||||
### Finish Time-based Escrow
|
||||
|
||||
```javascript
|
||||
async function finishEscrow() {
|
||||
```
|
||||
|
||||
Connect to the XRP Ledger and get the account wallets.
|
||||
|
||||
```javascript
|
||||
results = "Connecting to the selected ledger.\n"
|
||||
operationalResultField.value = results
|
||||
let net = getNet()
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
|
||||
results += "\nConnected. Finishing escrow.\n"
|
||||
operationalResultField.value = results
|
||||
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const sendAmount = operationalAmountField.value
|
||||
|
||||
results += "\noperational_wallet.address: = " + operational_wallet.address
|
||||
operationalResultField.value = results
|
||||
```
|
||||
|
||||
Define the transaction. The _Owner_ is the account that created the escrow. The _OfferSequence_ is the sequence number of the escrow transaction. Automatically fill in the common fields for the transaction.
|
||||
|
||||
```javascript
|
||||
const prepared = await client.autofill({
|
||||
"TransactionType": "EscrowFinish",
|
||||
"Account": operationalAccountField.value,
|
||||
"Owner": standbyAccountField.value,
|
||||
"OfferSequence": parseInt(operationalEscrowSequenceField.value)
|
||||
})
|
||||
```
|
||||
|
||||
Sign the transaction definition.
|
||||
|
||||
```javascript
|
||||
const signed = operational_wallet.sign(prepared)
|
||||
```
|
||||
|
||||
Submit the signed transaction to the XRP ledger.
|
||||
|
||||
```javascript
|
||||
|
||||
const tx = await client.submitAndWait(signed.tx_blob)
|
||||
```
|
||||
|
||||
Report the results.
|
||||
|
||||
```javascript
|
||||
results += "\nBalance changes: " +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
operationalResultField.value = results
|
||||
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
```
|
||||
|
||||
Disconnect from the XRP Ledger.
|
||||
|
||||
```javascript
|
||||
client.disconnect()
|
||||
} // End of finishEscrow()
|
||||
```
|
||||
|
||||
### Get Standby Escrows
|
||||
|
||||
Get the escrows associated with the Standby account.
|
||||
|
||||
```javascript
|
||||
async function getStandbyEscrows() {
|
||||
```
|
||||
|
||||
Connect to the network. The information you are looking for is public information, so there is no need to instantiate your wallet.
|
||||
|
||||
```javascript
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
standbyResultField.value = results
|
||||
|
||||
await client.connect()
|
||||
results += '\nConnected.'
|
||||
standbyResultField.value = results
|
||||
|
||||
results= "\nGetting standby account escrows...\n"
|
||||
```
|
||||
|
||||
Create the `account_objects` request. Specify that you want objects of the type _escrow_.
|
||||
|
||||
```javascript
|
||||
const escrow_objects = await client.request({
|
||||
"id": 5,
|
||||
"command": "account_objects",
|
||||
"account": standbyAccountField.value,
|
||||
"ledger_index": "validated",
|
||||
"type": "escrow"
|
||||
})
|
||||
```
|
||||
|
||||
Report the results.
|
||||
|
||||
```javascript
|
||||
results += JSON.stringify(escrow_objects.result, null, 2)
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
Disconnect from the XRP Ledger
|
||||
|
||||
```javascript
|
||||
client.disconnect()
|
||||
} // End of getStandbyEscrows()
|
||||
```
|
||||
|
||||
### Get Operational Escrows
|
||||
|
||||
This function is the same as `getStandbyEscrows()`, but for the Operational account.
|
||||
|
||||
```javascript
|
||||
async function getOperationalEscrows() {
|
||||
```
|
||||
|
||||
Connect to the network. The information you are looking for is public information, so there is no need to instantiate your wallet.
|
||||
|
||||
```javascript
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
operationalResultField.value = results
|
||||
|
||||
await client.connect()
|
||||
results += '\nConnected.'
|
||||
operationalResultField.value = results
|
||||
|
||||
results= "\nGetting operational account escrows...\n"
|
||||
```
|
||||
|
||||
Create the `account_objects` request. Specify that you want objects of the type _escrow_.
|
||||
|
||||
```javascript
|
||||
const escrow_objects = await client.request({
|
||||
"id": 5,
|
||||
"command": "account_objects",
|
||||
"account": operationalAccountField.value,
|
||||
"ledger_index": "validated",
|
||||
"type": "escrow"
|
||||
})
|
||||
```
|
||||
|
||||
Report the results.
|
||||
|
||||
```javascript
|
||||
results += JSON.stringify(escrow_objects.result, null, 2)
|
||||
operationalResultField.value = results
|
||||
```
|
||||
|
||||
Disconnect from the XRP Ledger instance.
|
||||
|
||||
```javascript
|
||||
client.disconnect()
|
||||
} // End of getOperationalEscrows()
|
||||
```
|
||||
|
||||
### Get Transaction Info
|
||||
|
||||
```javascript
|
||||
async function getTransaction() {
|
||||
```
|
||||
|
||||
Connect to the XRP Ledger.
|
||||
|
||||
```javascript
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
operationalResultField.value = results
|
||||
|
||||
await client.connect()
|
||||
results += '\nConnected.'
|
||||
operationalResultField.value = results
|
||||
|
||||
results= "\nGetting transaction information...\n"
|
||||
```
|
||||
|
||||
Prepare and send the transaction information request. The only required parameter is the transaction ID.
|
||||
|
||||
```javascript
|
||||
const tx_info = await client.request({
|
||||
"id": 1,
|
||||
"command": "tx",
|
||||
"transaction": operationalTransactionField.value,
|
||||
})
|
||||
```
|
||||
Report the results.
|
||||
|
||||
```javascript
|
||||
results += JSON.stringify(tx_info.result, null, 2)
|
||||
operationalResultField.value = results
|
||||
```
|
||||
|
||||
Disconnect from the XRP Ledger instance.
|
||||
|
||||
```javascript
|
||||
client.disconnect()
|
||||
} // End of getTransaction()
|
||||
```
|
||||
|
||||
### Cancel Escrow
|
||||
|
||||
Cancel an escrow after it passes the expiration date.
|
||||
|
||||
```javascript
|
||||
async function cancelEscrow() {
|
||||
```
|
||||
|
||||
Connect to the XRP Ledger instance.
|
||||
|
||||
```javascript
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
standbyResultField.value = results
|
||||
|
||||
await client.connect()
|
||||
results += '\nConnected.'
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
Get the account wallets.
|
||||
|
||||
```javascript
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
```
|
||||
|
||||
Prepare the EscrowCancel transaction.
|
||||
|
||||
```javascript
|
||||
const prepared = await client.autofill({
|
||||
"TransactionType": "EscrowCancel",
|
||||
"Account": standby_wallet.address,
|
||||
"Owner": standbyAccountField.value,
|
||||
"OfferSequence": parseInt(standbyEscrowSequenceNumberField.value)
|
||||
})
|
||||
```
|
||||
|
||||
Sign the transaction.
|
||||
```javascript
|
||||
const signed = standby_wallet.sign(prepared)
|
||||
```
|
||||
|
||||
Submit the transaction and wait for the response.
|
||||
|
||||
``` javascript
|
||||
const tx = await client.submitAndWait(signed.tx_blob)
|
||||
```
|
||||
|
||||
Report the results.
|
||||
|
||||
```javascript
|
||||
results += "\nBalance changes: " +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
standbyResultField.value = results
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
```
|
||||
|
||||
Disconnect from the XRP Ledger instance.
|
||||
|
||||
```javascript
|
||||
client.disconnect()
|
||||
}
|
||||
```
|
||||
|
||||
## 8.escrow.html
|
||||
|
||||
```html
|
||||
<html>
|
||||
<head>
|
||||
<title>Time-based Escrow Test Harness</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<style>
|
||||
body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
|
||||
h1{font-weight: bold;}
|
||||
input, button {padding: 6px;margin-bottom: 8px;}
|
||||
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
|
||||
td{vertical-align: middle;}
|
||||
</style>
|
||||
<script src='https://unpkg.com/xrpl@2.2.3'></script>
|
||||
<script src='ripplex1-send-xrp.js'></script>
|
||||
<script src='ripplex2-send-currency.js'></script>
|
||||
<script src='ripplex8-escrow.js'></script>
|
||||
</head>
|
||||
|
||||
<!-- ************************************************************** -->
|
||||
<!-- ********************** The Form ****************************** -->
|
||||
<!-- ************************************************************** -->
|
||||
|
||||
<body>
|
||||
<h1>Time-based Escrow Test Harness</h1>
|
||||
<form id="theForm">
|
||||
Choose your ledger instance:
|
||||
|
||||
<input type="radio" id="tn" name="server"
|
||||
value="wss://s.altnet.rippletest.net:51233" checked>
|
||||
<label for="tn">Testnet</label>
|
||||
|
||||
<input type="radio" id="dn" name="server"
|
||||
value="wss://s.devnet.rippletest.net:51233">
|
||||
<label for="dn">Devnet</label>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getAccountsFromSeeds()">Get Accounts From Seeds</button>
|
||||
<br/>
|
||||
<textarea id="seeds" cols="40" rows= "2"></textarea>
|
||||
<br/><br/>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccount('standby')">Get New Standby Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Standby Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Destination Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyDestinationField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Escrow Finish (seconds)
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyEscrowFinishDateField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Escrow Cancel (seconds)
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyEscrowCancelDateField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Escrow Sequence Number
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyEscrowSequenceNumberField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td><button type="button" onClick="configureAccount('standby',document.querySelector('#standbyDefault').checked)">Configure Account</button></td>
|
||||
<td>
|
||||
<input type="checkbox" id="standbyDefault" checked="true"/>
|
||||
<label for="standbyDefault">Allow Rippling</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbySeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="left">
|
||||
<textarea id="standbyResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="sendXRP()">Send XRP ></button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/>
|
||||
<button type="button" onClick="createTimeEscrow()">Create Time-based Escrow</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getStandbyEscrows()">Get Escrows</button>
|
||||
<br/>
|
||||
<button type="button" onClick="cancelEscrow()">Cancel Escrow</button>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="oPsendXRP()">< Send XRP</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/>
|
||||
<button type="button" onClick="finishEscrow()">Finish Time-based Escrow</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getOperationalEscrows()">Get Escrows</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getTransaction()">Get Transaction</button>
|
||||
</td>
|
||||
<td valign="top" align="right">
|
||||
<button type="button" onClick="getAccount('operational')">Get New Operational Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Operational Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Destination
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalDestinationField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Escrow Sequence Number
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalEscrowSequenceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr> <td align="right">
|
||||
Transaction to Look Up
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalTransactionField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td align="right">
|
||||
<input type="checkbox" id="operationalDefault" checked="true"/>
|
||||
<label for="operationalDefault">Allow Rippling</label>
|
||||
<button type="button" onClick="configureAccount('operational',document.querySelector('#operationalDefault').checked)">Configure Account</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalSeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="right">
|
||||
<textarea id="operationalResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
html: create-trustline-send-currency.html
|
||||
parent: quickstart-javascript.html
|
||||
blurb: Quickstart step 2, create trust lines and send currency.
|
||||
html: create-trustline-send-currency-using-javascript.html
|
||||
parent: send-payments-using-javascript.html
|
||||
blurb: Create Trust Lines and send currency.
|
||||
labels:
|
||||
- Cross-Currency
|
||||
- Payments
|
||||
@@ -9,8 +9,7 @@ labels:
|
||||
- Tokens
|
||||
|
||||
---
|
||||
|
||||
# 2. Create Trust Line and Send Currency
|
||||
# Create Trust Line and Send Currency Using JavaScript
|
||||
|
||||
This example shows how to:
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
---
|
||||
html: mint-and-burn-nfts.html
|
||||
parent: quickstart-javascript.html
|
||||
blurb: Quickstart step 3, mint and burn NFTs.
|
||||
html: mint-and-burn-nfts-using-javascript.html
|
||||
parent: nfts-using-javascript.html
|
||||
blurb: Mint and burn NFTs.
|
||||
labels:
|
||||
- Quickstart
|
||||
- Tokens
|
||||
- Non-fungible tokens, NFTs
|
||||
---
|
||||
|
||||
# 3. Mint and Burn NFTs
|
||||
# Mint and Burn NFTs Using JavaScript
|
||||
|
||||
This example shows how to:
|
||||
|
||||
1. Mint new Non-fungible Tokens (NFTs).
|
||||
2. Get a list of existing NFTs.
|
||||
3. Delete (Burn) an NFT.
|
||||
3. Delete (Burn) a NFT.
|
||||
|
||||
[](img/quickstart8.png)
|
||||
|
||||
@@ -35,11 +34,11 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
|
||||
[](img/quickstart9.png)
|
||||
|
||||
## Mint an NFT
|
||||
## Mint a NFT
|
||||
|
||||
To mint a non-fungible token object:
|
||||
|
||||
1. Set the **Flags** field. For testing purposes, we recommend setting the value to _8_. This sets the _tsTransferable_ flag, meaning that the NFT object can be transferred to another account. Otherwise, the NFT object can only be transferred back to the issuing account. See [NFToken Mint](https://xrpl.org/nftokenmint.html#:~:text=Example%20NFTokenMint%20JSON-,NFTokenMint%20Fields,-NFTokenMint%20Flags) for information about all of the available flags for minting NFTs.
|
||||
1. Set the **Flags** field. For testing purposes, we recommend setting the value to _8_. This sets the _tsTransferable_ flag, meaning that the NFT object can be transferred to another account. Otherwise, the NFT object can only be transferred back to the issuing account. See [NFTokenMint](nftokenmint.html) for information about all of the available flags for minting NFTs.
|
||||
2. Enter the **Token URL**. This is a URI that points to the data or metadata associated with the NFT object. You can use the sample URI provided if you do not have one of your own.
|
||||
3. Enter the **Transfer Fee**, a percentage of the proceeds from future sales of the NFT that will be returned to the original creator. This is a value of 0-50000 inclusive, allowing transfer rates between 0.000% and 50.000% in increments of 0.001%. If you do not set the **Flags** field to allow the NFT to be transferrable, set this field to 0.
|
||||
4. Click **Mint NFT**.
|
||||
@@ -55,9 +54,9 @@ Click **Get NFTs** to get a list of NFTs owned by the account.
|
||||
|
||||
## Burn a Token
|
||||
|
||||
The current owner of an NFT can always destroy (or _burn_) an NFT object.
|
||||
The current owner of a NFT can always destroy (or _burn_) a NFT object.
|
||||
|
||||
To permanently destroy an NFT:
|
||||
To permanently destroy a NFT:
|
||||
|
||||
1. Enter the **Token ID**.
|
||||
2. Click **Burn NFT**.
|
||||
@@ -704,4 +703,4 @@ async function oPburnToken() {
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
```
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: py-authorize-minter.html
|
||||
parent: quickstart-python.html
|
||||
parent: send-payments-using-python.html
|
||||
blurb: Authorize another account to mint NFTs for you.
|
||||
labels:
|
||||
- Accounts
|
||||
@@ -9,7 +9,7 @@ labels:
|
||||
- NFTs, NFTokens
|
||||
---
|
||||
|
||||
# Assign an Authorized Minter (Python)
|
||||
# Assign an Authorized Minter Using Python
|
||||
|
||||
You can assign another account permission to mint NFTs for you.
|
||||
|
||||
@@ -22,7 +22,7 @@ This example shows how to:
|
||||
|
||||
# Usage
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try the sample in your own browser.
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/py/){.github-code-download} archive to try the sample in your own browser.
|
||||
|
||||
## Get Accounts
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: py-broker-sale.html
|
||||
parent: quickstart-python.html
|
||||
parent: send-payments-using-python.html
|
||||
blurb: Broker a sale between a sell offer and a buy offer.
|
||||
labels:
|
||||
- Accounts
|
||||
@@ -9,7 +9,7 @@ labels:
|
||||
- XRP
|
||||
---
|
||||
|
||||
# Broker an NFT Sale (Python)
|
||||
# Broker an NFT Sale Using Python
|
||||
|
||||
Earlier examples showed how to make buy and sell offers directly between two accounts. Another option is to use a third account as a broker for the sale. The broker acts on behalf of the NFT owner. The seller creates an offer with the broker account as its destination. The broker gathers and evaluates buy offers and chooses which one to accept, adding an agreed-upon fee for arranging the sale. When the broker account accepts a sell offer with a buy offer, the funds and ownership of the NFT are transferred simultaneously, completing the deal. This allows an account to act as a marketplace or personal agent for NFT creators and traders.
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
---
|
||||
html: py-create-accounts-send-xrp.html
|
||||
parent: quickstart-python.html
|
||||
blurb: Quickstart 1, create two accounts and transfer XRP between them.
|
||||
parent: send-payments-using-python.html
|
||||
blurb: Create two accounts and transfer XRP between them using Python.
|
||||
labels:
|
||||
- Accounts
|
||||
- Quickstart
|
||||
- Transaction Sending
|
||||
- XRP
|
||||
---
|
||||
# 1. Create Accounts and Send XRP (Python)
|
||||
# Create Accounts and Send XRP Using Python
|
||||
|
||||
This example shows how to:
|
||||
|
||||
@@ -28,7 +28,7 @@ To get started, create a new folder on your local disk and install the Python li
|
||||
pip3 install xrpl-py
|
||||
```
|
||||
|
||||
Download and expand the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/python/){.github-code-download} archive.
|
||||
Download and expand the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/py/){.github-code-download} archive.
|
||||
|
||||
**Note:** Without the Quickstart Samples, you will not be able to try the examples that follow.
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
---
|
||||
html: py-create-trustline-send-currency.html
|
||||
parent: quickstart-python.html
|
||||
blurb: Quickstart step 2, create trust lines and send currency.
|
||||
parent: send-payments-using-python.html
|
||||
blurb: Create trust lines and send currency.
|
||||
labels:
|
||||
- Cross-Currency
|
||||
- Payments
|
||||
- Quickstart
|
||||
- Tokens
|
||||
---
|
||||
# 2. Create Trust Line and Send Currency (Python)
|
||||
# Create Trust Line and Send Currency Using Python
|
||||
|
||||
This example shows how to:
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
---
|
||||
html: py-mint-and-burn-nfts.html
|
||||
parent: quickstart-python.html
|
||||
blurb: Quickstart step 3, mint and burn NFTs.
|
||||
parent: send-payments-using-python.html
|
||||
blurb: Mint and burn NFTs.
|
||||
labels:
|
||||
- Quickstart
|
||||
- Tokens
|
||||
- Non-fungible tokens, NFTs
|
||||
---
|
||||
|
||||
# 3. Mint and Burn NFTs (Python)
|
||||
# Mint and Burn NFTs Using Python
|
||||
|
||||
This example shows how to:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: py-transfer-nfts.html
|
||||
parent: quickstart-python.html
|
||||
parent: send-payments-using-python.html
|
||||
blurb: Use a Python test harness to create and accept NFT buy and sell offers.
|
||||
labels:
|
||||
- Quickstart
|
||||
@@ -8,7 +8,7 @@ labels:
|
||||
- Non-fungible Tokens, NFTs
|
||||
---
|
||||
|
||||
# 4. Transfer NFTs (Python)
|
||||
# Transfer NFTs Using Python
|
||||
|
||||
This example shows how to:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: quickstart-intro.html
|
||||
parent: quickstart-javascript.html
|
||||
html: send-payments-using-javascript.html
|
||||
parent: modular-tutorials-in-javascript.html
|
||||
blurb: Use a JavaScript test harness to send XRP, trade currencies, and mint and trade NFTs.
|
||||
labels:
|
||||
- Accounts
|
||||
@@ -11,7 +11,7 @@ labels:
|
||||
- Tokens
|
||||
- XRP
|
||||
---
|
||||
# Quickstart Introduction (JavaScript)
|
||||
# Send Payments Using JavaScript
|
||||
|
||||
The XRP Ledger (XRPL) is a robust, secure, customizable service. You can create your own interface to try out the capabilities and support your specific business needs.
|
||||
|
||||
@@ -28,21 +28,11 @@ Typically, the example functions for interacting with the XRP Ledger involve fou
|
||||
3. Get the state of accounts and tokens on the XRP Ledger using requests.
|
||||
4. Disconnect from the XRP Ledger.
|
||||
|
||||
Each lesson shows you how to build the Token Test Harness one section at a time. Each module lets you try out meaningful interactions with the test ledger, with complete JavaScript and HTML code samples and a code walkthrough. There is also a link to the complete source code for each section that can be modified with a text editor and run in a browser. If you cannot wait, you can follow the prerequisites below, then jump to lesson 4, [Transfer NFTs](transfer-nfts.html), and try out the complete test harness right away.
|
||||
Each lesson shows you how to build the Token Test Harness one section at a time. Each module lets you try out meaningful interactions with the test ledger, with complete JavaScript and HTML code samples and a code walkthrough. There is also a link to the complete source code for each section that can be modified with a text editor and run in a browser. If you cannot wait, you can follow the prerequisites below, then jump to lesson 4, [Transfer NFTs](transfer-nfts-using-javascript.html), and try out the complete test harness right away.
|
||||
|
||||
This quickstart tutorial introduces you to the API used to implement features and explore the capabilities of XRP Ledger. It does not represent *all* of the capabilities of the API and this example is not intended for production or secure payment use.
|
||||
|
||||
Much of this is “brute force” code that sacrifices conciseness for readability. Each example builds on the previous step, adding a new JavaScript file and the supporting UI. We expect the applications you build to greatly improve upon these examples. Your feedback and contributions are most welcome.
|
||||
|
||||
In this quickstart, you can:
|
||||
|
||||
1. [Create Accounts and Send XRP](create-accounts-send-xrp.html)
|
||||
2. [Create Trust Line and Send Currency](create-trustline-send-currency.html).
|
||||
3. [Mint and Burn NFTs](mint-and-burn-nfts.html).
|
||||
4. [Transfer NFTs](transfer-nfts.html).
|
||||
|
||||
There are also expanded lessons demonstrating how to [Broker a NFT Sale](broker-sale.html), [Assign an Authorized Minter](authorize-minter.html), and [Batch Mint NFTs](batch-minting.html).
|
||||
|
||||
Much of this is “brute force” code that sacrifices conciseness for readability. Each example builds on the previous examples, adding a new JavaScript file and the supporting UI. We anticipate that the applications you build greatly improve upon these examples. Your feedback and contributions are most welcome.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -52,6 +42,4 @@ To get started, create a new folder on your local disk and install the JavaScrip
|
||||
npm install xrpl
|
||||
```
|
||||
|
||||
Download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/){.github-code-download}.
|
||||
|
||||
**Note:** Without the Quickstart Samples, you will not be able to try the examples that follow.
|
||||
Download and expand the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/){.github-code-download}.
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: py-quickstart-intro.html
|
||||
parent: quickstart-python.html
|
||||
html: send-payments-using-python.html
|
||||
parent: modular-tutorials-in-python.html
|
||||
blurb: Use a Python test harness to send XRP, trade currencies, and mint and trade NFTs.
|
||||
labels:
|
||||
- Accounts
|
||||
@@ -11,7 +11,7 @@ labels:
|
||||
- Tokens
|
||||
- XRP
|
||||
---
|
||||
# Quickstart Introduction (Python)
|
||||
# Send Payments Using Python
|
||||
|
||||
The XRP Ledger (XRPL) is a robust, secure, customizable service. You can create your own interface to try out the capabilities and support your specific business needs.
|
||||
|
||||
@@ -52,6 +52,6 @@ To get started, create a new folder on your local disk and install the Python li
|
||||
pip3 install xrpl-py
|
||||
```
|
||||
|
||||
Download the python [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/python/){.github-code-download}.
|
||||
Download the python [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/py/){.github-code-download}.
|
||||
|
||||
**Note:** Without the Quickstart Samples, you will not be able to try the examples that follow.
|
||||
@@ -1,14 +1,13 @@
|
||||
---
|
||||
html: transfer-nfts.html
|
||||
parent: quickstart-javascript.html
|
||||
html: transfer-nfts-using-javascript.html
|
||||
parent: nfts-using-javascript.html
|
||||
blurb: Use a JavaScript test harness to send XRP, trade currencies, and mint and trade NFTs.
|
||||
labels:
|
||||
- Quickstart
|
||||
- Tokens
|
||||
- Non-fungible Tokens, NFTs
|
||||
---
|
||||
|
||||
# 4. Transfer NFTs
|
||||
# Transfer NFTs Using JavaScript
|
||||
|
||||
This example shows how to:
|
||||
|
||||
@@ -21,7 +20,7 @@ This example shows how to:
|
||||
|
||||
[](img/quickstart13.png)
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try each of the samples in your own browser.
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/){.github-code-download} archive to try each of the samples in your own browser.
|
||||
|
||||
# Usage
|
||||
|
||||
@@ -80,7 +79,7 @@ To create an offer to buy a NFT:
|
||||
|
||||
## Accept a Buy Offer
|
||||
|
||||
To accept an offer to buy an NFT:
|
||||
To accept an offer to buy a NFT:
|
||||
|
||||
1. Enter the **NFT Offer Index** (the `nft_offer_index` of the NFT buy offer).
|
||||
3. Click **Accept Buy Offer**.
|
||||
@@ -89,7 +88,7 @@ To accept an offer to buy an NFT:
|
||||
|
||||
## Get Offers
|
||||
|
||||
To list the buy and sell offers associated with an NFT:
|
||||
To list the buy and sell offers associated with a NFT:
|
||||
1. Enter the **NFT ID**.
|
||||
2. Click **Get Offers**.
|
||||
|
||||
@@ -165,7 +164,7 @@ If the Expiration Date is present, append it to the transaction.
|
||||
|
||||
```
|
||||
|
||||
If the Destination field is not empty, append it to the transaction. When the destination is set, only the destination account can buy the NFT.
|
||||
If the Destination field is not empty, append it to the transaction. When the destination is set, only the destination account can buy the NFToken.
|
||||
|
||||
```javascript
|
||||
if(standbyDestinationField.value !== '') {
|
||||
@@ -1377,4 +1376,4 @@ Update the form with fields and buttons to support the new functions.
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
```
|
||||
Reference in New Issue
Block a user