mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 20:25:51 +00:00
update to match existing modular tutorials
This commit is contained in:
@@ -2,55 +2,100 @@
|
||||
|
||||
This example shows how to:
|
||||
|
||||
1. Issue `FOO` tokens on Devnet.
|
||||
2. Check if an AMM exists for `XRP/FOO`.
|
||||
3. Create an AMM for `XRP/FOO`.
|
||||
1. Check if an AMM pair exists.
|
||||
2. Issue tokens.
|
||||
3. Create an AMM pair with the issued tokens and XRP.
|
||||
|
||||
[](/docs/img/quickstart-create-amm1.png)
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/quickstart/js/)<!-- {.github-code-download} --> archive to try each of the samples in your own browser.
|
||||
|
||||
{% admonition type="note" name="Note" %}
|
||||
Without the Quickstart Samples, you will not be able to try the examples that follow.
|
||||
{% /admonition %}
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||

|
||||
### Get Accounts
|
||||
|
||||
Download the [AMM Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/amm/js/) to use the AMM test harness in your browser and follow along in this tutorial.
|
||||
1. Open `11.create-amm.html` in a browser.
|
||||
2. Select **Testnet** or **Devnet**
|
||||
3. Get test accounts.
|
||||
- If you have existing account seeds:
|
||||
1. Paste account seeds in the **Seeds** field.
|
||||
2. Click **Get Accounts from Seeds**.
|
||||
- If you don't have account seeds:
|
||||
1. Click **Get New Standby Account**.
|
||||
2. Click **Get New Operational Account**.
|
||||
|
||||
1. Open `create-an-amm.html` in a browser.
|
||||
2. Click **Get New Devnet Account**.
|
||||
3. Click **Issue FOO Tokens**.
|
||||
4. Click **Check for AMM**.
|
||||
5. Click **Create AMM**.
|
||||
6. Click **Check for AMM**.
|
||||
[](/docs/img/quickstart-create-amm2.png)
|
||||
|
||||
|
||||
### Check AMM
|
||||
|
||||
In the standby account fields:
|
||||
|
||||
1. Enter a [currency code](/docs/references/protocol/data-types/currency-formats.md#currency-codes) in the **Currency** field.
|
||||
2. Enter a token issuer in the **Destination** field.
|
||||
3. Click **Check AMM**.
|
||||
|
||||
[](/docs/img/quickstart-create-amm3.png)
|
||||
|
||||
|
||||
### Create Trustline
|
||||
|
||||
Create a trustline from the operational account to the standby account. In the standby account fields:
|
||||
|
||||
1. Enter a currency code in the **Currency** field.
|
||||
2. Enter the maximum transfer limit in the **Amount** field.
|
||||
3. Enter the operational account address in the **Destination** field.
|
||||
4. Click **Create Trustline**.
|
||||
|
||||
[](/docs/img/quickstart-create-amm4.png)
|
||||
|
||||
|
||||
### Issue Tokens
|
||||
|
||||
Send issued tokens from the operational account to the standby account. In the operational account fields:
|
||||
|
||||
1. Select **Allow Rippling** and click **Configure Account**.
|
||||
2. Enter a value in the **Amount** field.
|
||||
3. Enter the standby account address in the **Destination** field.
|
||||
4. Enter the currency code from the trustline in the **Currency** field.
|
||||
5. Click **Send Currency**.
|
||||
|
||||
[](/docs/img/quickstart-create-amm5.png)
|
||||
|
||||
|
||||
### Create an AMM
|
||||
|
||||
In the standby account fields:
|
||||
|
||||
1. Click **Get Balances** to verify how many tokens you have.
|
||||
2. Enter how much XRP to add in the **XRP Balance** field.
|
||||
3. Enter the operational account address in the **Destination** field.
|
||||
4. Enter the currency code in the **Currency** field.
|
||||
5. Enter how many issued tokens to add in the **Amount** field.
|
||||
6. Click **Create AMM**.
|
||||
|
||||
[](/docs/img/quickstart-create-amm6.png)
|
||||
|
||||
|
||||
## Code Walkthrough
|
||||
|
||||
### Connect to Devnet and generate credentials
|
||||
|
||||
You must be connected to the network to query it and submit transactions. This code connects to Devnet and generates a fresh wallet, funded with 100 XRP.
|
||||
|
||||
{% code-snippet file="/_code-samples/amm/js/1.create-an-amm.js" from="// Define client, network, and explorer." before="// Issue FOO tokens to Devnet wallet." language="js" /%}
|
||||
You can open `ripplex11-create-amm.js` from the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/quickstart/js/) to view the source code.
|
||||
|
||||
|
||||
### Issue FOO tokens
|
||||
### Check AMM
|
||||
|
||||
Normally, you'd acquire a second token through a stablecoin issuer, or buying it off an exchange. For this tutorial, we'll go through the process of issuing a brand new FOO token, enabling us to create a unique AMM pair later. Creating a new issuer and issuing a token involves:
|
||||
This checks if an AMM already exists. While multiple tokens can share the same currency code, each issuer makes them unique. When specifying an AMM, you must include the currency code and token issuer. If the AMM pair exists, this responds with the AMM information, such as token pair, trading fees, etc.
|
||||
|
||||
1. Creating a new issuer wallet.
|
||||
2. Enabling the `DefaultRipple` flag.
|
||||
3. Creating a trustline from your wallet to the issuer wallet.
|
||||
4. Sending the `FOO` tokens from the issuer to your wallet.
|
||||
|
||||
{% code-snippet file="/_code-samples/amm/js/1.create-an-amm.js" from="// Issue FOO tokens to Devnet wallet." before="// Check if AMM exists." language="js" /%}
|
||||
|
||||
|
||||
### Check if an AMM already exists.
|
||||
|
||||
Each AMM pair is unique. This checks to make sure the `XRP/FOO` pair doesn't already exist. In the previous step, we created a new issuer and `FOO` token; even if another `FOO` token already exists, it's considered unique if issued by another account. If the AMM pair exists, this responds with the AMM information, such as token pair, trading fees, etc.
|
||||
|
||||
{% code-snippet file="/_code-samples/amm/js/1.create-an-amm.js" from="// Check if AMM exists." before="// Create new AMM." language="js" /%}
|
||||
{% code-snippet file="/_code-samples/quickstart/js/ripplex11-create-amm.js" from="// Check AMM" language="js" /%}
|
||||
|
||||
|
||||
### Create AMM
|
||||
|
||||
This send the `AMMCreate` transaction with an initial pairing of 50 `XRP` to 500 `FOO`.
|
||||
This sends the `AMMCreate` transaction and creates a new AMM, using the initial assets provided.
|
||||
|
||||
{% code-snippet file="/_code-samples/amm/js/1.create-an-amm.js" from="// Create new AMM." language="js" /%}
|
||||
{% code-snippet file="/_code-samples/quickstart/js/ripplex11-create-amm.js" from="// Create AMM function" before="// Check AMM function" language="js" /%}
|
||||
|
||||
Reference in New Issue
Block a user