diff --git a/content/code_samples/rippleapi_quickstart/submit-and-verify.js b/content/code_samples/rippleapi_quickstart/submit-and-verify.js index 4d094971fc..57c061573e 100644 --- a/content/code_samples/rippleapi_quickstart/submit-and-verify.js +++ b/content/code_samples/rippleapi_quickstart/submit-and-verify.js @@ -25,7 +25,7 @@ const myOrder = { const INTERVAL = 1000; /* Instantiate RippleAPI. Uses s2 (full history server) */ const api = new RippleAPI({server: 'wss://s2.ripple.com'}); -/* number of ledgers to check for valid transaction before fail */ +/* Number of ledgers to check for valid transaction before failing */ const ledgerOffset = 5; const myInstructions = {maxLedgerVersionOffset: ledgerOffset}; @@ -39,7 +39,7 @@ function verifyTransaction(hash, options) { console.log('Sequence: ', data.sequence); return data.outcome.result === 'tesSUCCESS'; }).catch(error => { - /* if transaction not in latest validated ledger, + /* If transaction not in latest validated ledger, try again until max ledger hit */ if (error instanceof api.errors.PendingLedgerVersionError) { return new Promise((resolve, reject) => { @@ -52,17 +52,17 @@ function verifyTransaction(hash, options) { } -/* function to prepare, sign, and submit a transaction to the XRP Ledger -success verifies the transaction is being considered for the next ledger. -Still requires vlaidation */ +/* Function to prepare, sign, and submit a transaction to the XRP Ledger. */ function submitTransaction(lastClosedLedgerVersion, prepared, secret) { const signedData = api.sign(prepared.txJSON, secret); return api.submit(signedData.signedTransaction).then(data => { console.log('Tentative Result: ', data.resultCode); console.log('Tentative Message: ', data.resultMessage); - /* if transaction was not successfully submitted throw error */ + /* If transaction was not successfully submitted throw error */ assert.strictEqual(data.resultCode, 'tesSUCCESS'); - /* if successfully submitted fire off validation workflow */ + /* 'tesSUCCESS' means the transaction is being considered for the next ledger, and requires validation. */ + + /* If successfully submitted, begin validation workflow */ const options = { minLedgerVersion: lastClosedLedgerVersion, maxLedgerVersion: prepared.instructions.maxLedgerVersion diff --git a/content/tutorial-rippleapi-beginners-guide.md b/content/tutorial-rippleapi-beginners-guide.md index a2a270cb16..cfcd307b55 100644 --- a/content/tutorial-rippleapi-beginners-guide.md +++ b/content/tutorial-rippleapi-beginners-guide.md @@ -6,7 +6,7 @@ The scripts and configuration files used in this guide are [available in the Rip # Environment Setup # -The first step to using RippleAPI successfully is setting up your development environment. +The first step to using RippleAPI is setting up your development environment. ## Install Node.js and npm ## @@ -14,7 +14,7 @@ RippleAPI is built as an application for the Node.js runtime environment, so the This step depends on your operating system. We recommend [the official instructions for installing Node.js using a package manager](https://nodejs.org/en/download/package-manager/) for your operating system. If the packages for Node.js and `npm` (Node Package Manager) are separate, install both. (This applies to Arch Linux, CentOS, Fedora, and RHEL.) -After you have installed Node.js, you can check whether it's installed by checking the version of the `node` binary from a commandline: +After you have installed Node.js, you can check the version of the `node` binary from a command line: ``` node --version @@ -26,7 +26,6 @@ On some platforms, the binary is named `nodejs` instead: nodejs --version ``` - ## Use NPM to install RippleAPI and dependencies ## RippleAPI uses the newest version of JavaScript, ECMAScript 6 (also known as ES2015). To use the new features of ECMAScript 6, RippleAPI depends on [Babel-Node](https://babeljs.io) and its ES2015 presets. You can use `npm` to install RippleAPI and these dependencies together. @@ -77,8 +76,6 @@ npm WARN notsup Not compatible with your operating system or architecture: fseve npm WARN ajv@1.4.10 requires a peer of ajv-i18n@0.1.x but none was installed. ``` - - # First RippleAPI Script ## This script, `get-account-info.js`, fetches information about a hard-coded account. Use it to test that RippleAPI works: @@ -89,7 +86,7 @@ This script, `get-account-info.js`, fetches information about a hard-coded accou ## Running the script ## -RippleAPI and the script both use the ECMAScript 6 version of JavaScript, which is (at this time) not supported by Node.js natively. That's why we installed Babel earlier. The easiest way to run ECMAScript 6 is to use the `babel-node` binary, which NPM installs in the `node_modules/.bin/` directory of your project. Thus, running the script looks like this: +RippleAPI and the script both use the ECMAScript 6 version of JavaScript. That's why we installed Babel earlier. The easiest way to run ECMAScript 6 is to use the `babel-node` binary, which NPM installs in the `node_modules/.bin/` directory of your project. Thus, running the script looks like this: ``` ./node_modules/.bin/babel-node get-account-info.js @@ -211,15 +208,13 @@ If you are the administrator of the `rippled` server, you can [manually request See [Reliable Transaction Submission](tutorial-reliable-transaction-submission.html) for a more thorough explanation. - - # RippleAPI in Web Browsers # RippleAPI can also be used in a web browser if you compile a browser-compatible version and include [lodash](https://www.npmjs.com/package/lodash) as a dependency before the RippleAPI script. ## Build Instructions ## -To use RippleAPI in a browser, you need to a browser-compatible version. The following process compiles RippleAPI into a single JavaScript file you can include in a webpage. +To use RippleAPI in a browser, you need to build a browser-compatible version. The following process compiles RippleAPI into a single JavaScript file you can include in a webpage. #### 1. Download a copy of the RippleAPI git repository. @@ -233,7 +228,6 @@ git checkout release Alternatively, you can download an archive (.zip or .tar.gz) of a specific release from the [RippleAPI releases page](https://github.com/ripple/ripple-lib/releases) and extract it. - #### 2. Install dependencies using NPM You need to have [NPM (Node.js Package Manager) installed](#install-nodejs-and-npm) first. diff --git a/tutorial-rippleapi-beginners-guide.html b/tutorial-rippleapi-beginners-guide.html index 12b9f78cfb..092855c717 100644 --- a/tutorial-rippleapi-beginners-guide.html +++ b/tutorial-rippleapi-beginners-guide.html @@ -170,11 +170,11 @@

This tutorial guides you through the basics of building an XRP Ledger-connected application using Node.js and RippleAPI, a JavaScript API for accessing the XRP Ledger.

The scripts and configuration files used in this guide are available in the Ripple Dev Portal GitHub Repository.

Environment Setup

-

The first step to using RippleAPI successfully is setting up your development environment.

+

The first step to using RippleAPI is setting up your development environment.

Install Node.js and npm

RippleAPI is built as an application for the Node.js runtime environment, so the first step is getting Node.js installed. RippleAPI requires Node.js version 0.12, version 4.x, or higher.

This step depends on your operating system. We recommend the official instructions for installing Node.js using a package manager for your operating system. If the packages for Node.js and npm (Node Package Manager) are separate, install both. (This applies to Arch Linux, CentOS, Fedora, and RHEL.)

-

After you have installed Node.js, you can check whether it's installed by checking the version of the node binary from a commandline:

+

After you have installed Node.js, you can check the version of the node binary from a command line:

node --version
 

On some platforms, the binary is named nodejs instead:

@@ -253,7 +253,7 @@ api.connect().then(() => { }).catch(console.error);

Running the script

-

RippleAPI and the script both use the ECMAScript 6 version of JavaScript, which is (at this time) not supported by Node.js natively. That's why we installed Babel earlier. The easiest way to run ECMAScript 6 is to use the babel-node binary, which NPM installs in the node_modules/.bin/ directory of your project. Thus, running the script looks like this:

+

RippleAPI and the script both use the ECMAScript 6 version of JavaScript. That's why we installed Babel earlier. The easiest way to run ECMAScript 6 is to use the babel-node binary, which NPM installs in the node_modules/.bin/ directory of your project. Thus, running the script looks like this:

./node_modules/.bin/babel-node get-account-info.js
 

Output:

@@ -351,7 +351,7 @@ const myOrder = { const INTERVAL = 1000; /* Instantiate RippleAPI. Uses s2 (full history server) */ const api = new RippleAPI({server: 'wss://s2.ripple.com'}); -/* number of ledgers to check for valid transaction before fail */ +/* Number of ledgers to check for valid transaction before failing */ const ledgerOffset = 5; const myInstructions = {maxLedgerVersionOffset: ledgerOffset}; @@ -365,7 +365,7 @@ function verifyTransaction(hash, options) { console.log('Sequence: ', data.sequence); return data.outcome.result === 'tesSUCCESS'; }).catch(error => { - /* if transaction not in latest validated ledger, + /* If transaction not in latest validated ledger, try again until max ledger hit */ if (error instanceof api.errors.PendingLedgerVersionError) { return new Promise((resolve, reject) => { @@ -378,17 +378,17 @@ function verifyTransaction(hash, options) { } -/* function to prepare, sign, and submit a transaction to the XRP Ledger -success verifies the transaction is being considered for the next ledger. -Still requires vlaidation */ +/* Function to prepare, sign, and submit a transaction to the XRP Ledger. */ function submitTransaction(lastClosedLedgerVersion, prepared, secret) { const signedData = api.sign(prepared.txJSON, secret); return api.submit(signedData.signedTransaction).then(data => { console.log('Tentative Result: ', data.resultCode); console.log('Tentative Message: ', data.resultMessage); - /* if transaction was not successfully submitted throw error */ + /* If transaction was not successfully submitted throw error */ assert.strictEqual(data.resultCode, 'tesSUCCESS'); - /* if successfully submitted fire off validation workflow */ + /* 'tesSUCCESS' means the transaction is being considered for the next ledger, and requires validation. */ + + /* If successfully submitted, begin validation workflow */ const options = { minLedgerVersion: lastClosedLedgerVersion, maxLedgerVersion: prepared.instructions.maxLedgerVersion @@ -424,7 +424,7 @@ api.connect().then(() => {

RippleAPI in Web Browsers

RippleAPI can also be used in a web browser if you compile a browser-compatible version and include lodash as a dependency before the RippleAPI script.

Build Instructions

-

To use RippleAPI in a browser, you need to a browser-compatible version. The following process compiles RippleAPI into a single JavaScript file you can include in a webpage.

+

To use RippleAPI in a browser, you need to build a browser-compatible version. The following process compiles RippleAPI into a single JavaScript file you can include in a webpage.

1. Download a copy of the RippleAPI git repository.

If you have Git installed, you can clone the repository and check out the release branch, which always has the latest official release:

git clone https://github.com/ripple/ripple-lib.git