mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-26 22:55:49 +00:00
Migrate interactive tutorials (post realm v0.70)
Attempt migrating interactive tutorial again Migrate interactive tutorial snippet syntax Interactive tutorials: partially migrate send-xrp, no-freeze to new syntax Fix Send XRP interactive tutorial Interactive tutorials: fixes for Redocly incl. localization challenges Interactive tutorials: switch defaultValue back to value in anticipation of Redocly bugfix Fix document.ready→window.onRouteChange, cyclers, etc. in interactive tutorials.
This commit is contained in:
@@ -21,8 +21,10 @@ WebSocket follows a model where the client and server open one connection, then
|
||||
- You need a stable internet connection and access to an XRP Ledger server. The embedded examples connect to Ripple's pool of public servers. If you [run your own `rippled` or Clio server](../../infrastructure/installation/index.md), you can also connect to that server locally.
|
||||
- To properly handle XRP values without rounding errors, you need access to a number type that can do math on 64-bit unsigned integers. The examples in this tutorial use [big.js](https://github.com/MikeMcl/big.js/). If you are working with [tokens](../../concepts/tokens/index.md), you need even more precision. For more information, see [Currency Precision](../../references/protocol/data-types/currency-formats.md#xrp-precision).
|
||||
|
||||
|
||||
<script type="application/javascript" src="/js/interactive-tutorial.js"></script>
|
||||
<!-- Big number support -->
|
||||
<script type="application/javascript" src="assets/vendor/big.min.js"></script>
|
||||
<script type="application/javascript" src="/vendor/big.min.js"></script>
|
||||
<script type="application/javascript">
|
||||
// Helper stuff for this interactive tutorial specifically
|
||||
|
||||
@@ -72,13 +74,15 @@ const socket = new WebSocket('ws://localhost:6006')
|
||||
|
||||
Example:
|
||||
|
||||
{{ start_step("Connect") }}
|
||||
{% interactive-block label="Connect" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="connect-socket-button" class="btn btn-primary">Connect</button>
|
||||
<strong>Connection status:</strong>
|
||||
<span id="connection-status">Not connected</span>
|
||||
<h5>Console:</h5>
|
||||
<div class="ws-console" id="monitor-console-connect"><span class="placeholder">(Log is empty)</span></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
<script type="application/javascript">
|
||||
let socket;
|
||||
@@ -187,12 +191,14 @@ async function pingpong() {
|
||||
// Add pingpong() to the 'open' listener for socket
|
||||
```
|
||||
|
||||
{{ start_step("Dispatch Messages") }}
|
||||
{% interactive-block label="Dispatch Messages" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="enable_dispatcher" class="btn btn-primary" disabled="disabled">Enable Dispatcher</button>
|
||||
<button id="dispatch_ping" class="btn btn-primary" disabled="disabled">Ping!</button>
|
||||
<h5>Responses</h5>
|
||||
<div class="ws-console" id="monitor-console-ping"><span class="placeholder">(Log is empty)</span></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
<script type="application/javascript">
|
||||
const AWAITING = {}
|
||||
@@ -290,13 +296,15 @@ WS_HANDLERS["transaction"] = log_tx
|
||||
|
||||
For the following example, try opening the [Transaction Sender](/resources/dev-tools/tx-sender) in a different window or even on a different device and sending transactions to the address you subscribed to:
|
||||
|
||||
{{ start_step("Subscribe") }}
|
||||
{% interactive-block label="Subscribe" steps=$frontmatter.steps %}
|
||||
|
||||
<label for="subscribe_address">Test Net Address:</label>
|
||||
<input type="text" class="form-control" id="subscribe_address" value="rUCzEr6jrEyMpjhs4wSdQdz4g8Y382NxfM">
|
||||
<button id="tx_subscribe" class="btn btn-primary" disabled="disabled">Subscribe</button>
|
||||
<h5>Transactions</h5>
|
||||
<div class="ws-console" id="monitor-console-subscribe"><span class="placeholder">(Log is empty)</span></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
<script type="application/javascript">
|
||||
async function do_subscribe() {
|
||||
@@ -358,11 +366,13 @@ The following sample code looks at transaction metadata of all the above transac
|
||||
|
||||
{% code-snippet file="/_code-samples/monitor-payments-websocket/js/read-amount-received.js" language="js" /%}
|
||||
|
||||
{{ start_step("Read Payments") }}
|
||||
{% interactive-block label="Read Payments" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="tx_read" class="btn btn-primary" disabled="disabled">Start Reading</button>
|
||||
<h5>Transactions</h5>
|
||||
<div class="ws-console" id="monitor-console-read"><span class="placeholder">(Log is empty)</span></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
<script type="application/javascript">
|
||||
function CountXRPDifference(affected_nodes, address) {
|
||||
|
||||
@@ -3,13 +3,11 @@ html: send-xrp.html
|
||||
parent: tasks.html
|
||||
blurb: Learn how to send test payments right from your browser.
|
||||
cta_text: Send XRP
|
||||
embed_xrpl_js: true
|
||||
filters:
|
||||
- interactive_steps
|
||||
labels:
|
||||
- XRP
|
||||
- Payments
|
||||
top_nav_grouping: Popular Pages
|
||||
steps: ['Generate', 'Connect', 'Prepare', 'Sign', 'Submit', 'Wait', 'Check']
|
||||
---
|
||||
# Send XRP
|
||||
|
||||
@@ -20,8 +18,8 @@ This tutorial explains how to send a direct XRP Payment using `xrpl.js` for Java
|
||||
## Prerequisites
|
||||
|
||||
<!-- Source for this specific tutorial's interactive bits: -->
|
||||
<script type="application/javascript" src="assets/js/tutorials/send-xrp.js"></script>
|
||||
{% set use_network = "Testnet" %}
|
||||
<script type="application/javascript" src="/js/interactive-tutorial.js"></script>
|
||||
<script type="application/javascript" src="/js/tutorials/send-xrp.js"></script>
|
||||
|
||||
To interact with the XRP Ledger, you need to set up a dev environment with the necessary tools. This tutorial provides examples using the following options:
|
||||
|
||||
@@ -145,14 +143,15 @@ Here's an example of preparing the above payment:
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Prepare") }}
|
||||
{% interactive-block label="Prepare" steps=$frontmatter.steps %}
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">Send: </span>
|
||||
</div>
|
||||
<input type="number" class="form-control" value="22" id="xrp-amount"
|
||||
aria-label="Amount of XRP, as a decimal" aria-describedby="xrp-amount-label"
|
||||
min=".000001" max="100000000000" step="any">
|
||||
min=".000001" max="100000000000" step="any" />
|
||||
<div class="input-group-append">
|
||||
<span class="input-group-text" id="xrp-amount-label"> XRP</span>
|
||||
</div>
|
||||
@@ -160,7 +159,8 @@ Here's an example of preparing the above payment:
|
||||
<button id="prepare-button" class="btn btn-primary previous-steps-required">Prepare
|
||||
example transaction</button>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### 4. Sign the Transaction Instructions
|
||||
@@ -199,11 +199,13 @@ The result of the signing operation is a transaction object containing a signatu
|
||||
- In xrpl4j, `SignatureService.sign` returns a `SignedTransaction`, which contains the transaction's hash, which you can use to look up the transaction later.
|
||||
- In `XRPL_PHP`, the signing API also returns the transaction's ID, or identifying hash, which you can use to look up the transaction later. This is a 64-character hexadecimal string that is unique to this transaction.
|
||||
|
||||
{{ start_step("Sign") }}
|
||||
{% interactive-block label="Sign" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="sign-button" class="btn btn-primary previous-steps-required">Sign
|
||||
example transaction</button>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### 5. Submit the Signed Blob
|
||||
@@ -246,12 +248,16 @@ If you see any other result, you should check the following:
|
||||
|
||||
See the full list of [transaction results](../../references/protocol/transactions/transaction-results/transaction-results.md) for more possibilities.
|
||||
|
||||
{{ start_step("Submit") }}
|
||||
{% interactive-block label="Submit" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="submit-button" class="btn btn-primary previous-steps-required" data-tx-blob-from="#signed-tx-blob" data-wait-step-name="Wait">Submit
|
||||
example transaction</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png"> Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### 6. Wait for Validation
|
||||
@@ -286,9 +292,7 @@ Most transactions are accepted into the next ledger version after they're submit
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Wait") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
|
||||
|
||||
### 7. Check Transaction Status
|
||||
@@ -327,10 +331,12 @@ To know for sure what a transaction did, you must look up the outcome of the tra
|
||||
|
||||
**Caution:** XRP Ledger APIs may return tentative results from ledger versions that have not yet been validated. For example, in [tx method][] response, be sure to look for `"validated": true` to confirm that the data comes from a validated ledger version. Transaction results that are not from a validated ledger version are subject to change. For more information, see [Finality of Results](../../concepts/transactions/finality-of-results/index.md).
|
||||
|
||||
{{ start_step("Check") }}
|
||||
{% interactive-block label="Check" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="get-tx-button" class="btn btn-primary previous-steps-required">Check transaction status</button>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
## Differences for Production
|
||||
|
||||
@@ -27,9 +27,7 @@ To disable the master key pair for an account, you must meet the following prere
|
||||
|
||||
## Steps
|
||||
|
||||
{% set n = cycler(* range(1,99)) %}
|
||||
|
||||
### {{n.next()}}. Construct Transaction JSON
|
||||
### 1. Construct Transaction JSON
|
||||
|
||||
Prepare an [AccountSet transaction][] from your account with the field `"SetValue": 4`. This is the value for the AccountSet flag "Disable Master" (`asfDisableMaster`). The only other required fields for this transaction are the required [common fields](../../references/protocol/transactions/common-fields.md). For example, if you leave off the [auto-fillable fields](../../references/protocol/transactions/common-fields.md#auto-fillable-fields), the following transaction instructions are enough:
|
||||
|
||||
@@ -43,7 +41,7 @@ Prepare an [AccountSet transaction][] from your account with the field `"SetValu
|
||||
|
||||
**Tip:** It is strongly recommended to also provide the `LastLedgerSequence` field so that you can [reliably get the outcome of the transaction in a predictable amount of time](../../concepts/transactions/reliable-transaction-submission.md).
|
||||
|
||||
### {{n.next()}}. Sign Transaction
|
||||
### 2. Sign Transaction
|
||||
|
||||
You must use the **master key pair** to sign the transaction.
|
||||
|
||||
@@ -181,7 +179,7 @@ Look for `"status": "success"` to indicate that the server successfully signed t
|
||||
|
||||
Take note of the `tx_blob` value from the response. This is a signed transaction binary you can submit to the network.
|
||||
|
||||
### {{n.next()}}. Submit Transaction
|
||||
### 3. Submit Transaction
|
||||
|
||||
Submit the signed transaction blob from the previous step to the XRP Ledger.
|
||||
|
||||
@@ -307,11 +305,11 @@ Loading: "/etc/opt/ripple/rippled.cfg"
|
||||
If the transaction fails with the result `tecNO_ALTERNATIVE_KEY`, your account does not have another method of authorizing transactions currently enabled. You must [assign a regular key pair](assign-a-regular-key-pair.md) or [set up multi-signing](set-up-multi-signing.md), then try again to disable the master key pair.
|
||||
|
||||
|
||||
### {{n.next()}}. Wait for validation
|
||||
### 4. Wait for validation
|
||||
|
||||
{% partial file="/_snippets/wait-for-validation.md" /%}
|
||||
|
||||
### {{n.next()}}. Confirm Account Flags
|
||||
### 5. Confirm Account Flags
|
||||
|
||||
Confirm that your account's master key is disabled using the [account_info method][]. Be sure to specify the following parameters:
|
||||
|
||||
|
||||
@@ -26,9 +26,7 @@ To use offline signing, you must meet the following prerequisites:
|
||||
|
||||
## Steps
|
||||
|
||||
{% set n = cycler(* range(1,99)) %}
|
||||
|
||||
### {{n.next()}}. Set up offline machine
|
||||
### 1. Set up offline machine
|
||||
|
||||
The offline machine needs secure persistent storage (for example, an encrypted disk drive) and a way to [sign transactions](../../concepts/transactions/secure-signing.md). For an offline machine, you typically use physical media to transfer any necessary software after downloading it from an online machine. You must be sure that the online machine, the physical media, and the software itself are not infected with malware.
|
||||
|
||||
@@ -41,7 +39,7 @@ Software options for signing on the XRP Ledger include:
|
||||
You may want to set up custom software to help construct transaction instructions on the offline machine. For example, your software may track what [sequence number][] to use next, or contain preset templates for certain types of transactions you expect to send.
|
||||
|
||||
|
||||
### {{n.next()}}. Generate cryptographic keys
|
||||
### 2. Generate cryptographic keys
|
||||
|
||||
On the **offline machine**, generate a pair of [cryptographic keys](../../concepts/accounts/cryptographic-keys.md) to be used with your account. Be sure to generate the keys with a securely random procedure, not from a short passphrase or some other source that does not have enough entropy. For example, you can use the [wallet_propose method][] of `rippled`:
|
||||
|
||||
@@ -82,7 +80,7 @@ Take note of the following values:
|
||||
|
||||
|
||||
|
||||
### {{n.next()}}. Fund the new address
|
||||
### 3. Fund the new address
|
||||
|
||||
From an online machine, send enough XRP to the **account address** you noted in step 1. For more information, see [Creating Accounts](../../concepts/accounts/accounts.md#creating-accounts).
|
||||
|
||||
@@ -90,7 +88,7 @@ From an online machine, send enough XRP to the **account address** you noted in
|
||||
|
||||
|
||||
|
||||
### {{n.next()}}. Confirm account details
|
||||
### 4. Confirm account details
|
||||
|
||||
When the transaction from the previous step is validated by consensus, your account has been created. From the online machine, you can confirm the status of the account with the [account_info method][]. Make sure the response contains `"validated": true` to confirm that this result is final.
|
||||
|
||||
@@ -129,7 +127,7 @@ Loading: "/etc/opt/ripple/rippled.cfg"
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
### {{n.next()}}. Enter the sequence number on the offline machine.
|
||||
### 5. Enter the sequence number on the offline machine.
|
||||
|
||||
Save the account's starting sequence number on the offline machine. Whenever you prepare a transaction using the offline machine, use the saved sequence number, then increase the sequence number by 1 and save the new value.
|
||||
|
||||
@@ -139,7 +137,7 @@ Optionally, save the current ledger index to the offline machine. You can use th
|
||||
|
||||
|
||||
|
||||
### {{n.next()}}. Sign initial setup transactions, if any.
|
||||
### 6. Sign initial setup transactions, if any.
|
||||
|
||||
On the offline machine, prepare and sign transactions for configuring your account. The details depend on how you intend to use your account. Some examples of things you might want to do include:
|
||||
|
||||
@@ -190,13 +188,13 @@ Loading: "/etc/opt/ripple/rippled.cfg"
|
||||
To ensure _all_ transactions have a final outcome within a limited amount of time, provide a [`LastLedgerSequence`](../../concepts/transactions/reliable-transaction-submission.md#lastledgersequence) field. This value should be based on the current ledger index (which you must look up from an online machine) and the amount of time you want the transaction to remain valid. Be sure to set a large enough `LastLedgerSequence` value to allow for time spent switching from the online machine to the offline machine and back. For example, a value 256 higher than the current ledger index means that the transaction is valid for about 15 minutes. For more information, see [Finality of Results](../../concepts/transactions/finality-of-results/index.md) and [Reliable Transaction Submission](../../concepts/transactions/reliable-transaction-submission.md).
|
||||
|
||||
|
||||
### {{n.next()}}. Copy transactions to online machine.
|
||||
### 7. Copy transactions to online machine.
|
||||
|
||||
After you have signed the transactions, the next step is to get the signed transaction data to your online machine. See [Prerequisites](#prerequisites) for some examples of how to do this.
|
||||
|
||||
|
||||
|
||||
### {{n.next()}}. Submit setup transactions.
|
||||
### 8. Submit setup transactions.
|
||||
|
||||
The next step is to submit the transactions. Most transactions should have a final outcome in the next validated ledger after submission (about 4 seconds later), or possibly the ledger after that if they get queued (less than 10 seconds). For detailed steps to track the final outcome of a transaction, see [Reliable Transaction Submission](../../concepts/transactions/reliable-transaction-submission.md).
|
||||
|
||||
@@ -241,7 +239,7 @@ Loading: "/etc/opt/ripple/rippled.cfg"
|
||||
|
||||
Retry submitting any transactions that failed with a [non-final outcome](../../concepts/transactions/finality-of-results/index.md). There is no chance of the same transaction being processed more than once.
|
||||
|
||||
### {{n.next()}}. Confirm the final status of the transactions.
|
||||
### 9. Confirm the final status of the transactions.
|
||||
|
||||
For each transaction you submitted, note the transaction's [final outcome](../../concepts/transactions/finality-of-results/index.md), for example using the [tx method][]. For example:
|
||||
|
||||
@@ -314,7 +312,7 @@ For any transactions you decide to adjust or replace, note the details for when
|
||||
|
||||
|
||||
|
||||
### {{n.next()}}. Reconcile offline machine status.
|
||||
### 10. Reconcile offline machine status.
|
||||
|
||||
Return to the offline machine and apply any necessary changes to your custom server's saved settings, such as:
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ filters:
|
||||
- interactive_steps
|
||||
labels:
|
||||
- Accounts
|
||||
steps: ['Generate', 'Connect', 'Send AccountSet', 'Wait', 'Confirm Settings', 'Test Payments']
|
||||
---
|
||||
# Require Destination Tags
|
||||
|
||||
@@ -26,7 +27,8 @@ This tutorial demonstrates how to enable the Require Destination Tag flag on you
|
||||
- You can also read along and use the interactive steps in your browser without any setup.
|
||||
|
||||
<!-- Source for this specific tutorial's interactive bits: -->
|
||||
<script type="application/javascript" src="assets/js/tutorials/require-destination-tags.js"></script>
|
||||
<script type="application/javascript" src="/js/interactive-tutorial.js"></script>
|
||||
<script type="application/javascript" src="/js/tutorials/require-destination-tags.js"></script>
|
||||
|
||||
## Example Code
|
||||
|
||||
@@ -35,9 +37,8 @@ Complete sample code for all the steps of these tutorials is available under the
|
||||
- See [Code Samples: Require Destination Tags](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/require-destination-tags/) in the source repository for this website.
|
||||
|
||||
## Steps
|
||||
{% set n = cycler(* range(1,99)) %}
|
||||
|
||||
### {{n.next()}}. Get Credentials
|
||||
### 1. Get Credentials
|
||||
|
||||
To transact on the XRP Ledger, you need an address and secret key, and some XRP. For development purposes, you can get these using the following interface:
|
||||
|
||||
@@ -45,7 +46,7 @@ To transact on the XRP Ledger, you need an address and secret key, and some XRP.
|
||||
|
||||
When you're building production-ready software, you should use an existing account, and manage your keys using a [secure signing configuration](../../concepts/transactions/secure-signing.md).
|
||||
|
||||
### {{n.next()}}. Connect to the Network
|
||||
### 2. Connect to the Network
|
||||
|
||||
You must be connected to the network to submit transactions to it. The following code shows how to connect to a public XRP Ledger Testnet server a supported [client library](../../references/client-libraries.md):
|
||||
|
||||
@@ -65,7 +66,7 @@ For this tutorial, click the following button to connect:
|
||||
|
||||
{% partial file="/_snippets/interactive-tutorials/connect-step.md" /%}
|
||||
|
||||
### {{n.next()}}. Send AccountSet Transaction
|
||||
### 3. Send AccountSet Transaction
|
||||
|
||||
To enable the `RequireDest` flag, set the [`asfRequireDest` value (`1`)](../../references/protocol/transactions/types/accountset.md#accountset-flags) in the `SetFlag` field of an [AccountSet transaction][]. To send the transaction, you first _prepare_ it to fill out all the necessary fields, then _sign_ it with your account's secret key, and finally _submit_ it to the network.
|
||||
|
||||
@@ -83,23 +84,25 @@ For example:
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Send AccountSet") }}
|
||||
{% interactive-block label="Send AccountSet" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="send-accountset" class="btn btn-primary previous-steps-required" data-wait-step-name="Wait">Send AccountSet</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
### 4. Wait for Validation
|
||||
|
||||
Most transactions are accepted into the next ledger version after they're submitted, which means it may take 4-7 seconds for a transaction's outcome to be final. If the XRP Ledger is busy or poor network connectivity delays a transaction from being relayed throughout the network, a transaction may take longer to be confirmed. (For information on how to set an expiration for transactions, see [Reliable Transaction Submission](../../concepts/transactions/reliable-transaction-submission.md).)
|
||||
|
||||
{{ start_step("Wait") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
|
||||
|
||||
### {{n.next()}}. Confirm Account Settings
|
||||
### 5. Confirm Account Settings
|
||||
|
||||
After the transaction is validated, you can check your account's settings to confirm that the Require Destination Tag flag is enabled.
|
||||
|
||||
@@ -117,20 +120,28 @@ After the transaction is validated, you can check your account's settings to con
|
||||
{% /tabs %}
|
||||
|
||||
|
||||
{{ start_step("Confirm Settings") }}
|
||||
{% interactive-block label="Confirm Settings" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="confirm-settings" class="btn btn-primary previous-steps-required">Confirm Settings</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
For further confirmation, you can send test transactions (from a different address) to confirm that the setting is working as you expect it to. If you a payment with a destination tag, it should succeed, and if you send one _without_ a destination tag, it should fail with the error code [`tecDST_TAG_NEEDED`](../../references/protocol/transactions/transaction-results/tec-codes.md).
|
||||
|
||||
{{ start_step("Test Payments") }}
|
||||
{% interactive-block label="Test Payments" steps=$frontmatter.steps %}
|
||||
|
||||
<button class="test-payment btn btn-primary" data-dt="10">Send XRP (with Destination Tag)</button>
|
||||
<button class="test-payment btn btn-primary" data-dt="">Send XRP (without Destination Tag)</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
## See Also
|
||||
|
||||
@@ -7,6 +7,7 @@ filters:
|
||||
- interactive_steps
|
||||
labels:
|
||||
- Accounts
|
||||
steps: ['Generate', 'Connect', 'Check Sequence', 'Prepare & Sign', 'Submit', 'Wait', 'Intermission', 'Check Tickets', 'Prepare Ticketed Tx', 'Submit Ticketed Tx', 'Wait Again']
|
||||
---
|
||||
# Use Tickets
|
||||
|
||||
@@ -15,8 +16,8 @@ labels:
|
||||
## Prerequisites
|
||||
|
||||
<!-- Source for this specific tutorial's interactive bits: -->
|
||||
<script type="application/javascript" src="assets/js/tutorials/use-tickets.js"></script>
|
||||
{% set use_network = "Testnet" %}
|
||||
<script type="application/javascript" src="/js/interactive-tutorial.js"></script>
|
||||
<script type="application/javascript" src="/js/tutorials/use-tickets.js"></script>
|
||||
|
||||
This page provides JavaScript examples that use the [xrpl.js](https://js.xrpl.org/) library. See [Get Started Using JavaScript](../get-started/get-started-using-javascript.md) for setup instructions.
|
||||
|
||||
@@ -25,7 +26,6 @@ Since JavaScript works in the web browser, you can read along and use the intera
|
||||
|
||||
|
||||
## Steps
|
||||
{% set n = cycler(* range(1,99)) %}
|
||||
|
||||
This tutorial is divided into a few phases:
|
||||
|
||||
@@ -34,7 +34,7 @@ This tutorial is divided into a few phases:
|
||||
- (Optional) **Intermission:** After creating Tickets, you can send various other transactions at any time before, during, and after the following steps.
|
||||
- (Steps 7-10) **Use Ticket:** Use one of your set-aside Tickets to send a transaction. You can repeat these steps while skipping the previous parts as long as you have at least one Ticket remaining to use.
|
||||
|
||||
### {{n.next()}}. Get Credentials
|
||||
### 1. Get Credentials
|
||||
|
||||
To transact on the XRP Ledger, you need an address and secret key, and some XRP. For development purposes, you can get these on the [{{use_network}}](../../concepts/networks-and-servers/parallel-networks.md) using the following interface:
|
||||
|
||||
@@ -43,7 +43,7 @@ To transact on the XRP Ledger, you need an address and secret key, and some XRP.
|
||||
When you're building production-ready software, you should use an existing account, and manage your keys using a [secure signing configuration](../../concepts/transactions/secure-signing.md).
|
||||
|
||||
|
||||
### {{n.next()}}. Connect to Network
|
||||
### 2. Connect to Network
|
||||
|
||||
You must be connected to the network to submit transactions to it. Since Tickets are only available on Devnet so far, you should connect to a Devnet server. For example:
|
||||
|
||||
@@ -62,7 +62,7 @@ For this tutorial, click the following button to connect:
|
||||
{% partial file="/_snippets/interactive-tutorials/connect-step.md" /%}
|
||||
|
||||
|
||||
### {{n.next()}}. Check Sequence Number
|
||||
### 3. Check Sequence Number
|
||||
|
||||
Before you create any Tickets, you should check what [Sequence Number][] your account is at. You want the current Sequence number for the next step, and the Ticket Sequence numbers it sets aside start from this number.
|
||||
|
||||
@@ -74,15 +74,19 @@ Before you create any Tickets, you should check what [Sequence Number][] your ac
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Check Sequence") }}
|
||||
{% interactive-block label="Check Sequence" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="check-sequence" class="btn btn-primary previous-steps-required">Check Sequence Number</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Querying...</div>
|
||||
|
||||
{% loading-icon message="Querying..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
|
||||
### {{n.next()}}. Prepare and Sign TicketCreate
|
||||
### 4. Prepare and Sign TicketCreate
|
||||
|
||||
Construct a [TicketCreate transaction][] using the sequence number you determined in the previous step. Use the `TicketCount` field to specify how many Tickets to create. For example, to prepare a transaction that would make 10 Tickets:
|
||||
|
||||
@@ -97,14 +101,16 @@ Construct a [TicketCreate transaction][] using the sequence number you determine
|
||||
Record the transaction's hash and `LastLedgerSequence` value so you can [be sure whether or not it got validated](../../concepts/transactions/reliable-transaction-submission.md) later.
|
||||
|
||||
|
||||
{{ start_step("Prepare & Sign") }}
|
||||
{% interactive-block label="Prepare & Sign" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="prepare-and-sign" class="btn btn-primary previous-steps-required">Prepare & Sign</button>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
|
||||
### {{n.next()}}. Submit TicketCreate
|
||||
### 5. Submit TicketCreate
|
||||
|
||||
Submit the signed transaction blob that you created in the previous step. For example:
|
||||
|
||||
@@ -116,14 +122,18 @@ Submit the signed transaction blob that you created in the previous step. For ex
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Submit") }}
|
||||
{% interactive-block label="Submit" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="ticketcreate-submit" class="btn btn-primary previous-steps-required" data-tx-blob-from="#tx_blob" data-wait-step-name="Wait">Submit</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
### 6. Wait for Validation
|
||||
|
||||
Most transactions are accepted into the next ledger version after they're submitted, which means it may take 4-7 seconds for a transaction's outcome to be final. If the XRP Ledger is busy or poor network connectivity delays a transaction from being relayed throughout the network, a transaction may take longer to be confirmed. (For information on how to set an expiration for transactions, see [Reliable Transaction Submission](../../concepts/transactions/reliable-transaction-submission.md).)
|
||||
|
||||
@@ -135,9 +145,7 @@ Most transactions are accepted into the next ledger version after they're submit
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Wait") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
|
||||
|
||||
### (Optional) Intermission
|
||||
@@ -146,16 +154,18 @@ The power of Tickets is that you can carry on with your account's business as us
|
||||
|
||||
**Tip:** You can come back here to send Sequenced transactions between or during any of the following steps, without interfering with the success of your Ticketed transaction.
|
||||
|
||||
{{ start_step("Intermission") }}
|
||||
{% interactive-block label="Intermission" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="intermission-payment" class="btn btn-primary previous-steps-required">Payment</button>
|
||||
<button id="intermission-escrowcreate" class="btn btn-primary previous-steps-required">EscrowCreate</button>
|
||||
<button id="intermission-accountset" class="btn btn-primary previous-steps-required">AccountSet</button>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
|
||||
### {{n.next()}}. Check Available Tickets
|
||||
### 7. Check Available Tickets
|
||||
|
||||
When you want to send a Ticketed transaction, you need to know what Ticket Sequence number to use for it. If you've been keeping careful track of your account, you already know which Tickets you have, but if you're not sure, you can use the [account_objects method][] to look up your available tickets. For example:
|
||||
|
||||
@@ -168,14 +178,16 @@ When you want to send a Ticketed transaction, you need to know what Ticket Seque
|
||||
{% /tabs %}
|
||||
|
||||
|
||||
{{ start_step("Check Tickets") }}
|
||||
{% interactive-block label="Check Tickets" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="check-tickets" class="btn btn-primary previous-steps-required">Check Tickets</button>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
**Tip:** You can repeat the steps from here through the end as long as you have Tickets left to be used!
|
||||
|
||||
### {{n.next()}}. Prepare Ticketed Transaction
|
||||
### 8. Prepare Ticketed Transaction
|
||||
|
||||
Now that you have a Ticket available, you can prepare a transaction that uses it.
|
||||
|
||||
@@ -196,17 +208,19 @@ If you don't plan to submit the TicketCreate transaction right away, you should
|
||||
- **`rippled`:** Omit `LastLedgerSequence` from the prepared instructions. The server does not provide a value by default.
|
||||
{% /admonition %}
|
||||
|
||||
{{ start_step("Prepare Ticketed Tx") }}
|
||||
{% interactive-block label="Prepare Ticketed Tx" steps=$frontmatter.steps %}
|
||||
|
||||
<div id="ticket-selector">
|
||||
<h4>Select a Ticket:</h4>
|
||||
<div class="form-area"></div>
|
||||
</div>
|
||||
<button id="prepare-ticketed-tx" class="btn btn-primary previous-steps-required">Prepare Ticketed Transaction</button>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. Submit Ticketed Transaction
|
||||
### 9. Submit Ticketed Transaction
|
||||
|
||||
Submit the signed transaction blob that you created in the previous step. For example:
|
||||
|
||||
@@ -218,19 +232,19 @@ Submit the signed transaction blob that you created in the previous step. For ex
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Submit Ticketed Tx") }}
|
||||
{% interactive-block label="Submit Ticketed Tx" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="ticketedtx-submit" class="btn btn-primary previous-steps-required" data-tx-blob-from="#tx_blob_t" data-wait-step-name="Wait Again">Submit</button>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
### 10. Wait for Validation
|
||||
|
||||
Ticketed transactions go through the consensus process the same way that Sequenced transactions do.
|
||||
|
||||
{{ start_step("Wait Again") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" variables={label: "Wait Again"} /%}
|
||||
|
||||
## With Multi-Signing
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ labels:
|
||||
- Decentralized Exchange
|
||||
- Tokens
|
||||
- AMM
|
||||
steps: ['Connect', 'Generate', 'Acquire tokens', 'Check for AMM', 'Look up AMMCreate cost', 'Create AMM', 'Check AMM info', 'Check trust lines']
|
||||
---
|
||||
# Create an Automated Market Maker
|
||||
|
||||
@@ -17,7 +18,8 @@ _(Requires the [AMM amendment][] {% not-enabled /%})_
|
||||
An [Automated Market Maker (AMM)](../../concepts/tokens/decentralized-exchange/automated-market-makers.md) can be an efficient way to facilitate exchanges between two assets while earning its liquidity providers passive income. This tutorial shows how to create an AMM for a given asset pair.
|
||||
|
||||
<!-- Source for this specific tutorial's interactive bits: -->
|
||||
<script type="application/javascript" src="assets/js/tutorials/create-amm.js"></script>
|
||||
<script type="application/javascript" src="/js/interactive-tutorial.js"></script>
|
||||
<script type="application/javascript" src="/js/tutorials/create-amm.js"></script>
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -37,10 +39,8 @@ Complete sample code for all of the steps of these tutorials is available under
|
||||
|
||||
|
||||
## Steps
|
||||
{% set n = cycler(* range(1,99)) %}
|
||||
{% set use_network = "Devnet" %}
|
||||
|
||||
### {{n.next()}}. Connect to the network
|
||||
### 1. Connect to the network
|
||||
|
||||
You must be connected to the network to query it and submit transactions. The following code shows how to connect to a public {{use_network}} server using a supported [client library](../../references/client-libraries.md):
|
||||
|
||||
@@ -56,7 +56,7 @@ For this tutorial, click the following button to connect:
|
||||
|
||||
{% partial file="/_snippets/interactive-tutorials/connect-step.md" /%}
|
||||
|
||||
### {{n.next()}}. Get credentials
|
||||
### 2. Get credentials
|
||||
|
||||
To transact on the XRP Ledger, you need an address, a secret key, and some XRP. For development and testing purposes, you can get these on the [{{use_network}}](../../concepts/networks-and-servers/parallel-networks.md) using the following interface:
|
||||
|
||||
@@ -73,7 +73,7 @@ When you're building production-ready software, you should use an existing accou
|
||||
{% /tabs %}
|
||||
|
||||
|
||||
### {{n.next()}}. Select and acquire assets
|
||||
### 3. Select and acquire assets
|
||||
|
||||
As the creator of an AMM, you are also the first liquidity provider and you have to supply it with a starting pool of assets. Other users of the XRP Ledger can also become liquidity providers by supplying assets after the AMM exists. It's crucial to choose assets carefully because, as a liquidity provider for an AMM, you are supplying some amounts of both for users to swap between. If one of the AMM's assets becomes worthless, other users can use the AMM to trade for the other asset, leaving the AMM (and thus, its liquidity providers including you) holding only the worthless one. Technically, the AMM always holds some positive amount of both assets, but the amounts can be very small.
|
||||
|
||||
@@ -101,14 +101,18 @@ The helper function for issuing follows an abbreviated version of the steps in t
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Acquire tokens") }}
|
||||
{% interactive-block label="Acquire tokens" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="buy-tst" class="btn btn-primary previous-steps-required">Buy TST</button>
|
||||
<button id="get-foo" class="btn btn-primary previous-steps-required">Get FOO</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Working...</div>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
### {{n.next()}}. Check if the AMM exists
|
||||
{% loading-icon message="Working..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
### 4. Check if the AMM exists
|
||||
|
||||
Since there can only be one AMM for a specific pair of assets, it's best to check first before trying to create one. Use the [amm_info method][] to check whether the AMM already exists. For the request, you specify the two assets. The response should be an `actNotFound` error if the AMM does not exist.
|
||||
|
||||
@@ -122,13 +126,17 @@ Since there can only be one AMM for a specific pair of assets, it's best to chec
|
||||
|
||||
If the AMM does already exist, you should double-check that you specified the right pair of assets. If someone else has already created this AMM, you can deposit to it instead. <!-- TODO: link to a tutorial about depositing to and withdrawing from an AMM when one exists -->
|
||||
|
||||
{{ start_step("Check for AMM") }}
|
||||
<button id="check-for-amm" class="btn btn-primary previous-steps-required">Check AMM</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
{% interactive-block label="Check for AMM" steps=$frontmatter.steps %}
|
||||
|
||||
### {{n.next()}}. Look up the AMMCreate transaction cost
|
||||
<button id="check-for-amm" class="btn btn-primary previous-steps-required">Check AMM</button>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
### 5. Look up the AMMCreate transaction cost
|
||||
|
||||
Creating an AMM has a special [transaction cost][] to prevent spam: since it creates objects in the ledger that no one owns, you must burn at least one [owner reserve increment](../../concepts/accounts/reserves.md) of XRP to send the AMMCreate transaction. The exact value can change due to [fee voting](https://xrpl.org/fee-voting.html), so you should look up the current incremental reserve value using the [server_state method][].
|
||||
|
||||
@@ -142,14 +150,18 @@ It is also a good practice to display this value and give a human operator a cha
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Look up AMMCreate cost") }}
|
||||
{% interactive-block label="Look up AMMCreate cost" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="look-up-ammcreate-cost" class="btn btn-primary previous-steps-required">Check cost</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. Send AMMCreate transaction
|
||||
### 6. Send AMMCreate transaction
|
||||
|
||||
Send an [AMMCreate transaction][] to create the AMM. Important aspects of this transaction include:
|
||||
|
||||
@@ -172,7 +184,8 @@ For the two starting assets, it does not matter which is `Asset` and which is `A
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Create AMM") }}
|
||||
{% interactive-block label="Create AMM" steps=$frontmatter.steps %}
|
||||
|
||||
<form>
|
||||
<div class="form-group row">
|
||||
<label for="trading-fee" class="col-form-label col-sm-3">Trading Fee</label>
|
||||
@@ -203,11 +216,14 @@ For the two starting assets, it does not matter which is `Asset` and which is `A
|
||||
</div>
|
||||
</form>
|
||||
<button id="create-amm" class="btn btn-primary previous-steps-required">Create AMM</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
### {{n.next()}}. Check AMM info
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
### 7. Check AMM info
|
||||
|
||||
If the AMMCreate transaction succeeded, it creates the AMM and related objects in the ledger. You _could_ check the metadata of the AMMCreate transaction, but it is often easier to call the [amm_info method][] again to get the status of the newly-created AMM.
|
||||
|
||||
@@ -223,13 +239,17 @@ In the result, the `amm` object's `lp_token` field is particularly useful becaus
|
||||
|
||||
Initially, the AMM's total outstanding LP Tokens, reported in the `lp_token` field of the `amm_info` response, match the tokens you hold as its first liquidity provider. However, after other accounts deposit liquidity to the same AMM, the amount shown in `amm_info` updates to reflect the total issued to all liquidity providers. Since others can deposit at any time, even potentially in the same ledger version where the AMM was created, you shouldn't assume that this amount represents your personal LP Tokens balance.
|
||||
|
||||
{{ start_step("Check AMM info") }}
|
||||
<button id="check-amm-info" class="btn btn-primary previous-steps-required">Check AMM</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
{% interactive-block label="Check AMM info" steps=$frontmatter.steps %}
|
||||
|
||||
### {{n.next()}}. Check trust lines
|
||||
<button id="check-amm-info" class="btn btn-primary previous-steps-required">Check AMM</button>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
### 8. Check trust lines
|
||||
|
||||
You can also use the [account_lines method][] to get an updated view of your token balances. Your balances should be decreased by the amounts you deposited, but you now have a balance of LP Tokens that you received from the AMM.
|
||||
|
||||
@@ -245,11 +265,15 @@ The `account_lines` response shows only the tokens held by the account you looke
|
||||
|
||||
**Tip:** If one of the assets in the AMM's pool is XRP, you need to call the [account_info method][] on your account to see the difference in your balance (the `Balance` field of the account object).
|
||||
|
||||
{{ start_step("Check trust lines") }}
|
||||
{% interactive-block label="Check trust lines" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="check-trust-lines" class="btn btn-primary previous-steps-required">Check trust lines</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
## Next Steps
|
||||
|
||||
@@ -7,6 +7,7 @@ filters:
|
||||
- interactive_steps
|
||||
labels:
|
||||
- Tokens
|
||||
steps: ['Generate', 'Connect', 'Send AccountSet', 'Wait', 'Confirm Settings']
|
||||
---
|
||||
# Enable No Freeze
|
||||
|
||||
@@ -20,7 +21,8 @@ If you [issue tokens](../../concepts/tokens/index.md) in the XRP Ledger, can ena
|
||||
- You don't need to have [issued a token](issue-a-fungible-token.md) in the XRP Ledger to enable No Freeze, but the main reason you would do so is if you intend to or have already issued such a token.
|
||||
|
||||
<!-- Source for this specific tutorial's interactive bits: -->
|
||||
<script type="application/javascript" src="assets/js/tutorials/enable-no-freeze.js"></script>
|
||||
<script type="application/javascript" src="/js/interactive-tutorial.js"></script>
|
||||
<script type="application/javascript" src="/js/tutorials/enable-no-freeze.js"></script>
|
||||
|
||||
|
||||
## Example Code
|
||||
@@ -30,9 +32,8 @@ Complete sample code for all of the steps of this tutorial is available under th
|
||||
- See [Code Samples: Freeze](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/freeze/) in the source repository for this website.
|
||||
|
||||
## Steps
|
||||
{% set n = cycler(* range(1,99)) %}
|
||||
|
||||
### {{n.next()}}. Get Credentials
|
||||
### 1. Get Credentials
|
||||
|
||||
To transact on the XRP Ledger, you need an address and secret key, and some XRP. If you use the best practice of having separate ["cold" and "hot" addresses](../../concepts/accounts/account-types.md), you need the **master keys** to the _cold address_, which is the **issuer** of the token. Only the issuer's No Freeze setting has any effect on a token.
|
||||
|
||||
@@ -45,7 +46,7 @@ For this tutorial, you can get credentials from the following interface:
|
||||
When you're building production-ready software, you should use an existing account, and manage your keys using a [secure signing configuration](../../concepts/transactions/secure-signing.md).
|
||||
|
||||
|
||||
### {{n.next()}}. Connect to the Network
|
||||
### 2. Connect to the Network
|
||||
|
||||
You must be connected to the network to submit transactions to it. The following code shows how to connect to a public XRP Ledger Testnet server a supported [client library](../../references/client-libraries.md):
|
||||
|
||||
@@ -62,7 +63,7 @@ For this tutorial, click the following button to connect:
|
||||
{% partial file="/_snippets/interactive-tutorials/connect-step.md" /%}
|
||||
|
||||
|
||||
### {{n.next()}}. Send AccountSet Transaction
|
||||
### 3. Send AccountSet Transaction
|
||||
|
||||
To enable the No Freeze setting, send an [AccountSet transaction][] with a `SetFlag` field containing the [`asfNoFreeze` value (`6`)](../../references/protocol/transactions/types/accountset.md#accountset-flags). To send the transaction, you first _prepare_ it to fill out all the necessary fields, then _sign_ it with your account's secret key, and finally _submit_ it to the network.
|
||||
|
||||
@@ -96,24 +97,26 @@ For example:
|
||||
{% /tabs %}
|
||||
|
||||
|
||||
{{ start_step("Send AccountSet") }}
|
||||
{% interactive-block label="Send AccountSet" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="send-accountset" class="btn btn-primary previous-steps-required" data-wait-step-name="Wait">Send AccountSet</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending" /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
### 4. Wait for Validation
|
||||
|
||||
Most transactions are accepted into the next ledger version after they're submitted, which means it may take 4-7 seconds for a transaction's outcome to be final. If the XRP Ledger is busy or poor network connectivity delays a transaction from being relayed throughout the network, a transaction may take longer to be confirmed. (For information on how to set an expiration for transactions, see [Reliable Transaction Submission](../../concepts/transactions/reliable-transaction-submission.md).)
|
||||
|
||||
{{ start_step("Wait") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
|
||||
|
||||
### {{n.next()}}. Confirm Account Settings
|
||||
### 5. Confirm Account Settings
|
||||
|
||||
After the transaction is validated, you can check your account's settings to confirm that the No Freeze flag is enabled. You can do this by calling the [account_info method][] and checking the value of the account's `Flags` field to see if the [`lsfNoFreeze` bit (`0x00200000`)](../../references/protocol/ledger-data/ledger-entry-types/accountroot.md#accountroot-flags) is enabled.
|
||||
|
||||
@@ -168,11 +171,15 @@ Response:
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Confirm Settings") }}
|
||||
{% interactive-block label="Confirm Settings" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="confirm-settings" class="btn btn-primary previous-steps-required" data-wait-step-name="Wait">Confirm Settings</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending" /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
## See Also
|
||||
|
||||
@@ -8,6 +8,7 @@ filters:
|
||||
labels:
|
||||
- Tokens
|
||||
- Security
|
||||
steps: ['Generate', 'Connect', 'Send AccountSet (Start Freeze)', 'Wait', 'Confirm Settings', 'Send AccountSet (End Freeze)', 'Wait (again)', 'Confirm Settings (After Freeze)']
|
||||
---
|
||||
# Enact Global Freeze
|
||||
|
||||
@@ -23,7 +24,8 @@ If you [issue tokens](../../concepts/tokens/index.md) in the XRP Ledger, can ena
|
||||
- You don't need to have [issued a token](issue-a-fungible-token.md) in the XRP Ledger to enact a Global Freeze, but the main reason you would do so is if you have already issued such a token.
|
||||
|
||||
<!-- Source for this specific tutorial's interactive bits: -->
|
||||
<script type="application/javascript" src="assets/js/tutorials/enact-global-freeze.js"></script>
|
||||
<script type="application/javascript" src="/js/interactive-tutorial.js"></script>
|
||||
<script type="application/javascript" src="/js/tutorials/enact-global-freeze.js"></script>
|
||||
|
||||
## Example Code
|
||||
|
||||
@@ -32,10 +34,8 @@ Complete sample code for all of the steps of this tutorial is available under th
|
||||
- See [Code Samples: Freeze](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/freeze/) in the source repository for this website.
|
||||
|
||||
## Steps
|
||||
{% set n = cycler(* range(1,99)) %}
|
||||
|
||||
|
||||
### {{n.next()}}. Get Credentials
|
||||
### 1. Get Credentials
|
||||
|
||||
To transact on the XRP Ledger, you need an address and secret key, and some XRP. If you use the best practice of having separate ["cold" and "hot" addresses](../../concepts/accounts/account-types.md), you need the keys to the _cold address_, which is the **issuer** of the token. Only the issuer's Global Freeze setting has any effect on a token.
|
||||
|
||||
@@ -48,7 +48,7 @@ For this tutorial, you can get credentials from the following interface:
|
||||
When you're building production-ready software, you should use an existing account, and manage your keys using a [secure signing configuration](../../concepts/transactions/secure-signing.md).
|
||||
|
||||
|
||||
### {{n.next()}}. Connect to the Network
|
||||
### 2. Connect to the Network
|
||||
|
||||
You must be connected to the network to submit transactions to it. The following code shows how to connect to a public XRP Ledger Testnet server a supported [client library](../../references/client-libraries.md):
|
||||
|
||||
@@ -65,7 +65,7 @@ For this tutorial, click the following button to connect:
|
||||
{% partial file="/_snippets/interactive-tutorials/connect-step.md" /%}
|
||||
|
||||
|
||||
### {{n.next()}}. Send AccountSet Transaction to Start the Freeze
|
||||
### 3. Send AccountSet Transaction to Start the Freeze
|
||||
|
||||
To enable the Global Freeze setting, send an [AccountSet transaction][] with a `SetFlag` field containing the [`asfGlobalFreeze` value (`7`)](../../references/protocol/transactions/types/accountset.md#accountset-flags). To send the transaction, you first _prepare_ it to fill out all the necessary fields, then _sign_ it with your account's secret key, and finally _submit_ it to the network.
|
||||
|
||||
@@ -100,23 +100,29 @@ For example:
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Send AccountSet (Start Freeze)") }}
|
||||
{% interactive-block label="Send AccountSet (Start Freeze)" steps=$frontmatter.steps %}
|
||||
|
||||
<button class="btn btn-primary previous-steps-required send-accountset" data-wait-step-name="Wait" data-action="start_freeze">Send AccountSet</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
### 4. Wait for Validation
|
||||
|
||||
Most transactions are accepted into the next ledger version after they're submitted, which means it may take 4-7 seconds for a transaction's outcome to be final. If the XRP Ledger is busy or poor network connectivity delays a transaction from being relayed throughout the network, a transaction may take longer to be confirmed. (For information on how to set an expiration for transactions, see [Reliable Transaction Submission](../../concepts/transactions/reliable-transaction-submission.md).)
|
||||
|
||||
{{ start_step("Wait") }}
|
||||
{% interactive-block label="Wait" steps=$frontmatter.steps %}
|
||||
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. Confirm Account Settings
|
||||
### 5. Confirm Account Settings
|
||||
|
||||
After the transaction is validated, you can check your issuing account's settings to confirm that the Global Freeze flag is enabled. You can do this by calling the [account_info method][] and checking the value of the account's `Flags` field to see if the [`lsfGlobalFreeze` bit (`0x00400000`)](../../references/protocol/ledger-data/ledger-entry-types/accountroot.md#accountroot-flags) is on.
|
||||
|
||||
@@ -171,11 +177,15 @@ Response:
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Confirm Settings") }}
|
||||
{% interactive-block label="Confirm Settings" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="confirm-settings" class="btn btn-primary previous-steps-required">Confirm Settings</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### Intermission: While Frozen
|
||||
@@ -191,7 +201,7 @@ If you use the [No Freeze setting](../../concepts/tokens/fungible-tokens/freezes
|
||||
Otherwise, you can continue to the next step whenever you're ready.
|
||||
|
||||
|
||||
### {{n.next()}}. Send AccountSet Transaction to End the Freeze
|
||||
### 6. Send AccountSet Transaction to End the Freeze
|
||||
|
||||
To end the Global Freeze, send an [AccountSet transaction][] with a `ClearFlag` field containing the [`asfGlobalFreeze` value (`7`)](../../references/protocol/transactions/types/accountset.md#accountset-flags). As always, you first _prepare_ the transaction, _sign_ it, and finally _submit_ it to the network.
|
||||
|
||||
@@ -224,31 +234,37 @@ For example:
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Send AccountSet (End Freeze)") }}
|
||||
{% interactive-block label="Send AccountSet (End Freeze)" steps=$frontmatter.steps %}
|
||||
|
||||
<button class="btn btn-primary previous-steps-required send-accountset" data-wait-step-name="Wait (again)" data-action="end_freeze">Send AccountSet (end the freeze)</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
### 7. Wait for Validation
|
||||
|
||||
As before, wait for the previous transaction to be validated by consensus before continuing.
|
||||
|
||||
{{ start_step("Wait (again)") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" variables={label: "Wait (again)"} /%}
|
||||
|
||||
|
||||
### {{n.next()}}. Confirm Account Settings
|
||||
### 8. Confirm Account Settings
|
||||
|
||||
After the transaction is validated, you can confirm the status of the Global Freeze flag in the same way as before: by calling the [account_info method][] and checking the value of the account's `Flags` field to see if the [`lsfGlobalFreeze` bit (`0x00400000`)](../../references/protocol/ledger-data/ledger-entry-types/accountroot.md#accountroot-flags) is **off**.
|
||||
|
||||
{{ start_step("Confirm Settings (After Freeze)") }}
|
||||
{% interactive-block label="Confirm Settings (After Freeze)" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="confirm-settings-end" class="btn btn-primary previous-steps-required">Confirm Settings (After Freeze)</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
## See Also
|
||||
|
||||
@@ -8,6 +8,7 @@ filters:
|
||||
labels:
|
||||
- Tokens
|
||||
- Security
|
||||
steps: ['Generate', 'Connect', 'Choose Trust Line', 'Send TrustSet to Freeze', 'Wait', 'Check Freeze Status', 'Send TrustSet to End Freeze', 'Wait (again)']
|
||||
---
|
||||
# Freeze a Trust Line
|
||||
|
||||
@@ -25,7 +26,8 @@ This tutorial shows the steps to [freeze an individual trust line](../../concept
|
||||
- You **cannot** have enabled the [No Freeze setting](../../concepts/tokens/fungible-tokens/freezes.md#no-freeze), which gives up your ability to freeze individual trust lines.
|
||||
|
||||
<!-- Source for this specific tutorial's interactive bits: -->
|
||||
<script type="application/javascript" src="assets/js/tutorials/freeze-individual-line.js"></script>
|
||||
<script type="application/javascript" src="/js/interactive-tutorial.js"></script>
|
||||
<script type="application/javascript" src="/js/tutorials/freeze-individual-line.js"></script>
|
||||
|
||||
|
||||
## Example Code
|
||||
@@ -35,15 +37,14 @@ Complete sample code for all of the steps of this tutorial is available under th
|
||||
- See [Code Samples: Freeze](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/freeze/) in the source repository for this website.
|
||||
|
||||
## Steps
|
||||
{% set n = cycler(* range(1,99)) %}
|
||||
|
||||
### {{n.next()}}. Get Credentials
|
||||
### 1. Get Credentials
|
||||
|
||||
To transact on the XRP Ledger, you need an address and secret key, and some XRP. If you use the best practice of having separate ["cold" and "hot" addresses](../../concepts/accounts/account-types.md), you need the keys to the _cold address_, which is the **issuer** of the token.
|
||||
|
||||
{% partial file="/_snippets/interactive-tutorials/generate-step.md" /%}
|
||||
|
||||
### {{n.next()}}. Connect to the Network
|
||||
### 2. Connect to the Network
|
||||
|
||||
You must be connected to the network to submit transactions to it. The following code shows how to connect to a public XRP Ledger Testnet server a supported [client library](../../references/client-libraries.md):
|
||||
|
||||
@@ -66,7 +67,7 @@ For purposes of this tutorial, use the following interface to connect and perfor
|
||||
{% partial file="/_snippets/interactive-tutorials/connect-step.md" /%}
|
||||
|
||||
|
||||
### {{n.next()}}. Choose Trust Line
|
||||
### 3. Choose Trust Line
|
||||
|
||||
You can only freeze one trust line per transaction, so you need to know which trust line you want. Each of your trust lines is uniquely identified by these 3 things:
|
||||
|
||||
@@ -125,16 +126,18 @@ Example Request:
|
||||
|
||||
For purposes of this tutorial, a second test address has created a trust line to the test address for the currency "FOO", which you can see in the following example:
|
||||
|
||||
{{ start_step("Choose Trust Line")}}
|
||||
<div class="loader collapse" id="trust-line-setup-loader"><img class="throbber" src="assets/img/xrp-loader-96.png">Waiting for setup to complete...</div>
|
||||
{% interactive-block label="Choose Trust Line" steps=$frontmatter.steps %}
|
||||
|
||||
<div class="loader collapse" id="trust-line-setup-loader"><img class="throbber" src="/img/xrp-loader-96.png">Waiting for setup to complete...</div>
|
||||
<input type="hidden" id="peer-seed" value="" />
|
||||
<button id="look-up-trust-lines" class="btn btn-primary" disabled="disabled" title="Wait for setup to complete...">Choose Trust Line</button>
|
||||
<div class="loader loader-looking collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Looking...</div>
|
||||
<div class="loader loader-looking collapse"><img class="throbber" src="/img/xrp-loader-96.png">Looking...</div>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. Send TrustSet Transaction to Freeze the Trust Line
|
||||
### 4. Send TrustSet Transaction to Freeze the Trust Line
|
||||
|
||||
To enable or disable an Individual Freeze on a specific trust line, send a [TrustSet transaction][] with the [`tfSetFreeze` flag enabled](../../references/protocol/transactions/types/trustset.md#trustset-flags). The fields of the transaction should be as follows:
|
||||
|
||||
@@ -181,24 +184,26 @@ As always, to send a transaction, you _prepare_ it by filling in all the necessa
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Send TrustSet to Freeze") }}
|
||||
{% interactive-block label="Send TrustSet to Freeze" steps=$frontmatter.steps %}
|
||||
|
||||
<button class="btn btn-primary previous-steps-required send-trustset" data-wait-step-name="Wait" data-action="start_freeze">Send TrustSet (Freeze)</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
**Note:** If you want to freeze multiple trust lines in different currencies with the same counterparty, repeat this step for each trust line. It is possible to send several transactions in a single ledger if you use a different [sequence number](../../references/protocol/data-types/basic-data-types.md#account-sequence) for each transaction. <!--{# TODO: link rapid/batch submission guidelines when https://github.com/XRPLF/xrpl-dev-portal/issues/1025 is done #}-->
|
||||
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
### 5. Wait for Validation
|
||||
|
||||
Most transactions are accepted into the next ledger version after they're submitted, which means it may take 4-7 seconds for a transaction's outcome to be final. If the XRP Ledger is busy or poor network connectivity delays a transaction from being relayed throughout the network, a transaction may take longer to be confirmed. (For information on how to set an expiration for transactions, see [Reliable Transaction Submission](../../concepts/transactions/reliable-transaction-submission.md).)
|
||||
|
||||
{{ start_step("Wait") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
|
||||
### {{n.next()}}. Check Trust Line Freeze Status
|
||||
### 6. Check Trust Line Freeze Status
|
||||
|
||||
At this point, the trust line from the counterparty should be frozen. You can check the freeze status of any trust line using the [account_lines method][] with the following fields:
|
||||
|
||||
@@ -256,14 +261,18 @@ Example Response:
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Check Freeze Status") }}
|
||||
{% interactive-block label="Check Freeze Status" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="confirm-settings" class="btn btn-primary previous-steps-required">Check Trust Line</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Checking...</div>
|
||||
|
||||
{% loading-icon message="Checking..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. (Optional) Send TrustSet Transaction to End the Freeze
|
||||
### 7. (Optional) Send TrustSet Transaction to End the Freeze
|
||||
|
||||
If you decide that the trust line no longer needs to be frozen (for example, you investigated and decided that the suspicious activity was benign), you can end the individual freeze in almost the same way that you froze the trust line in the first place. To end an individual freeze, send a [TrustSet transaction][] with the [`tfClearFreeze` flag enabled](../../references/protocol/transactions/types/trustset.md#trustset-flags). The other fields of the transaction should be the same as when you froze the trust line:
|
||||
|
||||
@@ -310,20 +319,22 @@ As always, to send a transaction, you _prepare_ it by filling in all the necessa
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Send TrustSet to End Freeze") }}
|
||||
{% interactive-block label="Send TrustSet to End Freeze" steps=$frontmatter.steps %}
|
||||
|
||||
<button class="btn btn-primary previous-steps-required send-trustset" data-wait-step-name="Wait (again)" data-action="end_freeze">Send TrustSet (End Freeze)</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
### 8. Wait for Validation
|
||||
|
||||
As before, wait for the transaction to be validated by consensus.
|
||||
|
||||
{{ start_step("Wait (again)") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" variables={label: "Wait (again)"} /%}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ filters:
|
||||
- interactive_steps
|
||||
labels:
|
||||
- Tokens
|
||||
steps: ['Generate', 'Connect', 'Configure Issuer', 'Wait (Issuer Setup)', 'Configure Hot Address', 'Wait (Hot Address Setup)', 'Make Trust Line', 'Wait (TrustSet)', 'Send Token', 'Wait (Payment)', 'Confirm Balances']
|
||||
---
|
||||
# Issue a Fungible Token
|
||||
|
||||
@@ -24,7 +25,8 @@ Anyone can issue various types of tokens in the XRP Ledger, ranging from informa
|
||||
- You can also read along and use the interactive steps in your browser without any setup.
|
||||
|
||||
<!-- Source for this specific tutorial's interactive bits: -->
|
||||
<script type="application/javascript" src="assets/js/tutorials/issue-a-token.js"></script>
|
||||
<script type="application/javascript" src="/js/interactive-tutorial.js"></script>
|
||||
<script type="application/javascript" src="/js/tutorials/issue-a-token.js"></script>
|
||||
|
||||
## Example Code
|
||||
|
||||
@@ -33,9 +35,8 @@ Complete sample code for all of the steps of these tutorials is available under
|
||||
- See [Code Samples: Issue a Fungible Token](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/issue-a-token/) in the source repository for this website.
|
||||
|
||||
## Steps
|
||||
{% set n = cycler(* range(1,99)) %}
|
||||
|
||||
### {{n.next()}}. Get Credentials
|
||||
### 1. Get Credentials
|
||||
|
||||
To transact on the XRP Ledger, you need an address and secret key, and some XRP. You also need one or more recipients who are willing to hold the tokens you issue: unlike in some other blockchains, in the XRP Ledger you cannot force someone to hold a token they do not want.
|
||||
|
||||
@@ -44,25 +45,23 @@ The best practice is to use ["cold" and "hot" addresses](../../concepts/accounts
|
||||
In this tutorial, the hot address receives the tokens you issue from the cold address. You can get the keys for two addresses using the following interface.
|
||||
|
||||
<!-- Special version of generate-step.md for getting sender AND receiver credentials -->
|
||||
{% if use_network is undefined or use_network == "Testnet" %}
|
||||
{% set use_network = "Testnet" %}
|
||||
{% set faucet_url = "https://faucet.altnet.rippletest.net/accounts" %}
|
||||
{% elif use_network == "Devnet" %}
|
||||
{% set faucet_url = "https://faucet.devnet.rippletest.net/accounts" %}
|
||||
{# No faucet for Mainnet! #}
|
||||
{% endif %}
|
||||
{{ start_step("Generate") }}
|
||||
<button id="generate-2x-creds-button" class="btn btn-primary" data-fauceturl="{{faucet_url}}">Get {{use_network}} credentials</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Generating Keys...</div>
|
||||
|
||||
{% interactive-block label="Generate" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="generate-2x-creds-button" class="btn btn-primary" data-fauceturl="https://faucet.altnet.rippletest.net/accounts">Get Testnet credentials</button>
|
||||
|
||||
{% loading-icon message="Generating Keys..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
**Caution:** Ripple provides the [Testnet and Devnet](../../concepts/networks-and-servers/parallel-networks.md) for testing purposes only, and sometimes resets the state of these test networks along with all balances. As a precaution, **do not** use the same addresses on Testnet/Devnet and Mainnet.
|
||||
|
||||
When you're building production-ready software, you should use an existing account, and manage your keys using a [secure signing configuration](../../concepts/transactions/secure-signing.md).
|
||||
|
||||
|
||||
### {{n.next()}}. Connect to the Network
|
||||
### 2. Connect to the Network
|
||||
|
||||
You must be connected to the network to submit transactions to it. The following code shows how to connect to a public XRP Ledger Testnet server with a supported [client library](../../references/client-libraries.md):
|
||||
|
||||
@@ -90,7 +89,7 @@ For this tutorial, click the following button to connect:
|
||||
{% partial file="/_snippets/interactive-tutorials/connect-step.md" /%}
|
||||
|
||||
|
||||
### {{n.next()}}. Configure Issuer Settings
|
||||
### 3. Configure Issuer Settings
|
||||
|
||||
First, configure the settings for your cold address (which will become the issuer of your token). Most settings can be reconfigured later, with the following exceptions: <!-- STYLE_OVERRIDE: will -->
|
||||
|
||||
@@ -139,7 +138,8 @@ The following code sample shows how to send an [AccountSet transaction][] to ena
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Configure Issuer") }}
|
||||
{% interactive-block label="Configure Issuer" steps=$frontmatter.steps %}
|
||||
|
||||
<form>
|
||||
<div class="form-inline">
|
||||
<div class="input-group form-check">
|
||||
@@ -191,11 +191,14 @@ The following code sample shows how to send an [AccountSet transaction][] to ena
|
||||
</div>
|
||||
</form>
|
||||
<button id="config-issuer-button" class="btn btn-primary previous-steps-required" data-wait-step-name="Wait (Issuer Setup)">Configure issuer</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending transaction...</div>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
{% loading-icon message="Sending transaction..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
### 4. Wait for Validation
|
||||
|
||||
Most transactions are accepted into the next ledger version after they're submitted, which means it may take 4-7 seconds for a transaction's outcome to be final. You should wait for your earlier transactions to be fully validated before proceeding to the later steps, to avoid unexpected failures from things executing out of order. For more information, see [Reliable Transaction Submission](../../concepts/transactions/reliable-transaction-submission.md).
|
||||
|
||||
@@ -207,12 +210,10 @@ The code samples in this tutorial use helper functions to wait for validation wh
|
||||
|
||||
**Tip:** Technically, you can configure the hot address in parallel with configuring the issuer address. For simplicity, this tutorial waits for each transaction one at a time.
|
||||
|
||||
{{ start_step("Wait (Issuer Setup)") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" variables={label: "Wait (Issuer Setup)"} /%}
|
||||
|
||||
|
||||
### {{n.next()}}. Configure Hot Address Settings
|
||||
### 5. Configure Hot Address Settings
|
||||
|
||||
The hot address does not strictly require any settings changes from the default, but the following are recommended as best practices:
|
||||
|
||||
@@ -242,7 +243,8 @@ The following code sample shows how to send an [AccountSet transaction][] to ena
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Configure Hot Address") }}
|
||||
{% interactive-block label="Configure Hot Address" steps=$frontmatter.steps %}
|
||||
|
||||
<form>
|
||||
<div class="form-inline">
|
||||
<div class="input-group form-check">
|
||||
@@ -285,20 +287,21 @@ The following code sample shows how to send an [AccountSet transaction][] to ena
|
||||
</div>
|
||||
</form>
|
||||
<button id="config-hot-address-button" class="btn btn-primary previous-steps-required" data-wait-step-name="Wait (Hot Address Setup)">Configure hot address</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending transaction...</div>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
{% loading-icon message="Sending transaction..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
### 6. Wait for Validation
|
||||
|
||||
As before, wait for the previous transaction to be validated by consensus before continuing.
|
||||
|
||||
{{ start_step("Wait (Hot Address Setup)") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" variables={label: "Wait (Hot Address Setup)"} /%}
|
||||
|
||||
|
||||
### {{n.next()}}. Create Trust Line from Hot to Cold Address
|
||||
### 7. Create Trust Line from Hot to Cold Address
|
||||
|
||||
Before you can receive tokens, you need to create a [trust line](../../concepts/tokens/fungible-tokens/index.md) to the token issuer. This trust line is specific to the [currency code](../../references/protocol/data-types/currency-formats.md#currency-codes) of the token you want to issue, such as USD or FOO. You can choose any currency code you want; each issuer's tokens are treated as separate in the XRP Ledger protocol. However, users' balances of tokens with the same currency code can [ripple](../../concepts/tokens/fungible-tokens/rippling.md) between different issuers if the users enable rippling settings.
|
||||
|
||||
@@ -335,7 +338,8 @@ The following code sample shows how to send a [TrustSet transaction][] from the
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Make Trust Line") }}
|
||||
{% interactive-block label="Make Trust Line" steps=$frontmatter.steps %}
|
||||
|
||||
<form>
|
||||
<p>Currency code:</p>
|
||||
<div class="container">
|
||||
@@ -368,23 +372,24 @@ The following code sample shows how to send a [TrustSet transaction][] from the
|
||||
</div>
|
||||
</form>
|
||||
<button id="create-trust-line-button" class="btn btn-primary previous-steps-required" data-wait-step-name="Wait (TrustSet)">Create Trust Line</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending transaction...</div>
|
||||
|
||||
{% loading-icon message="Sending transaction..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
**Note:** If you use [Authorized Trust Lines][], there is an extra step after this one: the cold address must approve the trust line from the hot address. For details of how to do this, see [Authorizing Trust Lines](../../concepts/tokens/fungible-tokens/authorized-trust-lines.md#authorizing-trust-lines).
|
||||
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
### 8. Wait for Validation
|
||||
|
||||
As before, wait for the previous transaction to be validated by consensus before continuing.
|
||||
|
||||
{{ start_step("Wait (TrustSet)") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" variables={label: "Wait (TrustSet)"} /%}
|
||||
|
||||
|
||||
### {{n.next()}}. Send Token
|
||||
### 9. Send Token
|
||||
|
||||
Now you can create tokens by sending a [Payment transaction][] from the cold address to the hot address. This transaction should have the following attributes (dot notation indicates nested fields):
|
||||
|
||||
@@ -421,7 +426,8 @@ The following code sample shows how to send a [Payment transaction][] to issue 8
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Send Token") }}
|
||||
{% interactive-block label="Send Token" steps=$frontmatter.steps %}
|
||||
|
||||
<form>
|
||||
<div class="form-inline mt-2">
|
||||
<div class="input-group">
|
||||
@@ -445,21 +451,22 @@ The following code sample shows how to send a [Payment transaction][] to issue 8
|
||||
</div>
|
||||
</form>
|
||||
<button id="send-token-button" class="btn btn-primary previous-steps-required" data-wait-step-name="Wait (Payment)">Send Token</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending transaction...</div>
|
||||
|
||||
{% loading-icon message="Sending transaction..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
### 10. Wait for Validation
|
||||
|
||||
As before, wait for the previous transaction to be validated by consensus before continuing.
|
||||
|
||||
{{ start_step("Wait (Payment)") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" variables={label: "Wait (Payment)"} /%}
|
||||
|
||||
|
||||
### {{n.next()}}. Confirm Token Balances
|
||||
### 11. Confirm Token Balances
|
||||
|
||||
You can check the balances of your token from the perspective of either the token issuer or the hot address. Tokens issued in the XRP Ledger always have balances that sum to 0: negative from the perspective of the issuer and positive from the perspective of the holder.
|
||||
|
||||
@@ -487,11 +494,15 @@ The following code sample shows how to use both methods:
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
{{ start_step("Confirm Balances") }}
|
||||
{% interactive-block label="Confirm Balances" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="confirm-balances-button" class="btn btn-primary previous-steps-required">Confirm Balances</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Checking...</div>
|
||||
|
||||
{% loading-icon message="Checking..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### Next Steps
|
||||
|
||||
@@ -7,6 +7,7 @@ filters:
|
||||
labels:
|
||||
- Decentralized Exchange
|
||||
- Tokens
|
||||
steps: ['Connect', 'Generate', 'Look Up Offers',' Send OfferCreate', 'Wait', 'Check Metadata', 'Check Balances and Offers']
|
||||
---
|
||||
# Trade in the Decentralized Exchange
|
||||
|
||||
@@ -21,8 +22,9 @@ This tutorial demonstrates how you can buy and sell tokens in the [decentralized
|
||||
- You can also read along and use the interactive steps in your browser without any setup.
|
||||
|
||||
<!-- Source for this specific tutorial's interactive bits: -->
|
||||
<script type="application/javascript" src="/js/interactive-tutorial.js"></script>
|
||||
<script src='https://cdn.jsdelivr.net/npm/bignumber.js@9.0.2/bignumber.min.js'></script>
|
||||
<script type="application/javascript" src="assets/js/tutorials/trade-in-the-dex.js"></script>
|
||||
<script type="application/javascript" src="/js/tutorials/trade-in-the-dex.js"></script>
|
||||
|
||||
## Example Code
|
||||
|
||||
@@ -32,7 +34,6 @@ Complete sample code for all of the steps of this tutorial is available under th
|
||||
|
||||
|
||||
## Steps
|
||||
{% set n = cycler(* range(1,99)) %}
|
||||
|
||||
This tutorial demonstrates how to buy a fungible token in the decentralized exchange by selling XRP. (Other types of trades are possible, but selling a token, for example, requires you to have it first.) The example token used in this tutorial is as follows:
|
||||
|
||||
@@ -41,7 +42,7 @@ This tutorial demonstrates how to buy a fungible token in the decentralized exch
|
||||
| TST | `rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd` | A test token pegged to XRP at a rate of approximately 10 XRP per 1 TST. The issuer has existing Offers on the XRP Ledger Testnet to buy and sell these tokens. |
|
||||
|
||||
|
||||
### {{n.next()}}. Connect to Network
|
||||
### 1. Connect to Network
|
||||
|
||||
You must be connected to the network to submit transactions to it. Additionally, some languages (including JavaScript) require a high-precision number library for performing calculations on currency amounts you may find in the ledger. The following code shows how to connect to a public XRP Ledger Testnet server a supported [client library](../../references/client-libraries.md) with the appropriate dependencies.
|
||||
|
||||
@@ -63,7 +64,7 @@ For this tutorial, click the following button to connect:
|
||||
|
||||
{% partial file="/_snippets/interactive-tutorials/connect-step.md" /%}
|
||||
|
||||
### {{n.next()}}. Get Credentials
|
||||
### 2. Get Credentials
|
||||
|
||||
To transact on the XRP Ledger, you need an address, a secret key, and some XRP. For development purposes, you can get these on the [{{use_network}}](../../concepts/networks-and-servers/parallel-networks.md) using the following interface:
|
||||
|
||||
@@ -83,7 +84,7 @@ When you're building production-ready software, you should use an existing accou
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
### {{n.next()}}. Look Up Offers
|
||||
### 7. Look Up Offers
|
||||
|
||||
Before you buy or sell a token, you usually want to look up what others are buying and selling for, to get a sense of how others value it. In the XRP Ledger, you can look up existing offers for any currency pair using the [book_offers method][].
|
||||
|
||||
@@ -107,7 +108,8 @@ The following code shows how to look up existing Offers and compare them to a pr
|
||||
|
||||
The following block demonstrates these calculations in action:
|
||||
|
||||
{{ start_step("Look Up Offers") }}
|
||||
{% interactive-block label="Look Up Offers" steps=$frontmatter.steps %}
|
||||
|
||||
<form>
|
||||
<h5>TakerPays</h5>
|
||||
<div class="form-group row">
|
||||
@@ -146,11 +148,14 @@ The following block demonstrates these calculations in action:
|
||||
</div>
|
||||
</form>
|
||||
<button id="look-up-offers" class="btn btn-primary previous-steps-required">Look Up Offers</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Querying...</div>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
### {{n.next()}}. Send OfferCreate Transaction
|
||||
{% loading-icon message="Querying..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
### 3. Send OfferCreate Transaction
|
||||
|
||||
To actually make a trade, send an [OfferCreate transaction][]. In this case, you want to buy TST using XRP, so you should set the parameters as follows:
|
||||
|
||||
@@ -175,21 +180,24 @@ The following code shows how to prepare, sign, and submit the transaction:
|
||||
|
||||
You can use this interface to send the transaction specified by the amounts in the previous step:
|
||||
|
||||
{{ start_step("Send OfferCreate") }}
|
||||
<button id="send-offercreate" class="btn btn-primary previous-steps-required" data-wait-step-name="Wait">Send OfferCreate</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Sending...</div>
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
{% interactive-block label="Send OfferCreate" steps=$frontmatter.steps %}
|
||||
|
||||
### {{n.next()}}. Wait for Validation
|
||||
<button id="send-offercreate" class="btn btn-primary previous-steps-required" data-wait-step-name="Wait">Send OfferCreate</button>
|
||||
|
||||
{% loading-icon message="Sending..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
### 4. Wait for Validation
|
||||
|
||||
Most transactions are accepted into the next ledger version after they're submitted, which means it may take 4-7 seconds for a transaction's outcome to be final. If the XRP Ledger is busy or poor network connectivity delays a transaction from being relayed throughout the network, a transaction may take longer to be confirmed. (For information on how to set an expiration for transactions, see [Reliable Transaction Submission](../../concepts/transactions/reliable-transaction-submission.md).)
|
||||
|
||||
{{ start_step("Wait") }}
|
||||
{% partial file="/_snippets/interactive-tutorials/wait-step.md" /%}
|
||||
{{ end_step() }}
|
||||
|
||||
### {{n.next()}}. Check Metadata
|
||||
|
||||
### 5. Check Metadata
|
||||
|
||||
You can use the validated transaction's [metadata](../../references/protocol/transactions/metadata.md) to determine exactly what it did. (Don't use metadata from tentative transaction results, because it may be different from the [final result](../../concepts/transactions/finality-of-results/index.md), especially when using the decentralized exchange.) In case of an OfferCreate transaction, likely results include:
|
||||
|
||||
@@ -213,14 +221,18 @@ The following code demonstrates how to check the metadata of the transaction:
|
||||
|
||||
You can use this interface to test it out:
|
||||
|
||||
{{ start_step("Check Metadata") }}
|
||||
{% interactive-block label="Check Metadata" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="check-metadata" class="btn btn-primary previous-steps-required">Check Metadata</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Checking...</div>
|
||||
|
||||
{% loading-icon message="Checking..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
|
||||
{% /interactive-block %}
|
||||
|
||||
|
||||
### {{n.next()}}. Check Balances and Offers
|
||||
### 6. Check Balances and Offers
|
||||
|
||||
This is also a good time to look up the balances and outstanding Offers owned by your account as of the latest validated ledger. This shows any changes caused by your transaction as well as any others that executed in the same ledger version.
|
||||
|
||||
@@ -240,10 +252,13 @@ The following code demonstrates how to look up balances using the [account_lines
|
||||
|
||||
You can use this interface to test it out:
|
||||
|
||||
{{ start_step("Check Balances and Offers") }}
|
||||
{% interactive-block label="Check Balances and Offers" steps=$frontmatter.steps %}
|
||||
|
||||
<button id="check-balances-and-offers" class="btn btn-primary previous-steps-required">Check Balances and Offers</button>
|
||||
<div class="loader collapse"><img class="throbber" src="assets/img/xrp-loader-96.png">Checking...</div>
|
||||
|
||||
{% loading-icon message="Checking..." /%}
|
||||
|
||||
<div class="output-area"></div>
|
||||
{{ end_step() }}
|
||||
{% /interactive-block %}
|
||||
|
||||
{% raw-partial file="/_snippets/common-links.md" /%}
|
||||
|
||||
Reference in New Issue
Block a user