分享

RippleAPI Beginners Guide

 quasiceo 2018-08-16

RippleAPI Beginners Guide

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 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 the version of the node binary from a command line:

node --version

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 and its ES2015 presets. You can use npm to install RippleAPI and these dependencies together.

1. Create a new directory for your project

Create a folder called (for example) my_ripple_experiment:

mkdir my_ripple_experiment && cd my_ripple_experiment

Optionally, start a Git repository in that directory so you can track changes to your code.

git init

Alternatively, you can create a repo on GitHub to version and share your work. After setting it up, clone the repo to your local machine and cd into that directory.

2. Create a new package.json file for your project.

Use the following template, which includes:

  • RippleAPI itself (ripple-lib)
  • Babel (babel-cli)
  • The ECMAScript 6 presets for Babel (babel-preset-es2015)
  • (Optional) ESLint (eslint) for checking code quality.
{
  "name": "my_ripple_experiment",
  "version": "0.0.1",
  "license": "MIT",
  "private": true,
  "//": "Change the license to something appropriate. You may want to use 'UNLICENSED' if you are just starting out.",
  "dependencies": {
    "ripple-lib": "*",
    "babel-cli": "^6.0.0",
    "babel-preset-es2015": "*"
  },
  "babel": {
    "presets": ["es2015"]
  },
  "devDependencies": {
    "eslint": "*"
  }
}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多