Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6004b61
refactor(docs): update FAssets redemption guide
fassko Jul 22, 2025
b214efa
refactor(script): update asset manager address retrieval in getFXRP s…
fassko Jul 22, 2025
b6653ba
refactor(docs): update FAssets settings documentation and TypeScript …
fassko Jul 23, 2025
a1e9ef4
refactor(docs): streamline FAssets asset manager address retrieval gu…
fassko Jul 23, 2025
a1e0562
refactor(script): update FXRP asset manager retrieval method in getFX…
fassko Aug 8, 2025
3ae7dc9
refactor(docs): remove unnecessary whitespace in FAssets asset manage…
fassko Aug 8, 2025
d20a30d
refactor(script): update payment calculation
fassko Aug 8, 2025
4ea653e
refactor(docs): enhance FAssets minting guide and update TypeScript s…
fassko Aug 8, 2025
8c1dd07
refactor(docs): add function to print redemption request information …
fassko Aug 8, 2025
f3b9230
refactor(docs): add helper functions and update asset manager retriev…
fassko Aug 8, 2025
36cbfbe
refactor(docs): enhance FAssets minting guides and update TypeScript …
fassko Aug 8, 2025
05268d9
refactor(FAssetsRedeem): simplify redemption process and enhance asse…
fassko Aug 11, 2025
1a87a46
refactor(docs): clean up whitespace and improve formatting in FAssets…
fassko Aug 11, 2025
c10ab80
refactor(docs): update Flare Contract Registry link in FAssets mintin…
fassko Aug 11, 2025
970c791
refactor(script): update asset manager retrieval method in FAssets Ty…
fassko Aug 11, 2025
d1e7528
refactor(script): streamline function definition for parsing Collater…
fassko Aug 11, 2025
0169f01
refactor(script): add eslint directive for explicit 'any' type in eve…
fassko Aug 11, 2025
5769b5b
refactor(docs): streamline the swap and redeem process in FAssets doc…
fassko Aug 11, 2025
d96082a
refactor(docs): clarify asset manager settings retrieval and improve …
fassko Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ keywords: [fassets, flare-network, fxrp, asset-manager]
sidebar_position: 1
---

import CodeBlock from "@theme/CodeBlock";
import Remix from "@site/src/components/remix";
import AssetManagerRegistry from "!!raw-loader!/examples/developer-hub-solidity/FAssetsAssetManagerRegistry.sol";
import ExploringAdditionalParameters from "./_exploring-additional-parameters.mdx";

## Overview
Expand All @@ -19,44 +16,20 @@ These addresses can change between Flare testnets and mainnet deployments, and r

Instead, you should dynamically fetch the FXRP Asset Manager address using the [Flare Contract Registry](/network/guides/flare-contracts-registry), the trusted source for obtaining contract addresses on any Flare network.

In this guide, you will learn:
## Get the FXRP Asset Manager Address

- How to retrieve the [Asset Manager Controller](/fassets/reference/IAssetManagerController) using the Flare Contract Registry.
- How to find the specific FXRP [Asset Manager](/fassets/reference/IAssetManager).
- A sample Solidity contract that encapsulates this logic.
To get the [FAssets asset manager](/fassets/reference/IAssetManager) address, you can use the [Flare Contract Registry](/network/guides/flare-contracts-registry) library.
It is included in the [Flare Periphery Contracts package](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts).

## Sample code
The following example demonstrates how to get the FXRP Asset Manager address using the Flare Contract Registry library in a Solidity contract.

