> For the complete documentation index, see [llms.txt](https://docs.usemoon.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.usemoon.ai/interacting-with-the-blockchain/ripple.md).

# Ripple

Sure, here's a basic guide on how to interact with the Ripple blockchain using the Moon SDK in Markdown format.

### Initialization

Firstly, you need to import the necessary modules and initialize the MoonSDK:

```javascript
import { MoonSDK } from '@moonup/moon-api';

const moonSDK = new MoonSDK({
  apiKey: 'your-api-key',
});
```

Replace `'your-api-key'` with your actual API key.

### List Ripple Accounts

To list Ripple accounts:

```javascript
async function listRippleAccounts() {
  try {
    const response = await moonSDK.getRippleSDK().listRippleAccounts();
    console.log(response.data);
  } catch (error) {
    console.error(error);
  }
}

listRippleAccounts();
```

### Create a Ripple Account

To create a new Ripple account:

```javascript
async function createRippleAccount() {
  try {
    const response = await moonSDK.getRippleSDK().createRippleAccount({
      network: 'testnet', // or 'mainnet'
    });
    console.log(response.data);
  } catch (error) {
    console.error(error);
  }
}

createRippleAccount();
```

The `createRippleAccount` function will return an object containing the account name and private key of the newly created account.

### Sign a Ripple Transaction

To sign a Ripple transaction:

```javascript
async function signRippleTransaction(accountName, toAddress, amount, currency) {
  try {
    const response = await moonSDK.getRippleSDK().signRippleTransaction(accountName, {
      network: 'testnet', // or 'mainnet'
      to: toAddress,
      amount: amount,
      currency: currency,
    });
    console.log(response.data);
  } catch (error) {
    console.error(error);
  }
}

signRippleTransaction('your-account-name', 'recipient-address', '100', 'XRP');
```

Replace `'your-account-name'`, `'recipient-address'`, `'100'`, and `'XRP'` with the appropriate values. The `signRippleTransaction` function will return an object containing the signed transaction (`signedTx`) and the transaction hash (`transaction_hash`).

### Extra Notes

* Always remember to handle errors properly in your production code.
* This guide assumes that you're running in a Node.js environment. If you're running in a browser, you'll need to use a library like `ripple-lib` to sign transactions, as the browser doesn't have access to the file system to store private keys.
* This guide uses the testnet network for demonstration purposes. When you're ready to use the mainnet, make sure to change the `network` parameter to `'mainnet'`.
* Ripple uses a different unit of account than Bitcoin. One XRP is equal to 1,000,000 XRP drops, so you'll need to specify the amount in XRP drops when sending a transaction.
