You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -19,44 +16,20 @@ These addresses can change between Flare testnets and mainnet deployments, and r
19
16
20
17
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.
21
18
22
-
In this guide, you will learn:
19
+
## Get the FXRP Asset Manager Address
23
20
24
-
- How to retrieve the [Asset Manager Controller](/fassets/reference/IAssetManagerController) using the Flare Contract Registry.
25
-
- How to find the specific FXRP [Asset Manager](/fassets/reference/IAssetManager).
26
-
- A sample Solidity contract that encapsulates this logic.
21
+
To get the [FAssets asset manager](/fassets/reference/IAssetManager) address, you can use the [Flare Contract Registry](/network/guides/flare-contracts-registry) library.
22
+
It is included in the [Flare Periphery Contracts package](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts).
27
23
28
-
## Sample code
24
+
The following example demonstrates how to get the FXRP Asset Manager address using the Flare Contract Registry library in a Solidity contract.
29
25
30
-
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).
26
+
```solidity
27
+
import { ContractRegistry } from "@flarenetwork/flare-periphery-contracts/coston2/ContractRegistry.sol";
28
+
import {IAssetManager} from "@flarenetwork/flare-periphery-contracts/coston2/IAssetManager.sol";
<RemixfileName="FAssetsAssetManagerRegistry.sol">Open in Remix</Remix>
38
-
<br></br>
39
-
40
-
### Contract Breakdown
41
-
42
-
1. Imports the necessary interfaces and libraries from the [Flare Periphery Contracts package](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts).
43
-
2. Defines a constant `TXRP_HASH` that is the hash of the string `TXRP`.
44
-
This is used to identify the FXRP asset manager.
45
-
3. Implements a function `getFxrpAssetManager` that returns the FXRP [Asset Manager](/fassets/reference/IAssetManager) address.
46
-
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.
47
-
5. Uses the `IAssetManagerController` interface from the Flare Periphery Contracts package to get all the asset managers from the Asset Manager Controller.
48
-
6. Iterates over the asset managers and returns the FXRP Asset Manager address.
49
-
7. Gets the settings of the asset manager.
50
-
8. Checks if the pool token suffix is `TXRP` and if true returns the FXRP Asset Manager address.
51
-
52
-
You can find out this sample code in the [Flare starter kit](/network/guides/hardhat-foundry-starter-kit).
53
-
54
-
:::tip Reusable Library
55
-
56
-
To reuse this code to get the FXRP Asset Manager address in other smart contracts, you can wrap it in a reusable library.
57
-
This is useful if you want to use the FXRP Asset Manager address in multiple smart contracts and avoid repeating the same code.
58
-
59
-
:::
30
+
// Get the FXRP Asset Manager address from the Flare contracts registry
2. Calls the [`fAsset`](/fassets/reference/IAssetManager#fasset) function to get the FXRP token address.
56
55
3. Logs the address to the console.
57
56
57
+
:::info
58
+
The `getFXRPAssetManagerAddress` function is a utility function that is included in the [Flare Hardhat Starter Kit](/network/guides/hardhat-foundry-starter-kit).
59
+
It is used to get the FXRP Asset Manager address from the Flare Contract Registry.
60
+
:::
61
+
58
62
### Run the Script
59
63
60
64
To run the script, use the following command:
@@ -81,7 +85,7 @@ Once you have the FXRP address, you can:
81
85
2. Add it to your wallet to track FXRP balances
82
86
3. Use it in DeFi protocols that support FXRP
83
87
84
-
:::tip Next Steps
88
+
##Next Steps
85
89
86
90
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.
87
91
@@ -91,5 +95,3 @@ To continue your FAssets development journey, you can:
91
95
- Understand how to [redeem FXRP](/fassets/developer-guides/fassets-redeem).
92
96
- Explore [FAssets system settings](/fassets/operational-parameters).
93
97
- Check the [lot size](/fassets/developer-guides/fassets-settings-node) for FXRP operations.
Copy file name to clipboardExpand all lines: docs/fassets/developer-guides/3-fassets-asset-manager-settings-solidity.mdx
+28-38Lines changed: 28 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,14 +37,17 @@ To get the FAsset lot size, you can use the following smart contract:
37
37
38
38
### Code Breakdown
39
39
40
-
1.Importtheinterface `IAssetManager` fromthe [FlarePeripheryContractspackage](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts), which provides access to the FAssets system.
2.Importtheinterface `IAssetManager` fromthe [FlarePeripheryContractspackage](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts), which provides access to the FAssets system.
4. Start the minting reservation process at the script's entry point.
58
56
5. Call `findBestAgent` with the required number of lots.
59
-
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.
60
-
7. Calculate the collateral reservation fee by calling [`collateralReservationFee`](/fassets/reference/IAssetManager#collateralreservationfee).
61
-
8. Reserve collateral from agent by calling [`reserveCollateral`](/fassets/reference/IAssetManager#reservecollateral)
62
-
9. Call `assetMintingDecimals` to determine the XRP token's decimal precision.
63
-
10. Parse the [`CollateralReserved`](/fassets/reference/IAssetManagerEvents#collateralreserved) event.
64
-
11. Calculate the total XRP value required for payment.
57
+
6. Get the asset manager from the [Flare Contract Registry](/network/guides/flare-contracts-registry).
58
+
7. Find the best agent with enough free collateral lots.
59
+
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.
60
+
9. Calculate the collateral reservation fee by calling [`collateralReservationFee`](/fassets/reference/IAssetManager#collateralreservationfee).
61
+
10. Reserve collateral from agent by calling [`reserveCollateral`](/fassets/reference/IAssetManager#reservecollateral)
62
+
11. Call `assetMintingDecimals` to determine the XRP token's decimal precision.
63
+
12. Parse the [`CollateralReserved`](/fassets/reference/IAssetManagerEvents#collateralreserved) event.
64
+
13. Calculate the total XRP value required for payment.
65
65
66
66
## Send Payment on XRP Ledger
67
67
@@ -100,16 +100,17 @@ This script demonstrates how to retrieve the FDC proof and execute minting.
100
100
### Execute Minting Script Breakdown
101
101
102
102
1. Get environment variables.
103
-
2.Declare the constant `ASSET_MANAGER_ADDRESS` pointing to the FXRP AssetManager on the Songbird Testnet (Coston network).
104
-
105
-
3. Set the collateral reservation ID to the previously reserved minting request.
106
-
4. Set the Flare Data Connector (FDC) round ID to retrieve the proof.
107
-
5. Prepare the FDC request payload data.
108
-
6. Create a function to get the proof from the FDC.
103
+
2.Set the collateral reservation ID to the previously reserved minting request.
104
+
3. Set the FDC round ID to retrieve the proof.
105
+
4. Provide the FDC request data.
106
+
5.ImporttheAssetmanagercontractartifact.
107
+
6. Define the function to prepare the FDC request.
108
+
7. Create a function to get the proof from the FDC.
109
109
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.
110
-
7. Retrieve the FDC proof from the Data Availability Layer.
111
-
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).
112
-
9. On a successful transaction call `parseExecutemintingEvents` to extract and log events [`RedemptionTicketCreated`](/fassets/reference/IAssetManagerEvents#redemptionticketcreated) and [`MintingExecuted`](/fassets/reference/IAssetManagerEvents#mintingexecuted).
110
+
8. Define the function to parse the events.
111
+
9. Retrieve the FDC proof from the Data Availability Layer.
112
+
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).
113
+
11. On a successful transaction call `parseExecutemintingEvents` to extract and log events [`RedemptionTicketCreated`](/fassets/reference/IAssetManagerEvents#redemptionticketcreated) and [`MintingExecuted`](/fassets/reference/IAssetManagerEvents#mintingexecuted).
4. Start the minting reservation process at the script's entry point.
68
-
5. Call `findBestAgen` with the required number of lots.
69
-
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.
70
-
7. Calculate the collateral reservation fee by calling [`collateralReservationFee`](/fassets/reference/IAssetManager#collateralreservationfee).
71
-
8. Set the executor fee the same as the collateral reservation fee to make this example simpler.
72
-
9. Reserve collateral from agent by calling [`reserveCollateral`](/fassets/reference/IAssetManager#reservecollateral) with the executor address.
73
-
The executor fee is on top of the collateral reservation fee in native tokens.
74
-
The fee is agreed between the minter and the executor.
75
-
10. Call `assetMintingDecimals` to determine the XRP token's decimal precision.
76
-
11. Parse the [`CollateralReserved`](/fassets/reference/IAssetManagerEvents#collateralreserved) event to get the collateral reservation ID and other important collateral reservation details.
77
-
12. Calculate the total XRP value required for payment.
63
+
2. Get the AssetManager artifact
64
+
3. Retrieve and filter agents with enough free collateral and select the agent with the lowest fee and normal status.
5. Start the minting reservation process at the script's entry point.
67
+
6. Get the asset manager artifact.
68
+
7. Call `findBestAgent` with the required number of lots.
69
+
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.
70
+
9. Calculate the collateral reservation fee by calling [`collateralReservationFee`](/fassets/reference/IAssetManager#collateralreservationfee).
71
+
10. Set the executor fee the same as the collateral reservation fee to make this example simpler.
72
+
11. Reserve collateral from agent by calling [`reserveCollateral`](/fassets/reference/IAssetManager#reservecollateral) with the executor address.
73
+
The executor fee is on top of the collateral reservation fee in native tokens.
74
+
The fee is agreed between the minter and the executor.
75
+
12. Call `assetMintingDecimals` to determine the XRP token's decimal precision.
76
+
13. Parse the [`CollateralReserved`](/fassets/reference/IAssetManagerEvents#collateralreserved) event to get the collateral reservation ID and other important collateral reservation details.
77
+
14. Calculate the total XRP value required for payment.
0 commit comments