To get the [FAssets asset manager](/fassets/reference/IAssetManager) address, you can use the following smart contract that retrieves the [Asset Manager Controller](/fassets/reference/IAssetManagerController) address from the [Flare contract registry](/network/guides/flare-contracts-registry).
```solidity
import { ContractRegistry } from "@flarenetwork/flare-periphery-contracts/coston2/ContractRegistry.sol";
import {IAssetManager} from "@flarenetwork/flare-periphery-contracts/coston2/IAssetManager.sol";

<CodeBlock language="solidity" title="contracts/AssetManagerRegistry.sol">
{AssetManagerRegistry}
</CodeBlock>

{/* prettier-ignore */}
<Remix fileName="FAssetsAssetManagerRegistry.sol">Open in Remix</Remix>
<br></br>

### Contract Breakdown

1. Imports the necessary interfaces and libraries from the [Flare Periphery Contracts package](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts).
2. Defines a constant `TXRP_HASH` that is the hash of the string `TXRP`.
This is used to identify the FXRP asset manager.
3. Implements a function `getFxrpAssetManager` that returns the FXRP [Asset Manager](/fassets/reference/IAssetManager) address.
4. Uses the `ContractRegistry` library from the Flare Periphery Contracts package to get the [Asset Manager Controller](/fassets/reference/IAssetManagerController) address from the Flare contract registry.
5. Uses the `IAssetManagerController` interface from the Flare Periphery Contracts package to get all the asset managers from the Asset Manager Controller.
6. Iterates over the asset managers and returns the FXRP Asset Manager address.
7. Gets the settings of the asset manager.
8. Checks if the pool token suffix is `TXRP` and if true returns the FXRP Asset Manager address.

You can find out this sample code in the [Flare starter kit](/network/guides/hardhat-foundry-starter-kit).

:::tip Reusable Library

To reuse this code to get the FXRP Asset Manager address in other smart contracts, you can wrap it in a reusable library.
This is useful if you want to use the FXRP Asset Manager address in multiple smart contracts and avoid repeating the same code.

:::
// Get the FXRP Asset Manager address from the Flare contracts registry
IAssetManager assetManager = ContractRegistry.getAssetManagerFXRP();
```

## Next Steps

Expand Down
10 changes: 6 additions & 4 deletions docs/fassets/developer-guides/2-fassets-fxrp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ sidebar_position: 2

import CodeBlock from "@theme/CodeBlock";
import Remix from "@site/src/components/remix";
import FAssetsSwapAndRedeemContract from "!!raw-loader!/examples/developer-hub-solidity/FAssetsSwapAndRedeem.sol";
import FAssetsGetFxrpScript from "!!raw-loader!/examples/developer-hub-javascript/fassets_get_fxrp.ts";
import RedemptionProcessPrerequisites from "./_redemption_process_prerequisites.mdx";

