Skip to content

Commit fdbac63

Browse files
committed
Docs: more on basic types, tx types
1 parent ef25155 commit fdbac63

File tree

4 files changed

+70
-34
lines changed

4 files changed

+70
-34
lines changed

docs/index.md

+35-17
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ If you omit the "catch" section, errors may not be visible.
108108

109109
1. Install [NodeJS](https://nodejs.org) and the Node Package Manager (npm). Most Linux distros have a package for NodeJS, but make sure you have version `0.12.0` or higher.
110110
2. Use npm to install [Babel](https://babeljs.io/) globally:
111-
npm install -g babel
111+
`npm install -g babel`
112112
3. Use npm to install RippleAPI:
113-
npm install ripple-lib
113+
`npm install ripple-lib`
114114

115115
After you have installed ripple-lib, you can create scripts using the [boilerplate](#boilerplate) and run them using babel-node:
116-
babel-node script.js
116+
`babel-node script.js`
117117

118118
<aside class="notice">
119119
Instead of using babel-node in production, we recommend using Babel to transpile to ECMAScript 5 first.
@@ -128,23 +128,28 @@ Instead of using babel-node in production, we recommend using Babel to transpile
128128
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
129129
```
130130

131-
Every Ripple account has an *address*, which is a base58-encoding of a hash of the account's public key.
131+
Every Ripple account has an *address*, which is a base58-encoding of a hash of the account's public key. Ripple addresses always start with the lowercase letter `r`.
132132

133133
## Account Sequence Number
134134

135-
Every Ripple account has a *sequence number* that is used to order transactions. Every transaction must have a sequence number and transaction can only be executed in order by sequence number. This prevents one transaction from executing twice and transactions executing out of order. The sequence number starts at `1` and increments for each transaction that the account makes.
135+
Every Ripple account has a *sequence number* that is used to keep transactions in order. Every transaction must have a sequence number. A transaction can only be executed if it has the next sequence number in order, of the account sending it. This prevents one transaction from executing twice and transactions executing out of order. The sequence number starts at `1` and increments for each transaction that the account makes.
136136

137137
## Currency
138138

139139
Currencies are represented as either 3-character currency codes or 40-character uppercase hexadecimal strings. We recommend using uppercase [ISO 4217 Currency Codes](http://www.xe.com/iso4217.php) only. The string "XRP" is disallowed on trustlines because it is reserved for the Ripple native currency. The following characters are permitted: all uppercase and lowercase letters, digits, as well as the symbols `?`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `<`, `>`, `(`, `)`, `{`, `}`, `[`, `]`, and `|`.
140140

141141
## Value
142-
A *value* is a quantity of a currency represented as a decimal string (string encoding is used because javascript numbers do not have sufficient precision).
142+
A *value* is a quantity of a currency represented as a decimal string. Be careful: JavaScript's native number format does not have sufficient precision to represent all values. XRP has different precision from other currencies.
143+
144+
**XRP** has 6 significant digits past the decimal point. In other words, XRP cannot be divided into positive values smaller than `0.000001` (1e-6). XRP has a maximum value of `100000000000` (1e11).
145+
146+
**Non-XRP values** have 15 decimal digits of precision, with a maximum value of `9999999999999999e80`. The smallest positive non-XRP value is `1e-81`.
143147

144-
An XRP value has 6 significant digits past the decimal point. A non-XRP value has 16 total digits of precision.
145148

146149
## Amount
147150

151+
Example amount:
152+
148153
```json
149154
{
150155
"currency": "USD",
@@ -153,14 +158,15 @@ An XRP value has 6 significant digits past the decimal point. A non-XRP value ha
153158
}
154159
```
155160

161+
Example XRP amount:
156162
```json
157163
{
158164
"currency": "XRP",
159165
"value": "2000"
160166
}
161167
```
162168

163-
An *amount* is data structure representing a currency, a quantity of that currency, and the counterparty on the trustline that holds the value (for all currencies besides "XRP").
169+
An *amount* is data structure representing a currency, a quantity of that currency, and the counterparty on the trustline that holds the value. For XRP, there is no counterparty.
164170

165171
A *lax amount* allows the counterparty to be omitted for all currencies. If the counterparty is not specified in an amount within a transaction specification, then any counterparty may be used for that amount.
166172

@@ -182,7 +188,7 @@ A transaction type is specified by the strings in the first column in the table
182188

183189
Type | Description
184190
---- | -----------
185-
[payment](#payment) | A `payment` transaction represents a transfer of value from one account to another. Depending on the path taken, additional exchanges of value may occur atomically to facilitate the payment.
191+
[payment](#payment) | A `payment` transaction represents a transfer of value from one account to another. Depending on the [path](https://ripple.com/build/paths/) taken, additional exchanges of value may occur atomically to facilitate the payment.
186192
[order](#order) | An `order` transaction creates a limit order. It defines an intent to exchange currencies, and creates an order in the Ripple Consensus Ledger's order book if not completely fulfilled when placed. Orders can be partially fulfilled.
187193
[orderCancellation](#order-cancellation) | An `orderCancellation` transaction cancels an order in the Ripple Consensus Ledger's order book.
188194
[trustline](#trustline) | A `trustline` transactions creates or modifies a trust line between two accounts.
@@ -195,20 +201,28 @@ Type | Description
195201

196202
Executing a transaction with `RippleAPI` requires the following four steps:
197203

198-
1. prepare - Create an unsigned transaction based on a [specification](#transaction-specifications) and [instructions](#transaction-instructions).
199-
2. sign - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place.
200-
3. submit - Submit the transaction to the connected server.
201-
4. verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted. It is recommended that you specify a `maxLedgerVersion` in the instructions when preparing a transaction because without it there is no way to know that a failed transaction will never succeeed in the future. It is impossible for a transaction to succeed after the network ledger version exceeds the `maxLedgerVersion` provided in the transaction instructions.
204+
1. Prepare - Create an unsigned transaction based on a [specification](#transaction-specifications) and [instructions](#transaction-instructions). There is a method to prepare each type of transaction:
205+
* [preparePayment](#preparepayment)
206+
* [prepareTrustline](#preparetrustline)
207+
* [prepareOrder](#prepareorder)
208+
* [prepareOrderCancellation](#prepareordercancellation)
209+
* [prepareSettings](#preparesettings)
210+
* [prepareSuspendedPaymentCreation](#preparesuspendedpaymentcreation)
211+
* [prepareSuspendedPaymentCancellation](#preparesuspendedpaymentcancellation)
212+
* [prepareSuspendedPaymentExecution](#preparesuspendedpaymentexecution)
213+
2. [Sign](#sign) - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place.
214+
3. [Submit](#submit) - Submit the transaction to the connected server.
215+
4. Verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted.
202216

203217
## Transaction Fees
204218

205-
Every transaction requires a *fee* to be paid in XRP. The fee is destroyed; it is not sent to any other party. The purpose of the fee is to prevent denial of service attacks on the Ripple network.
219+
Every transaction must destroy a small amount of XRP as a cost to send the transaction. This is also called a *transaction fee*. The transaction cost is designed to increase along with the load on the Ripple network, making it very expensive to deliberately or inadvertently overload the network.
206220

207-
You can choose the size of the fee you want to pay or let a default be used. The fee is like a bid in an auction for slots in the next ledger closing. If the fee you choose is too low, your transaction will not be included in the next ledger closing. You can get an estimate of the fee required to be included in the next ledger closing with the [getFee](#getfee) method.
221+
You can choose the size of the fee you want to pay or let a default be used. You can get an estimate of the fee required to be included in the next ledger closing with the [getFee](#getfee) method.
208222

209223
## Transaction Instructions
210224

211-
Transactions instructions indicates how to execute a transaction, complementary with the [transaction specification](#transaction-specifications).
225+
Transaction instructions indicate how to execute a transaction, complementary with the [transaction specification](#transaction-specifications).
212226

213227
Name | Type | Description
214228
---- | ---- | -----------
@@ -218,13 +232,17 @@ maxLedgerVersion | integer | *Optional* The highest ledger version that the tran
218232
maxLedgerVersionOffset | integer | *Optional* Offset from current legder version to highest ledger version that the transaction can be included in.
219233
sequence | [sequence](#account-sequence-number) | *Optional* The initiating account's sequence number for this transaction.
220234

235+
We recommended that you specify a `maxLedgerVersion` because without it there is no way to know that a failed transaction will never succeeed in the future. It is impossible for a transaction to succeed after the network ledger version exceeds the transaction's `maxLedgerVersion`.
236+
221237
## Transaction ID
222238

223239
```json
224240
"F4AB442A6D4CBB935D66E1DA7309A5FC71C7143ED4049053EC14E3875B0CF9BF"
225241
```
226242

227-
A hash of the transaction that can be used to identify it. A transaction can be looked up by its ID using the [getTransaction](#gettransaction) method.
243+
A transaction ID is a 64-bit hexadecimal string that uniquely identifies the transaction. The transaction ID is derived from the transaction instruction and specifications, using a strong hash function.
244+
245+
You can look up a transaction by ID using the [getTransaction](#gettransaction) method.
228246

229247
# Transaction Specifications
230248

docs/src/basictypes.md.ejs

+11-5
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,28 @@
66
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
77
```
88

9-
Every Ripple account has an *address*, which is a base58-encoding of a hash of the account's public key.
9+
Every Ripple account has an *address*, which is a base58-encoding of a hash of the account's public key. Ripple addresses always start with the lowercase letter `r`.
1010

1111
## Account Sequence Number
1212

13-
Every Ripple account has a *sequence number* that is used to order transactions. Every transaction must have a sequence number and transaction can only be executed in order by sequence number. This prevents one transaction from executing twice and transactions executing out of order. The sequence number starts at `1` and increments for each transaction that the account makes.
13+
Every Ripple account has a *sequence number* that is used to keep transactions in order. Every transaction must have a sequence number. A transaction can only be executed if it has the next sequence number in order, of the account sending it. This prevents one transaction from executing twice and transactions executing out of order. The sequence number starts at `1` and increments for each transaction that the account makes.
1414

1515
## Currency
1616

1717
Currencies are represented as either 3-character currency codes or 40-character uppercase hexadecimal strings. We recommend using uppercase [ISO 4217 Currency Codes](http://www.xe.com/iso4217.php) only. The string "XRP" is disallowed on trustlines because it is reserved for the Ripple native currency. The following characters are permitted: all uppercase and lowercase letters, digits, as well as the symbols `?`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `<`, `>`, `(`, `)`, `{`, `}`, `[`, `]`, and `|`.
1818

1919
## Value
20-
A *value* is a quantity of a currency represented as a decimal string (string encoding is used because javascript numbers do not have sufficient precision).
20+
A *value* is a quantity of a currency represented as a decimal string. Be careful: JavaScript's native number format does not have sufficient precision to represent all values. XRP has different precision from other currencies.
21+
22+
**XRP** has 6 significant digits past the decimal point. In other words, XRP cannot be divided into positive values smaller than `0.000001` (1e-6). XRP has a maximum value of `100000000000` (1e11).
23+
24+
**Non-XRP values** have 15 decimal digits of precision, with a maximum value of `9999999999999999e80`. The smallest positive non-XRP value is `1e-81`.
2125

22-
An XRP value has 6 significant digits past the decimal point. A non-XRP value has 16 total digits of precision.
2326

2427
## Amount
2528

29+
Example amount:
30+
2631
```json
2732
{
2833
"currency": "USD",
@@ -31,14 +36,15 @@ An XRP value has 6 significant digits past the decimal point. A non-XRP value ha
3136
}
3237
```
3338

39+
Example XRP amount:
3440
```json
3541
{
3642
"currency": "XRP",
3743
"value": "2000"
3844
}
3945
```
4046

41-
An *amount* is data structure representing a currency, a quantity of that currency, and the counterparty on the trustline that holds the value (for all currencies besides "XRP").
47+
An *amount* is data structure representing a currency, a quantity of that currency, and the counterparty on the trustline that holds the value. For XRP, there is no counterparty.
4248

4349
A *lax amount* allows the counterparty to be omitted for all currencies. If the counterparty is not specified in an amount within a transaction specification, then any counterparty may be used for that amount.
4450

docs/src/boilerplate.md.ejs

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ If you omit the "catch" section, errors may not be visible.
3232

3333
1. Install [NodeJS](https://nodejs.org) and the Node Package Manager (npm). Most Linux distros have a package for NodeJS, but make sure you have version `0.12.0` or higher.
3434
2. Use npm to install [Babel](https://babeljs.io/) globally:
35-
npm install -g babel
35+
`npm install -g babel`
3636
3. Use npm to install RippleAPI:
37-
npm install ripple-lib
37+
`npm install ripple-lib`
3838

3939
After you have installed ripple-lib, you can create scripts using the [boilerplate](#boilerplate) and run them using babel-node:
40-
babel-node script.js
40+
`babel-node script.js`
4141

4242
<aside class="notice">
4343
Instead of using babel-node in production, we recommend using Babel to transpile to ECMAScript 5 first.

docs/src/transactions.md.ejs

+21-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A transaction type is specified by the strings in the first column in the table
66

77
Type | Description
88
---- | -----------
9-
[payment](#payment) | A `payment` transaction represents a transfer of value from one account to another. Depending on the path taken, additional exchanges of value may occur atomically to facilitate the payment.
9+
[payment](#payment) | A `payment` transaction represents a transfer of value from one account to another. Depending on the [path](https://ripple.com/build/paths/) taken, additional exchanges of value may occur atomically to facilitate the payment.
1010
[order](#order) | An `order` transaction creates a limit order. It defines an intent to exchange currencies, and creates an order in the Ripple Consensus Ledger's order book if not completely fulfilled when placed. Orders can be partially fulfilled.
1111
[orderCancellation](#order-cancellation) | An `orderCancellation` transaction cancels an order in the Ripple Consensus Ledger's order book.
1212
[trustline](#trustline) | A `trustline` transactions creates or modifies a trust line between two accounts.
@@ -19,27 +19,39 @@ Type | Description
1919

2020
Executing a transaction with `RippleAPI` requires the following four steps:
2121

22-
1. prepare - Create an unsigned transaction based on a [specification](#transaction-specifications) and [instructions](#transaction-instructions).
23-
2. sign - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place.
24-
3. submit - Submit the transaction to the connected server.
25-
4. verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted. It is recommended that you specify a `maxLedgerVersion` in the instructions when preparing a transaction because without it there is no way to know that a failed transaction will never succeeed in the future. It is impossible for a transaction to succeed after the network ledger version exceeds the `maxLedgerVersion` provided in the transaction instructions.
22+
1. Prepare - Create an unsigned transaction based on a [specification](#transaction-specifications) and [instructions](#transaction-instructions). There is a method to prepare each type of transaction:
23+
* [preparePayment](#preparepayment)
24+
* [prepareTrustline](#preparetrustline)
25+
* [prepareOrder](#prepareorder)
26+
* [prepareOrderCancellation](#prepareordercancellation)
27+
* [prepareSettings](#preparesettings)
28+
* [prepareSuspendedPaymentCreation](#preparesuspendedpaymentcreation)
29+
* [prepareSuspendedPaymentCancellation](#preparesuspendedpaymentcancellation)
30+
* [prepareSuspendedPaymentExecution](#preparesuspendedpaymentexecution)
31+
2. [Sign](#sign) - Cryptographically sign the transaction locally and save the [transaction ID](#transaction-id). Signing is how the owner of an account authorizes a transaction to take place.
32+
3. [Submit](#submit) - Submit the transaction to the connected server.
33+
4. Verify - Verify that the transaction got validated by querying with [getTransaction](#gettransaction). This is necessary because transactions may fail even if they were successfully submitted.
2634

2735
## Transaction Fees
2836

29-
Every transaction requires a *fee* to be paid in XRP. The fee is destroyed; it is not sent to any other party. The purpose of the fee is to prevent denial of service attacks on the Ripple network.
37+
Every transaction must destroy a small amount of XRP as a cost to send the transaction. This is also called a *transaction fee*. The transaction cost is designed to increase along with the load on the Ripple network, making it very expensive to deliberately or inadvertently overload the network.
3038

31-
You can choose the size of the fee you want to pay or let a default be used. The fee is like a bid in an auction for slots in the next ledger closing. If the fee you choose is too low, your transaction will not be included in the next ledger closing. You can get an estimate of the fee required to be included in the next ledger closing with the [getFee](#getfee) method.
39+
You can choose the size of the fee you want to pay or let a default be used. You can get an estimate of the fee required to be included in the next ledger closing with the [getFee](#getfee) method.
3240

3341
## Transaction Instructions
3442

35-
Transactions instructions indicates how to execute a transaction, complementary with the [transaction specification](#transaction-specifications).
43+
Transaction instructions indicate how to execute a transaction, complementary with the [transaction specification](#transaction-specifications).
3644

3745
<%- renderSchema("objects/instructions.json") %>
3846

47+
We recommended that you specify a `maxLedgerVersion` because without it there is no way to know that a failed transaction will never succeeed in the future. It is impossible for a transaction to succeed after the network ledger version exceeds the transaction's `maxLedgerVersion`.
48+
3949
## Transaction ID
4050

4151
```json
4252
"F4AB442A6D4CBB935D66E1DA7309A5FC71C7143ED4049053EC14E3875B0CF9BF"
4353
```
4454

45-
A hash of the transaction that can be used to identify it. A transaction can be looked up by its ID using the [getTransaction](#gettransaction) method.
55+
A transaction ID is a 64-bit hexadecimal string that uniquely identifies the transaction. The transaction ID is derived from the transaction instruction and specifications, using a strong hash function.
56+
57+
You can look up a transaction by ID using the [getTransaction](#gettransaction) method.

0 commit comments

Comments
 (0)