|
| 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. Minting and executor fees are added to the net amount to form the XRPL payment amount. |
| 62 | +5. Connect to the XRPL Testnet using `XRPL_TESTNET_RPC_URL` and load the sender wallet from `XRPL_SEED`. |
| 63 | +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). |
| 64 | +7. Read three values in parallel: |
| 65 | + - `getDirectMintingPaymentAddress` — the Core Vault XRPL address that receives the payment. |
| 66 | + - `getFxrpBalance` — the recipient's FXRP balance before minting. |
| 67 | + - `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. |
| 68 | +8. Send the XRPL payment to the Core Vault with the recipient memo via the `sendDirectMintPayment` function. |
| 69 | +9. Wait for the [`DirectMintingExecuted`](/fassets/reference/IAssetManagerEvents#directmintingexecuted) event on `AssetManagerFXRP` using `waitForDirectMintingExecuted` function. |
| 70 | + The event's `mintedAmountUBA`, `mintingFeeUBA`, and `executorFeeUBA` describe how the underlying payment was split. |
| 71 | +10. Read the final FXRP balance and log the delta. |
| 72 | + |
| 73 | +## Important Notes |
| 74 | + |
| 75 | +- **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. |
| 76 | +- **If the payment is below the minimum minting fee**, no FXRP is minted, and the entire payment is forfeited to the fee receiver. |
| 77 | +- **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. |
| 78 | +- **For repeat minters**, prefer the destination-tag flow via `IMintingTagManager` — it avoids constructing a memo per payment and lets you set a preferred executor. |
| 79 | + |
| 80 | +:::tip[What's next] |
| 81 | + |
| 82 | +To continue your FAssets development journey, you can: |
| 83 | + |
| 84 | +- Read the protocol details in [Direct Minting](/fassets/direct-minting). |
| 85 | +- Check current limits and fees in [Operational Parameters](/fassets/operational-parameters). |
| 86 | +- Continue with [Redeem FAssets](/fassets/developer-guides/fassets-redeem). |
| 87 | + |
| 88 | +::: |
0 commit comments