Expand Down Expand Up @@ -55,6 +54,11 @@ The script:
2. Calls the [`fAsset`](/fassets/reference/IAssetManager#fasset) function to get the FXRP token address.
3. Logs the address to the console.

:::info
The `getFXRPAssetManagerAddress` function is a utility function that is included in the [Flare Hardhat Starter Kit](/network/guides/hardhat-foundry-starter-kit).
It is used to get the FXRP Asset Manager address from the Flare Contract Registry.
:::

### Run the Script

To run the script, use the following command:
Expand All @@ -81,7 +85,7 @@ Once you have the FXRP address, you can:
2. Add it to your wallet to track FXRP balances
3. Use it in DeFi protocols that support FXRP

:::tip Next Steps
## Next Steps

In this guide, you learned how to get the FXRP address for the FAssets system by interacting with the `AssetManager` contract using the [`IAssetManager`](/fassets/reference/IAssetManager) interface.

Expand All @@ -91,5 +95,3 @@ To continue your FAssets development journey, you can:
- Understand how to [redeem FXRP](/fassets/developer-guides/fassets-redeem).
- Explore [FAssets system settings](/fassets/operational-parameters).
- Check the [lot size](/fassets/developer-guides/fassets-settings-node) for FXRP operations.

:::
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ To get the FAsset lot size, you can use the following smart contract:

### Code Breakdown

1. Import the interface `IAssetManager` from the [Flare Periphery Contracts package](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts), which provides access to the FAssets system.
2. Create a contract called `FAssetsSettings` that will be used to fetch the FAssets settings from the asset manager.
3. Value `assetManager` holds the address of the FAssets FXRP asset manager contract.
The type `IAssetManager` comes from the Flare Periphery Contracts package.
4. The constructor initializes the contract with the AsseFXRP asset managertManager address.
5. The `getLotSize` function gets numbers from the FAssets FXRP asset manager settings using the [`getSettings`](/fassets/reference/IAssetManager#getsettings) function returns the complete asset manager settings that you can find in the [FAssets Operational Parameters](/fassets/operational-parameters/#asset-manager-operational-parameters) documentation:
- `lotSizeAMG`: The smallest amount you can trade (in AMG units)
- `assetDecimals`: How many decimal places the FAssets asset uses
1. Import the [ContractRegistry library](/network/guides/flare-contracts-registry#contract-registry-library) to access the Flare Network contract registry.
2. Import the interface `IAssetManager` from the [Flare Periphery Contracts package](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts), which provides access to the FAssets system.
3. Create a contract called `FAssetsSettings` that will be used to fetch the FAssets settings from the asset manager.
4. Use the ContractRegistry to get the FAssets FXRP asset manager address.
5. Use the `getLotSize` function to retrieve settings from the FAssets FXRP asset manager.
The function calls [`getSettings`](/fassets/reference/IAssetManager#getsettings) which returns the complete asset manager settings that you can find in the [FAssets Operational Parameters](/fassets/operational-parameters/#asset-manager-operational-parameters) documentation:
- `lotSizeAMG`: The smallest amount you can trade (in AMG units).
- `assetDecimals`: How many decimal places the FAssets asset uses.
6. The `getLotSize` function returns two values:
- `lotSizeAMG`: The smallest amount you can trade (in AMG units).
- `assetDecimals`: How many decimal places the FAssets asset uses.

:::info Flare Hardhat Starter Kit
Using the [Flare Hardhat Starter Kit](/network/guides/hardhat-foundry-starter-kit) you can quickly deploy the contract and generate TypeChain bindings for seamless TypeScript integration.
Expand All @@ -56,34 +59,22 @@ It streamlines development by providing a ready-made project structure, preconfi
Use the following TypeScript script to deploy the contract and fetch the FAsset settings using the Hardhat tool:

```typescript title="scripts/fassets/getLotSize.ts"
import { ethers } from "hardhat";
import { FAssetsSettingsContract } from "../../typechain-types";
// yarn hardhat run scripts/fassets/getLotSize.ts --network coston2

// 1. AssetManager address on Songbird Testnet Coston network
const ASSET_MANAGER_ADDRESS = "0x56728e46908fB6FcC5BCD2cc0c0F9BB91C3e4D34";
// 1. Get the contract artifact
const FAssetsSettings = artifacts.require("FAssetsSettings");

async function main() {
console.log("Deploying FAssetsSettings...");

// 2. Get the contract factory
const FAssetsSettings = (await ethers.getContractFactory(
"FAssetsSettings",
)) as FAssetsSettingsContract;

// 3. Deploy the contract
const fAssetsSettings = await FAssetsSettings.deploy(ASSET_MANAGER_ADDRESS);
await fAssetsSettings.waitForDeployment();
console.log(
"FAssetsSettings deployed to:",
await fAssetsSettings.getAddress(),
);

// 4. Call getSettings function
// 2. Deploy the contract
const fAssetsSettings = await FAssetsSettings.new();
console.log("FAssetsSettings deployed to:", fAssetsSettings.address);

// 3. Call getSettings function
const lotSize = await fAssetsSettings.getLotSize();
console.log("Lot size:", lotSize[0]);
console.log("Decimals:", lotSize[1]);

// 5. Convert lot size to XRP
// 4. Convert lot size to XRP
const lotSizeFXRP = Number(lotSize[0]) / Math.pow(10, Number(lotSize[1]));
console.log("Lot size in XRP", lotSizeFXRP);
}
Expand All @@ -96,18 +87,17 @@ main().catch((error) => {

### Code Explanation

1. Define the FAssets TXRP asset manager address on the Songbird Testnet Coston network.
2. Use the Typescript smart contract `FAssetsSettings` type to interact with the contract.
3. Deploy the `FAssetsSettings` on the network and get the contract address.
4. Call the `getLotSize` function to get the lot size and asset decimals.
5. Convert the lot size to XRP.
1. Get the contract artifact `FAssetsSettings` from the Hardhat artifacts.
2. Deploy the `FAssetsSettings` on the network and get the contract address.
3. Call the `getLotSize` function to get the lot size and asset decimals.
4. Convert the lot size to XRP.

## Run the Script

Now you can run the script using the Hardhat tool with the following command:

```bash
npx hardhat run scripts/fassets/getLotSize.ts --network coston
npx hardhat run scripts/fassets/getLotSize.ts --network coston2
```

You should see the following output:
Expand All @@ -126,9 +116,9 @@ Lot size in XRP 20
This script is included in the [Flare Hardhat Starter Kit](https://github.com/flare-foundation/flare-hardhat-starter).

:::
Congratulations! You have now deployed a Solidity helper contract and used a TypeScript script to
Congratulations! You have now deployed a Solidity helper contract and used a TypeScript script to:

- fetch FAsset FXRP lot size and decimals;
- convert the value to a user-friendly format using decimal precision.
- Fetch FAsset FXRP lot size and decimals
- Convert the value to a user-friendly format using decimal precision.

<ExploringAdditionalParameters />
35 changes: 18 additions & 17 deletions docs/fassets/developer-guides/5-fassets-minting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ The following code demonstrates how to reserve collateral by calling the [`reser

1. Define constants

- `ASSET_MANAGER_ADDRESS`: FXRP AssetManager address on Songbird Testnet (Coston).
- `LOTS_TO_MINT`: Number of FAsset lots to reserve.
- `UNDERLYING_ADDRESS`: Target XRP Ledger address for the minted asset.
- `ZERO_ADDRESS`: Placeholder for `executor` (not used in this script).

2. Retrieve and filter agents with enough free collateral and select the agent with the lowest fee and normal status.
3. Parse [`CollateralReserved`](/fassets/reference/IAssetManagerEvents#collateralreserved) event.
4. Start the minting reservation process at the script's entry point.
5. Call `findBestAgent` with the required number of lots.
6. Fetch agent metadata from [`getAgentInfo`](/fassets/reference/IAssetManager#getagentinfo) to get the agent's `feeBIPS`, which is used to calculate the collateral reservation fee.
7. Calculate the collateral reservation fee by calling [`collateralReservationFee`](/fassets/reference/IAssetManager#collateralreservationfee).
8. Reserve collateral from agent by calling [`reserveCollateral`](/fassets/reference/IAssetManager#reservecollateral)
9. Call `assetMintingDecimals` to determine the XRP token's decimal precision.
10. Parse the [`CollateralReserved`](/fassets/reference/IAssetManagerEvents#collateralreserved) event.
11. Calculate the total XRP value required for payment.
6. Get the asset manager from the [Flare Contract Registry](/network/guides/flare-contracts-registry).
7. Find the best agent with enough free collateral lots.
8. Fetch agent metadata from [`getAgentInfo`](/fassets/reference/IAssetManager#getagentinfo) to get the agent's `feeBIPS`, which is used to calculate the collateral reservation fee.
9. Calculate the collateral reservation fee by calling [`collateralReservationFee`](/fassets/reference/IAssetManager#collateralreservationfee).
10. Reserve collateral from agent by calling [`reserveCollateral`](/fassets/reference/IAssetManager#reservecollateral)
11. Call `assetMintingDecimals` to determine the XRP token's decimal precision.
12. Parse the [`CollateralReserved`](/fassets/reference/IAssetManagerEvents#collateralreserved) event.
13. Calculate the total XRP value required for payment.

## Send Payment on XRP Ledger

Expand Down Expand Up @@ -100,16 +100,17 @@ This script demonstrates how to retrieve the FDC proof and execute minting.
### Execute Minting Script Breakdown

1. Get environment variables.
2. Declare the constant `ASSET_MANAGER_ADDRESS` pointing to the FXRP AssetManager on the Songbird Testnet (Coston network).

3. Set the collateral reservation ID to the previously reserved minting request.
4. Set the Flare Data Connector (FDC) round ID to retrieve the proof.
5. Prepare the FDC request payload data.
6. Create a function to get the proof from the FDC.
2. Set the collateral reservation ID to the previously reserved minting request.
3. Set the FDC round ID to retrieve the proof.
4. Provide the FDC request data.
5. Import the Asset manager contract artifact.
6. Define the function to prepare the FDC request.
7. Create a function to get the proof from the FDC.
It sends a POST request to the [Flare Data Availability Layer](/fdc/overview#data-availability-layer) and returns a Merkle proof and attestation response from FDC.
7. Retrieve the FDC proof from the Data Availability Layer.
8. Call the [`executeMinting`](/fassets/reference/IAssetManager#executeminting) function on the AssetManager contract and send a transaction to the Flare network to convert the attested XRP payment into FXRP (minting).
9. On a successful transaction call `parseExecutemintingEvents` to extract and log events [`RedemptionTicketCreated`](/fassets/reference/IAssetManagerEvents#redemptionticketcreated) and [`MintingExecuted`](/fassets/reference/IAssetManagerEvents#mintingexecuted).
8. Define the function to parse the events.
9. Retrieve the FDC proof from the Data Availability Layer.
10. Call the [`executeMinting`](/fassets/reference/IAssetManager#executeminting) function on the AssetManager contract and send a transaction to the Flare network to convert the attested XRP payment into FXRP (minting).
11. On a successful transaction call `parseExecutemintingEvents` to extract and log events [`RedemptionTicketCreated`](/fassets/reference/IAssetManagerEvents#redemptionticketcreated) and [`MintingExecuted`](/fassets/reference/IAssetManagerEvents#mintingexecuted).

## Next Steps

Expand Down
30 changes: 15 additions & 15 deletions docs/fassets/developer-guides/6-fassets-minting-executor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,24 @@ The following code demonstrates how to reserve collateral by calling the [`reser

1. Define constants

- `ASSET_MANAGER_ADDRESS`: FXRP AssetManager address on Songbird Testnet (Coston).
- `LOTS_TO_MINT`: Number of FAssets [lots](/fassets/minting#lots) to reserve.
- `UNDERLYING_ADDRESS`: Target XRP Ledger address for the minted asset.
- `EXECUTOR_ADDRESS`: Executor address that will execute the minting process and provide the proof of underlying asset payment.

2. Retrieve and filter agents with enough free collateral and select the agent with the lowest fee and normal status.
3. Parse [`CollateralReserved`](/fassets/reference/IAssetManagerEvents#collateralreserved) event.
4. Start the minting reservation process at the script's entry point.
5. Call `findBestAgen` with the required number of lots.
6. Fetch agent metadata from [`getAgentInfo`](/fassets/reference/IAssetManager#getagentinfo) to get the agent's `feeBIPS`, which is used to calculate the collateral reservation fee.
7. Calculate the collateral reservation fee by calling [`collateralReservationFee`](/fassets/reference/IAssetManager#collateralreservationfee).
8. Set the executor fee the same as the collateral reservation fee to make this example simpler.
9. Reserve collateral from agent by calling [`reserveCollateral`](/fassets/reference/IAssetManager#reservecollateral) with the executor address.
The executor fee is on top of the collateral reservation fee in native tokens.
The fee is agreed between the minter and the executor.
10. Call `assetMintingDecimals` to determine the XRP token's decimal precision.
11. Parse the [`CollateralReserved`](/fassets/reference/IAssetManagerEvents#collateralreserved) event to get the collateral reservation ID and other important collateral reservation details.
12. Calculate the total XRP value required for payment.
2. Get the AssetManager artifact
3. Retrieve and filter agents with enough free collateral and select the agent with the lowest fee and normal status.
4. Parse [`CollateralReserved`](/fassets/reference/IAssetManagerEvents#collateralreserved) event.
5. Start the minting reservation process at the script's entry point.
6. Get the asset manager artifact.
7. Call `findBestAgent` with the required number of lots.
8. Fetch agent metadata from [`getAgentInfo`](/fassets/reference/IAssetManager#getagentinfo) to get the agent's `feeBIPS`, which is used to calculate the collateral reservation fee.
9. Calculate the collateral reservation fee by calling [`collateralReservationFee`](/fassets/reference/IAssetManager#collateralreservationfee).
10. Set the executor fee the same as the collateral reservation fee to make this example simpler.
11. Reserve collateral from agent by calling [`reserveCollateral`](/fassets/reference/IAssetManager#reservecollateral) with the executor address.
The executor fee is on top of the collateral reservation fee in native tokens.
The fee is agreed between the minter and the executor.
12. Call `assetMintingDecimals` to determine the XRP token's decimal precision.
13. Parse the [`CollateralReserved`](/fassets/reference/IAssetManagerEvents#collateralreserved) event to get the collateral reservation ID and other important collateral reservation details.
14. Calculate the total XRP value required for payment.

## Send Payment on XRP Ledger

Expand Down
Loading