diff --git a/.claude/rules/tutorials-guide.md b/.claude/rules/tutorials-guide.md index 136b322afe..c5d527a9a1 100644 --- a/.claude/rules/tutorials-guide.md +++ b/.claude/rules/tutorials-guide.md @@ -5,119 +5,163 @@ paths: # XRPL Tutorial Conventions -The template below shows the full structure a tutorial should follow; HTML comments provide instructions on how to fill it in. If the tutorial doesn't already link to a specific code sample, prompt the user for which code samples to use. +The template below shows the full structure a tutorial should follow. HTML comments serve two roles, distinguished by prefix: + +- `` marks a slot that needs to be filled in by the author +- `` describes the convention that applies at that spot + +If the tutorial doesn't already link to a specific code sample, prompt the user for which code samples to use. --- # Tutorial Title - - -This tutorial shows you how to + +This tutorial shows you how to ## Goals -By following this tutorial, you should learn how to: +By the end of this tutorial, you will be able to: - + ## Prerequisites - + To complete this tutorial, you should: - Have a basic understanding of the XRP Ledger. -- Have an [XRP Ledger client library](../../references/client-libraries.md), such as **xrpl.js**, installed. - - +- Have an [XRP Ledger client library](../../references/client-libraries.md) installed. This page provides examples for the following: + + - **JavaScript** with the [xrpl.js library][]. See [Get Started Using JavaScript][] for setup steps. + - **Python** with the [xrpl-py library][]. See [Get Started Using Python][] for setup steps. + - **Go** with the [xrpl-go library][]. See [Get Started Using Go][] for setup steps. + - **Java** with the [xrpl4j library][]. See [Get Started Using Java][] for setup steps. ## Source Code - + You can find the complete source code for this tutorial's examples in the {% repo-link path="_code-samples//" %}code samples section of this website's repository{% /repo-link %}. - - - -## Usage - ## Steps - + ### 1. Install dependencies - - + {% tabs %} {% tab label="JavaScript" %} From the code sample folder, use `npm` to install dependencies: -```sh -npm i +```bash +npm install ``` {% /tab %} {% tab label="Python" %} From the code sample folder, set up a virtual environment and use `pip` to install dependencies: -```sh +```bash python -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` {% /tab %} + +{% tab label="Go" %} +From the code sample folder, use `go` to install dependencies. + +```bash +go mod tidy +``` +{% /tab %} + +{% tab label="Java" %} +From the code sample folder, use `mvn` to install dependencies. + +```bash +mvn install +``` +{% /tab %} {% /tabs %} -### 2. Connect and get account(s) - +### 2. Set up client and accounts + -To get started, import the client library and instantiate an API client. +To get started, import the necessary libraries and instantiate a client to connect to the XRPL. This example imports: + + +--> + + ### 3. - + + +Create the [LoanBrokerSet transaction][] object. The management fee rate is set in 1/10th basis points. A value of `1000` equals 1% (100 basis points). {% tabs %} {% tab label="JavaScript" %} -{% code-snippet file="/_code-samples//js/.js" language="js" from="// TODO" before="// TODO next" /%} +{% code-snippet file="/_code-samples/lending-protocol/js/createLoanBroker.js" language="js" from="// Prepare LoanBrokerSet" before="// Submit, sign" /%} {% /tab %} - {% tab label="Python" %} -{% code-snippet file="/_code-samples//py/.py" language="py" from="# TODO" before="# TODO next" /%} +{% code-snippet file="/_code-samples/lending-protocol/py/create_loan_broker.py" language="py" from="# Prepare LoanBrokerSet" before="# Submit, sign" /%} {% /tab %} {% /tabs %} - +--> ## See Also - + {% raw-partial file="/docs/_snippets/common-links.md" /%} - ---- - -## Sample code conventions - -Sample code referenced by `{% code-snippet %}` lives at `_code-samples///` with both: -- A `README.md` at the topic root (used as the title/description on the [Code Samples](/resources/code-samples/) page) -- A per-language `README.md` describing install and run - -Language guidelines: -- **JavaScript:** xrpl.js, `package.json` with `"type": "module"`, ESM imports (not CommonJS), `await` over `.then()`, [JavaScript Standard Style](https://standardjs.com), `JSON.stringify(obj, null, 2)` when dumping objects to console. -- **Python:** xrpl-py, `requirements.txt`, `JsonRpcClient` (async only when needed), [Black Style](https://black.readthedocs.io/en/stable/).