mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 20:25:51 +00:00
xrpl.js 2.0 edits per review, more cleanup
This commit is contained in:
@@ -13,7 +13,7 @@ labels:
|
||||
|
||||
WebSocketは、クライアントとサーバーが1つの接続を確立し、その接続を経由して両方向にメッセージを送信するモデルに従います。この接続は、明示的に閉じる(または接続に障害が発生する)まで続きます。これは、要求ごとにクライアントが新しい接続を開いて閉じるHTTPベースのAPIモデル(JSON-RPCやRESTful APIなど)とは対照的です[¹](#footnote-1)<a id="from-footnote-1"></a>。
|
||||
|
||||
**ヒント:** このページの例はJavaScriptを使用しているため、Webブラウザーでネイティブに実行できます。JavaScriptで開発している場合は、[JavaScript向けRippleAPIライブラリ](https://js.xrpl.org/)も利用すると、一部の作業を簡素化できます。このチュートリアルでは、RippleAPIを使用できないその他のプログラミング言語にステップを適合できるよう、xrpl.jsを使用 _しない_ でトランザクションを監視する方法を説明します。
|
||||
**ヒント:** このページの例はJavaScriptを使用しているため、Webブラウザーでネイティブに実行できます。JavaScriptで開発している場合は、[JavaScript向けxrpl.jsライブラリ](https://js.xrpl.org/)も利用すると、一部の作業を簡素化できます。このチュートリアルでは、xrpl.jsを使用できないその他のプログラミング言語にステップを適合できるよう、xrpl.jsを使用 _しない_ でトランザクションを監視する方法を説明します。
|
||||
|
||||
## 前提条件
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ labels:
|
||||
---
|
||||
# 宛先タグの要求
|
||||
|
||||
`RequireDest`設定(RippleAPIの`requireDestinationTag`)は、送金先を識別する[宛先タグ](source-and-destination-tags.html)を顧客が付け忘れている場合にあなたのアドレスに[送金](payment-types.html)できないようにするためのものです。有効にすると、XRP Ledgerは宛先タグが付いていないあなたのアドレスへの送金を拒否します。
|
||||
`RequireDest`設定は、送金先を識別する[宛先タグ](source-and-destination-tags.html)を顧客が付け忘れている場合にあなたのアドレスに[送金](payment-types.html)できないようにするためのものです。有効にすると、XRP Ledgerは宛先タグが付いていないあなたのアドレスへの送金を拒否します。
|
||||
|
||||
以下は、ローカルでホストされている`rippled`の[submitメソッド][]を使用して、`RequireDest`フラグを有効にする[AccountSetトランザクション][]を送信する例です。
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ _(Requires the [TicketBatch amendment][] :not_enabled:)_
|
||||
<script type="application/javascript" src="assets/js/tutorials/use-tickets.js"></script>
|
||||
{% set use_network = "Devnet" %}<!--TODO: change to Testnet eventually -->
|
||||
|
||||
This page provides JavaScript examples that use the ripple-lib (RippleAPI) library. The [RippleAPI Beginners Guide](get-started-with-rippleapi-for-javascript.html) describes how to get started using RippleAPI to access XRP Ledger data from JavaScript.
|
||||
This page provides JavaScript examples that use the [xrpl.js](https://js.xrpl.org/) library. See [Get Started Using JavaScript](get-started-using-javascript.html) for setup instructions.
|
||||
|
||||
Since JavaScript works in the web browser, you can read along and use the interactive steps without any setup.
|
||||
|
||||
@@ -133,8 +133,6 @@ _JavaScript_
|
||||
|
||||
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](reliable-transaction-submission.html).)
|
||||
|
||||
You use the `ledger` event type in RippleAPI to trigger your code to run whenever there is a new validated ledger version. For example:
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
_JavaScript_
|
||||
|
||||
@@ -49,7 +49,6 @@ To enable gRPC on your server, complete the following steps:
|
||||
- [Software Ecosystem](software-ecosystem.html)
|
||||
- [Parallel Networks](parallel-networks.html)
|
||||
- **Tutorials:**
|
||||
- [Get Started with RippleAPI for JavaScript](get-started-with-rippleapi-for-javascript.html)
|
||||
- [Reliable Transaction Submission](reliable-transaction-submission.html)
|
||||
- [Manage the rippled Server](manage-the-rippled-server.html)
|
||||
- **References:**
|
||||
|
||||
@@ -44,8 +44,8 @@ To enable public signing, perform the following steps:
|
||||
- [Cryptographic Keys](cryptographic-keys.html)
|
||||
- **Tutorials:**
|
||||
- [Set Up Secure Signing](set-up-secure-signing.html)
|
||||
- [Get Started with the rippled API](get-started-using-http-websocket-apis.html)
|
||||
- [Get Started with RippleAPI for JavaScript](get-started-with-rippleapi-for-javascript.html)
|
||||
- [Get Started Using HTTP / WebSocket APIs](get-started-using-http-websocket-apis.html)
|
||||
- [Get Started Using JavaScript](get-started-using-javascript.html)
|
||||
- **References:**
|
||||
- [sign method][]
|
||||
- [sign_for method][]
|
||||
|
||||
@@ -84,14 +84,30 @@ Rippleが公開したものでないクライアントライブラリを使用
|
||||
|
||||
最高レベルのセキュリティを実現するために、クライアントライブラリを安定した最新バージョンの状態に保ってください。
|
||||
|
||||
### RippleAPIを使用したローカル署名の例
|
||||
### クライアントライブラリを使用したローカル署名の例
|
||||
|
||||
以下のサンプルコードは、RippleAPI for JavaScriptを使用してトランザクションの指示にローカルで署名する方法を示しています。
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
*JavaScript*
|
||||
|
||||
```js
|
||||
{% include '_code-samples/secure-signing/js/signPayment.js' %}
|
||||
```
|
||||
|
||||
*Python*
|
||||
|
||||
```py
|
||||
{% include '_code-samples/secure-signing/py/sign-payment.py' %}
|
||||
```
|
||||
|
||||
*Java*
|
||||
|
||||
```java
|
||||
{% include '_code-samples/secure-signing/java/SignPayment.java' %}
|
||||
```
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
|
||||
セキュリティを強化するために、[Vault](https://www.vaultproject.io/)などの管理ツールから秘密鍵を読み込みます。
|
||||
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ To optimize the security of your signing library:
|
||||
|
||||
Here are examples of how to sign transaction instructions locally using the following languages and libraries:
|
||||
|
||||
* **JavaScript** / **TypeScript** - [`ripple-lib`](https://github.com/XRPLF/xrpl.js)
|
||||
* **JavaScript** / **TypeScript** - [`xrpl.js`](https://github.com/XRPLF/xrpl.js)
|
||||
|
||||
* **Python** - [`xrpl-py`](https://github.com/XRPLF/xrpl-py)
|
||||
|
||||
|
||||
@@ -22,9 +22,8 @@ _[Checks Amendment][]が必要です。_
|
||||
- 現在レジャーに記録されているCheckオブジェクトのIDが必要です。
|
||||
- たとえばこのチュートリアルの例では、IDが`49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0`のCheckを取り消しますが、この手順を自身で実行する場合は異なるIDを使用する必要があります。
|
||||
- CheckCancelトランザクションを送信する資金供給のあるアカウントの**アドレス**と**シークレットキー**。Checkが有効期限切れでない限り、このアドレスは、Checkの送金元または受取人のいずれかでなければなりません。
|
||||
- トランザクションに安全に署名できる手段([RippleAPI][]や各自の[`rippled`サーバー](install-rippled.html)など)。
|
||||
- `rippled`サーバーに接続できるクライアントライブラリ([RippleAPI][]、HTTPライブラリ、またはWebSocketライブラリなど)。
|
||||
- 詳細は、[`rippled` APIの使用開始](get-started-using-http-websocket-apis.html)を参照してください。
|
||||
- トランザクションに[安全に署名できる手段](set-up-secure-signing.html)。
|
||||
- [クライアントライブラリ](client-libraries.html)またはHTTPライブラリ、WebSocketライブラリなど。
|
||||
|
||||
|
||||
## {{cancel_n.next()}}.CheckCancelトランザクションの準備
|
||||
|
||||
@@ -26,9 +26,8 @@ To send a Check with this tutorial, you need the following:
|
||||
- The **address** and **secret key** of a funded account to send the Check from.
|
||||
- You can use the [XRP Ledger Test Net Faucet](xrp-test-net-faucet.html) to get a funded address and secret with 10,000 Test Net XRP.
|
||||
- The **address** of a funded account to receive the Check.
|
||||
- A secure way to sign transactions, such as [RippleAPI][] or your own [`rippled` server](install-rippled.html).
|
||||
- A client library that can connect to a `rippled` server, such as [RippleAPI][] or any HTTP or WebSocket library.
|
||||
- For more information, see [Get Started with the `rippled` API](get-started-using-http-websocket-apis.html).
|
||||
- A [secure way to sign transactions](set-up-secure-signing.html).
|
||||
- A [client library](client-libraries.html) or any HTTP or WebSocket library.
|
||||
|
||||
## {{send_n.next()}}. Prepare the CheckCreate transaction
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ Anyone can issue various types of tokens in the XRP Ledger, ranging from informa
|
||||
- Each address needs enough XRP to satisfy the [reserve requirement](reserves.html) including the additional reserve for a trust line.
|
||||
- You need a connection to the XRP Ledger network. As shown in this tutorial, you can use public servers for testing.
|
||||
- You should be familiar with the Getting Started instructions for your preferred client library. This page provides examples for the following:
|
||||
- ripple-lib for JavaScript [(Node.js)](get-started-with-rippleapi-for-javascript.html) or [in-browser](get-started.html)
|
||||
- [xrpl-py for Python](get-started-using-python.html)
|
||||
- [xrpl4j for Java](get-started-using-java.html).
|
||||
- **JavaScript** with the [xrpl.js library](https://github.com/XRPLF/xrpl.js/). See [Get Started Using JavaScript](get-started-using-javascript.html) for setup steps.
|
||||
- **Python** with the [`xrpl-py` library](https://xrpl-py.readthedocs.io/). See [Get Started using Python](get-started-using-python.html) for setup steps.
|
||||
- **Java** with the [xrpl4j library](https://github.com/XRPLF/xrpl4j). See [Get Started Using Java](get-started-using-java.html) for setup steps.
|
||||
- You can also read along and use the interactive steps in your browser without any setup.
|
||||
|
||||
<!-- Source for this specific tutorial's interactive bits: -->
|
||||
|
||||
@@ -463,7 +463,7 @@ To confirm that an address has Default Ripple enabled, look up the address using
|
||||
|
||||
## Disallow XRP
|
||||
|
||||
The Disallow XRP setting (`disallowIncomingXRP` in RippleAPI) is designed to discourage XRP Ledger users from sending XRP to an address by accident. This reduces the costs and effort of bouncing undesired payments, if your gateway does not trade XRP. The Disallow XRP flag is not strictly enforced, because doing so could allow addresses to become permanently unusable if they run out of XRP. Client applications should honor the Disallow XRP flag by default.
|
||||
The Disallow XRP setting is designed to discourage XRP Ledger users from sending XRP to an address by accident. This reduces the costs and effort of bouncing undesired payments, if your gateway does not trade XRP. The Disallow XRP flag is not strictly enforced, because doing so could allow addresses to become permanently unusable if they run out of XRP. Client applications should honor the Disallow XRP flag by default.
|
||||
|
||||
An issuing gateway that does not trade XRP should enable the Disallow XRP flag on the gateway's issuing and operational addresses. A private exchange that trades in XRP should only enable the Disallow XRP flag on addresses that are not expected to receive XRP.
|
||||
|
||||
@@ -599,7 +599,7 @@ To robustly check for incoming payments, gateways should do the following:
|
||||
* Check the result code of every incoming payment. Some payments go into the ledger to charge an anti-spam fee, even though they failed. Only transactions with the result code `tesSUCCESS` can change non-XRP balances. Only transactions from a validated ledger are final.
|
||||
* [Look out for Partial Payments](https://ripple.com/files/GB-2014-06.pdf "Partial Payment Flag Gateway Bulletin"). Payments with the partial-payment flag enabled can be considered "successful" if any non-zero amount is delivered, even miniscule amounts.
|
||||
* In `rippled`, check the transaction for a `meta.delivered_amount` field. If present, that field indicates how much money *actually* got delivered to the `Destination` address.
|
||||
* In RippleAPI, you can search the `outcome.BalanceChanges` field to see how much the destination address received. In some cases, this can be divided into multiple parts on different trust lines.
|
||||
* In xrpl.js, you can use the [`xrpl.getBalanceChanges()` method](https://js.xrpl.org/modules.html#getBalanceChanges) to see how much each address received. In some cases, this can be divided into multiple parts on different trust lines.
|
||||
* Some transactions change your balances without being payments directly to or from one of your addresses. For example, if ACME sets a nonzero [transfer fee](#transfer-fees), then ACME's issuing address's outstanding obligations decrease each time Bob and Charlie exchange ACME's issued currencies. See [Transfer Fees](#transfer-fees) for more information.
|
||||
|
||||
To make things simpler for your customers, we recommend accepting payments to either operational addresses and issuing addresses.
|
||||
@@ -612,7 +612,7 @@ As an added precaution, we recommend comparing the balances of your issuing addr
|
||||
|
||||
## Transfer Fees
|
||||
|
||||
The `TransferRate` setting (`transferRate` in RippleAPI) defines a fee to charge for transferring issued currencies from one XRP Ledger address to another. See [Transfer Fees](transfer-fees.html) for more information.
|
||||
The `TransferRate` setting defines a fee to charge for transferring issued currencies from one XRP Ledger address to another. See [Transfer Fees](transfer-fees.html) for more information.
|
||||
|
||||
The following is an example of using a locally-hosted `rippled`'s [submit method][] to send an AccountSet transaction for the issuing address `rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW`, setting the `TransferRate` to charge a fee of 0.5%.
|
||||
|
||||
@@ -665,8 +665,7 @@ Response:
|
||||
|
||||
All XRP Ledger addresses, including operational and standby addresses, are subject to the issuer's transfer fees when sending issued currency. If you set a nonzero transfer fee, then you must send extra (to pay the transfer fee) when making payments from your operational address or standby address. In other words, your addresses must pay back a little of the balance your issuing address created, each time you make a payment.
|
||||
|
||||
* In `rippled`'s APIs, you should set the [`SendMax` transaction parameter][Payment] higher than the destination `Amount` parameter.
|
||||
* In RippleAPI, you should set the `source.maxAmount` parameter higher than the `destination.amount` parameter; or, set the `source.amount` parameter higher than the `destination.minAmount` parameter.
|
||||
Set the [`SendMax` transaction parameter][Payment] higher than the destination `Amount` parameter by a percentage based on the `TransferRate` setting.
|
||||
|
||||
**Note:** Transfer fees do not apply when sending issued currencies directly to the issuing address. The issuing address must always accept its issued currencies at face value in the XRP Ledger. This means that customers don't have to pay the transfer fee if they send payments to the issuing address directly, but they do when sending to an operational address. If you accept payments at both addresses, you may want to adjust the amount you credit customers in your system of record when customers send payments to the operational address, to compensate for the transfer fee the customer pays.
|
||||
|
||||
@@ -775,7 +774,7 @@ The goal of reliably submitting transactions is to achieve the following two pro
|
||||
To submit transactions reliably, follow these guidelines:
|
||||
|
||||
* Persist details of the transaction before submitting it.
|
||||
* Use the `LastLedgerSequence` parameter. (RippleAPI does this by default.)
|
||||
* Use the `LastLedgerSequence` parameter. (Many [client libraries](client-libraries.html) do this by default.)
|
||||
* Resubmit a transaction if it has not appeared in a validated ledger whose [ledger index][] is less than or equal to the transaction's `LastLedgerSequence` parameter.
|
||||
|
||||
For more information, see [Reliable Transaction Submission](reliable-transaction-submission.html).
|
||||
|
||||
Reference in New Issue
Block a user