Skip to content

Commit 13d5fdd

Browse files
authored
feat(docs): direct minting and redeeming guides (#1349)
1 parent caeeeb9 commit 13d5fdd

19 files changed

Lines changed: 898 additions & 10 deletions

docs/fassets/03-direct-minting.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ If a preferred executor's minting is delayed, their exclusive execution window r
110110

111111
:::tip[What's next]
112112

113-
Learn more about the different components and processes involved in FAssets - [standard minting](/fassets/minting), [redemptions](/fassets/redemption), [collateral](/fassets/collateral), [liquidations](/fassets/liquidation), and [Core Vault](/fassets/core-vault).
113+
To continue your FAssets development journey, you can:
114+
115+
- Read the protocol details in [Direct Minting](/fassets/direct-minting).
116+
- Mint without a reserved tag using [memo-based direct minting](/fassets/developer-guides/fassets-direct-minting).
117+
- Check current limits and fees in [Operational Parameters](/fassets/operational-parameters).
114118

115119
:::

docs/fassets/developer-guides.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ Guides for [minting FAssets](/fassets/minting) from underlying assets.
4242

4343
<DocCardList
4444
items={[
45+
{
46+
type: "link",
47+
label: "Direct Mint FXRP",
48+
href: "/fassets/developer-guides/fassets-direct-minting",
49+
docId: "fassets/developer-guides/fassets-direct-minting",
50+
},
51+
{
52+
type: "link",
53+
label: "Direct Mint FXRP with Tag",
54+
href: "/fassets/developer-guides/fassets-direct-minting-tag",
55+
docId: "fassets/developer-guides/fassets-direct-minting-tag",
56+
},
4557
{
4658
type: "link",
4759
label: "Mint FAssets",
@@ -63,6 +75,18 @@ Guides for [redeeming FAssets](/fassets/redemption) back to underlying assets.
6375

6476
<DocCardList
6577
items={[
78+
{
79+
type: "link",
80+
label: "Redeem FXRP by Amount",
81+
href: "/fassets/developer-guides/fassets-redeem-amount",
82+
docId: "fassets/developer-guides/fassets-redeem-amount",
83+
},
84+
{
85+
type: "link",
86+
label: "Redeem FXRP with Tag",
87+
href: "/fassets/developer-guides/fassets-redeem-with-tag",
88+
docId: "fassets/developer-guides/fassets-redeem-with-tag",
89+
},
6690
{
6791
type: "link",
6892
label: "Redeem FAssets",
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: Redeem FXRP with Tag
3+
tags: [intermediate, fassets]
4+
slug: fassets-redeem-with-tag
5+
description: Redeem any amount of FXRP and require an XRPL destination tag on the agent's payment.
6+
keywords:
7+
[
8+
fassets,
9+
fxrp,
10+
redemption,
11+
redeem-with-tag,
12+
xrpl,
13+
destination-tag,
14+
flare-network,
15+
]
16+
sidebar_position: 10
17+
---
18+
19+
import CodeBlock from "@theme/CodeBlock";
20+
import FAssetsRedeemWithTag from "!!raw-loader!/examples/developer-hub-javascript/fassetsRedeemWithTag.ts";
21+
22+
## Overview
23+
24+
This guide walks you through redeeming FXRP using [`redeemWithTag`](/fassets/reference/IAssetManager#redeemwithtag) on the `AssetManagerFXRP` contract.
25+
Compared to [`redeemAmount`](/fassets/developer-guides/fassets-redeem-amount), `redeemWithTag` adds a required XRPL destination tag that the agent must include in the redemption payment — useful when redeeming directly to an exchange address that requires a tag.
26+
27+
The complete runnable example is available in the [flare-viem-starter](https://github.com/flare-foundation/flare-viem-starter/blob/main/src/fassets/redeem-with-tag.ts) repository.
28+
29+
## Prerequisites
30+
31+
- An EVM wallet with.
32+
- Native tokens on the same wallet to cover the gas fees.
33+
- An XRPL destination address and the destination tag the recipient requires.
34+
35+
## Redeem with Tag Script
36+
37+
<CodeBlock language="typescript" title="src/fassets/redeem-with-tag.ts">
38+
{FAssetsRedeemWithTag}
39+
</CodeBlock>
40+
41+
## Code Breakdown
42+
43+
1. Set `REDEEM_AMOUNT_UBA` to the amount of FXRP to redeem in UBA (underlying base unit).
44+
2. Set `REDEEMER_UNDERLYING_ADDRESS_STRING` to the XRPL address that will receive the redeemed XRP from the agent.
45+
3. `EXECUTOR_ZERO_ADDRESS` is used because no executor is appointed in this example.
46+
Pass a real address to delegate default-handling to an executor.
47+
4. Set `REDEMPTION_DESTINATION_TAG` to the XRPL destination tag the agent must include on the redemption payment.
48+
It must fit in a 32-bit integer.
49+
See [minting with tag](/fassets/direct-minting#minting-tag-manager) for more details or check out the [minting with tag example](/fassets/developer-guides/fassets-direct-minting-tag) on how to reserve a tag.
50+
5. Resolve the `AssetManagerFXRP` address through the [Flare Contract Registry](/network/guides/flare-contracts-registry) using [`getContractAddressByName`](/network/guides/flare-contracts-registry).
51+
6. Read [`minimumRedeemAmountUBA`](/fassets/reference/IAssetManager#minimumredeemamountuba) and check that the requested amount is at least the protocol minimum.
52+
7. Simulate the [`redeemWithTag`](/fassets/reference/IAssetManager#redeemwithtag) call to validate the arguments and produce a signed request payload.
53+
8. Submit the redemption request transaction.
54+
9. Wait for the transaction receipt.
55+
10. Decode [`RedemptionWithTagRequested`](/fassets/reference/IAssetManagerEvents#redemptionwithtagrequested) events from the receipt logs with the `parseEventLogs` function and select the one whose `redeemer` matches the caller.
56+
A single call may emit multiple `RedemptionWithTagRequested` events when multiple agents fulfill the request.
57+
58+
## Important Notes
59+
60+
- **XRP-only feature.** `redeemWithTag` is an XRP-only feature and is only available for FXRP.
61+
- **`minimumRedeemAmountUBA` is enforced on-chain.** Requests below the threshold revert.
62+
- **The redemption may be partial.** If the request requires too many redemption tickets, only part is filled and the leftover is returned via [`RedemptionAmountIncomplete`](/fassets/reference/IAssetManagerEvents#redemptionamountincomplete).
63+
Call `redeemWithTag` again for the remainder.
64+
- **Multiple agents may pay.** A single `redeemWithTag` call can produce several [`RedemptionWithTagRequested`](/fassets/reference/IAssetManagerEvents#redemptionwithtagrequested) events — one per agent serving the request.
65+
Track each `requestId` for the agent's underlying-chain payment.
66+
- **Default uses a dedicated proof type.** Confirming a tagged redemption uses `confirmXRPRedemptionPayment`, and if the agent fails to pay call `xrpRedemptionPaymentDefault` to start the default process.
67+
68+
:::tip[What's next]
69+
70+
To continue your FAssets development journey, you can:
71+
72+
- Redeem any amount without a tag with [`redeemAmount`](/fassets/developer-guides/fassets-redeem-amount).
73+
- Handle non-paying agents in [Monitor Redemptions & Execute Defaults](/fassets/developer-guides/fassets-redemption-default).
74+
- Mint without a tag using [memo-based direct minting](/fassets/developer-guides/fassets-direct-minting) or [direct minting with tag](/fassets/developer-guides/fassets-direct-minting-tag).
75+
76+
:::

docs/fassets/developer-guides/7-fassets-redeem.mdx renamed to docs/fassets/developer-guides/11-fassets-redeem.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tags: [intermediate, fassets]
44
slug: fassets-redeem
55
description: Learn how to redeem FAssets
66
keywords: [fassets, flare-network]
7-
sidebar_position: 7
7+
sidebar_position: 11
88
---
99

1010
import CodeBlock from "@theme/CodeBlock";

docs/fassets/developer-guides/8-fassets-swap-redeem.mdx renamed to docs/fassets/developer-guides/12-fassets-swap-redeem.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tags: [intermediate, fassets]
44
slug: fassets-swap-redeem
55
description: Learn how to swap and redeem FAssets
66
keywords: [fassets, flare-network]
7-
sidebar_position: 8
7+
sidebar_position: 12
88
---
99

1010
import CodeBlock from "@theme/CodeBlock";

docs/fassets/developer-guides/9-fassets-agent-details.mdx renamed to docs/fassets/developer-guides/13-fassets-agent-details.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tags: [intermediate, fassets]
44
slug: fassets-agent-details
55
description: Learn how to read FAssets agent details
66
keywords: [fassets, flare-network]
7-
sidebar_position: 9
7+
sidebar_position: 13
88
---
99

1010
import CodeBlock from "@theme/CodeBlock";
@@ -21,7 +21,9 @@ This information is essential for building user interfaces that display agent in
2121

2222
## Understanding FAssets Agents
2323

24-
FAssets agents are entities that manage the minting and redemption of FAssets tokens. Each agent has:
24+
FAssets agents are entities that manage the minting and redemption of FAssets tokens.
25+
26+
Each agent has:
2527

2628
- **Management Address**: The address that controls the agent's operations.
2729
- **Agent Name**: Agent's display name.

docs/fassets/developer-guides/10-fassets-redemption-default.mdx renamed to docs/fassets/developer-guides/14-fassets-redemption-default.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tags: [intermediate, fassets]
44
slug: fassets-redemption-default
55
description: Monitor and handle redemption scenarios
66
keywords: [fassets, flare-network]
7-
sidebar_position: 10
7+
sidebar_position: 14
88
---
99

1010
import YouTubeEmbed from "@site/src/components/YouTubeEmbed";

docs/fassets/developer-guides/11-fassets-redemption-queue.mdx renamed to docs/fassets/developer-guides/15-fassets-redemption-queue.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tags: [intermediate, fassets]
44
slug: fassets-redemption-queue
55
description: Learn how to get the redemption queue
66
keywords: [fassets, flare-network]
7-
sidebar_position: 11
7+
sidebar_position: 15
88
---
99

1010
import CodeBlock from "@theme/CodeBlock";
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: Direct Mint FXRP
3+
tags: [intermediate, fassets]
4+
slug: fassets-direct-minting
5+
description: Mint FXRP in a single XRPL payment using direct minting.
6+
keywords: [fassets, fxrp, direct-minting, flare-network, xrpl]
7+
sidebar_position: 5
8+
---
9+
10+
import CodeBlock from "@theme/CodeBlock";
11+
import FAssetsDirectMinting from "!!raw-loader!/examples/developer-hub-javascript/fassetsDirectMinting.ts";
12+
13+
## Overview
14+
15+
This guide walks you through minting FAssets FXRP using [direct minting](/fassets/direct-minting): a single XRPL payment to the FXRP [Core Vault](/fassets/core-vault) with a memo that encodes the Flare-side recipient.
16+
An executor then finalizes the mint on Flare, and the recipient receives FXRP.
17+
18+
The complete runnable example is available in the [flare-viem-starter](https://github.com/flare-foundation/flare-viem-starter/blob/main/src/fassets/direct-mint.ts) repository.
19+
20+
## How it differs from standard minting
21+
22+
Compared to the standard [collateral reservation flow](/fassets/developer-guides/fassets-mint), direct minting is a single-step XRPL payment:
23+
24+
- No collateral reservation — the minter does not call [`reserveCollateral`](/fassets/developer-guides/fassets-mint#reserve-collateral) and there is no agent selection.
25+
- A single XRPL payment to the Core Vault address replaces the agent payment.
26+
- The recipient (and optionally the executor) is encoded in the XRPL memo or destination tag.
27+
- An executor calls `executeDirectMinting` on Flare to finalize and receives a flat fee.
28+
29+
This guide demonstrates the **32-byte memo format**, where the recipient is a Flare address and any executor can finalize.
30+
31+
## Prerequisites
32+
33+
- [Flare smart account](/smart-accounts/overview) controlled by your XRPL wallet.
34+
- Testnet XRP on the XRP Ledger Testnet usage.
35+
Get testnet XRP from the [XRP Testnet Faucet](https://xrpl.org/resources/dev-tools/xrp-faucets).
36+
37+
## Direct Minting Memo
38+
39+
The memo is a packed 32-byte [`PaymentReference`](/fassets/direct-minting#memo-field):
40+
41+
| Bytes | Value | Meaning |
42+
| :---- | :----------------- | :------------------------------------------------------------ |
43+
| 0-7 | `4642505266410018` | Direct minting prefix. |
44+
| 8-11 | `00000000` | Zero padding to fill the 32-byte memo. |
45+
| 12-31 | 20-byte recipient | EVM address of the Flare smart account receiving FXRP tokens. |
46+
47+
Because no executor is encoded, anyone can finalize this minting on Flare.
48+
For executor-restricted minting, use the 48-byte memo format described in [Memo Field](/fassets/direct-minting#memo-field).
49+
50+
## Direct Minting Script
51+
52+
<CodeBlock language="typescript" title="src/fassets/direct-mint.ts">
53+
{FAssetsDirectMinting}
54+
</CodeBlock>
55+
56+
## Code Breakdown
57+
58+
1. Define the direct minting prefix constant `DIRECT_MINTING_PREFIX`.
59+
2. `buildDirectMintingMemo` concatenates the prefix, four zero bytes, and the recipient address (without the `0x` prefix, lowercased) into a 32-byte hex string ready to be passed as [`MemoData`](https://xrpl.org/docs/references/protocol/transactions/common-fields#memos-field) on the XRPL payment.
60+
3. `sendDirectMintPayment` builds the memo for the recipient and submits an XRPL `Payment` transaction to the [Core Vault](/fassets/core-vault) address with `memos: [{ Memo: { MemoData } }]`, returning the resulting transaction.
61+
4. Set the net FXRP amount to mint in XRP.
62+
Minting and executor fees are added to the net amount to form the XRPL payment amount.
63+
5. Connect to the XRPL Testnet using `XRPL_TESTNET_RPC_URL` and load the sender wallet from `XRPL_SEED`.
64+
6. Resolve the recipient — the Flare [`PersonalAccount`](/smart-accounts/reference/IPersonalAccount) for the XRPL wallet — via [`getPersonalAccountAddress`](/smart-accounts/reference/IPersonalAccount), and look up `AssetManagerFXRP` through the [Flare Contract Registry](/network/guides/flare-contracts-registry) using [`getContractAddressByName`](/network/guides/flare-contracts-registry).
65+
7. Read three values in parallel:
66+
- `getDirectMintingPaymentAddress` — the Core Vault XRPL address that receives the payment.
67+
- `getFxrpBalance` — the recipient's FXRP balance before minting.
68+
- `computeDirectMintingPaymentAmountXrp` — the gross XRP amount equal to the net mint amount plus the minting fee and the executor fee, as quoted by the `AssetManagerFXRP` contract.
69+
8. Send the XRPL payment to the Core Vault with the recipient memo via the `sendDirectMintPayment` function.
70+
9. Wait for the [`DirectMintingExecuted`](/fassets/reference/IAssetManagerEvents#directmintingexecuted) event on `AssetManagerFXRP` using `waitForDirectMintingExecuted` function.
71+
The event's `mintedAmountUBA`, `mintingFeeUBA`, and `executorFeeUBA` describe how the underlying payment was split.
72+
10. Read the final FXRP balance and log the delta.
73+
74+
## Important Notes
75+
76+
- **Fees are deducted from the underlying payment.** The XRP sent to the [Core Vault](/fassets/core-vault) must cover the net mint amount plus the minting fee and the executor fee.
77+
- **If the payment is below the minimum minting fee**, no FXRP is minted, and the entire payment is forfeited to the fee receiver.
78+
- **Rate limits may delay execution.** When hourly, daily, or large-minting thresholds are hit, the minting emits [`DirectMintingDelayed`](/fassets/reference/IAssetManagerEvents#directmintingdelayed) instead of [`DirectMintingExecuted`](/fassets/reference/IAssetManagerEvents#directmintingexecuted), with an `executionAllowedAt` timestamp.
79+
- **For repeat minters**, prefer the destination-tag flow via `IMintingTagManager` — it avoids constructing a memo per payment and lets you set a preferred executor.
80+
81+
:::tip[What's next]
82+
83+
To continue your FAssets development journey, you can:
84+
85+
- Mint with tag with [`mintWithTag`](/fassets/developer-guides/fassets-direct-minting-tag).
86+
- Read the protocol details in [Direct Minting](/fassets/direct-minting).
87+
- Redeem FAssets with [`redeemAmount`](/fassets/developer-guides/fassets-redeem-amount) or [`redeemWithTag`](/fassets/developer-guides/fassets-redeem-with-tag).
88+
89+
:::

0 commit comments

Comments
 (0)