|
| 1 | +--- |
| 2 | +title: Read FAssets Agent Details |
| 3 | +tags: [intermediate, fassets] |
| 4 | +slug: fassets-agent-details |
| 5 | +description: Learn how to read FAssets agent details |
| 6 | +keywords: [fassets, flare-network] |
| 7 | +sidebar_position: 9 |
| 8 | +--- |
| 9 | + |
| 10 | +import CodeBlock from "@theme/CodeBlock"; |
| 11 | +import Remix from "@site/src/components/remix"; |
| 12 | + |
| 13 | +## Overview |
| 14 | + |
| 15 | +In this guide, you will learn how to read FAssets agent details such as agent name, description, logo, and terms of use using the [AgentOwnerRegistry](fassets/reference/IAgentOwnerRegistry) smart contract. |
| 16 | +This information is essential for building user interfaces that display agent information or for validating agent credentials in your applications. |
| 17 | + |
| 18 | +## Prerequisites |
| 19 | + |
| 20 | +- Basic understanding of [FAssets system](/fassets/overview). |
| 21 | +- [Flare Network Periphery Contracts](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts) package. |
| 22 | + |
| 23 | +## Understanding FAssets Agents |
| 24 | + |
| 25 | +FAssets agents are entities that manage the minting and redemption of FAssets tokens. Each agent has: |
| 26 | + |
| 27 | +- **Management Address**: The address that controls the agent's operations. |
| 28 | +- **Agent Name**: Agent's display name. |
| 29 | +- **Description**: Detailed information about the agent. |
| 30 | +- **Icon URL**: Link to the agent's logo or branding image. |
| 31 | +- **Terms of Use URL**: Link to the agent's terms and conditions. |
| 32 | + |
| 33 | +## Step-by-Step Implementation |
| 34 | + |
| 35 | +### Get the AgentOwnerRegistry Contract Address |
| 36 | + |
| 37 | +The [AgentOwnerRegistry](/fassets/reference/IAgentOwnerRegistry) contract address is stored in the FAssets Asset Manager settings. |
| 38 | +Here's how to retrieve it: |
| 39 | + |
| 40 | +```solidity |
| 41 | +import {IAssetManager} from "@flarenetwork/flare-periphery-contracts/coston2/IAssetManager.sol"; |
| 42 | +import {ContractRegistry} from "@flarenetwork/flare-periphery-contracts/coston2/ContractRegistry.sol"; |
| 43 | +
|
| 44 | +// Get the Asset Manager instance |
| 45 | +IAssetManager assetManager = ContractRegistry.getAssetManagerFXRP(); |
| 46 | +
|
| 47 | +// Retrieve the AgentOwnerRegistry address from settings |
| 48 | +address agentOwnerRegistry = assetManager.getSettings().agentOwnerRegistry; |
| 49 | +``` |
| 50 | + |
| 51 | +### Access the AgentOwnerRegistry Contract |
| 52 | + |
| 53 | +Create an interface instance to interact with the AgentOwnerRegistry: |
| 54 | + |
| 55 | +```solidity |
| 56 | +import {IAgentOwnerRegistry} from "@flarenetwork/flare-periphery-contracts/coston2/IAgentOwnerRegistry.sol"; |
| 57 | +
|
| 58 | +IAgentOwnerRegistry agentOwnerRegistryContract = IAgentOwnerRegistry(agentOwnerRegistry); |
| 59 | +``` |
| 60 | + |
| 61 | +### Read Agent Details |
| 62 | + |
| 63 | +The [AgentOwnerRegistry](/fassets/reference/IAgentOwnerRegistry) provides several functions to retrieve agent information. |
| 64 | +All functions require the agent's management address as a parameter: |
| 65 | + |
| 66 | +#### Available Functions |
| 67 | + |
| 68 | +- [`getAgentName(address _managementAddress)`](/fassets/reference/IAgentOwnerRegistry#getagentname) - Returns the agent's display name. |
| 69 | +- [`getAgentDescription(address _managementAddress)`](/fassets/reference/IAgentOwnerRegistry#getDescription) - Returns the agent's description. |
| 70 | +- [`getAgentIconUrl(address _managementAddress)`](/fassets/reference/IAgentOwnerRegistry#getagenticonurl) - Returns the URL to the agent's icon/logo. |
| 71 | +- [`getAgentTermsOfUseUrl(address _managementAddress)`](/fassets/reference/IAgentOwnerRegistry#getagenttermsofuseurl) - Returns the URL to the agent's terms of use. |
| 72 | + |
| 73 | +#### Complete Example Function |
| 74 | + |
| 75 | +Here's a complete Solidity language function that retrieves all agent details in a single call: |
| 76 | + |
| 77 | +```solidity |
| 78 | +function getAgentDetails(address _managementAddress) external view |
| 79 | + returns (string memory name, string memory description, string memory iconUrl, string memory termsOfUseUrl) { |
| 80 | + |
| 81 | + // Get Asset Manager and AgentOwnerRegistry |
| 82 | + IAssetManager assetManager = ContractRegistry.getAssetManagerFXRP(); |
| 83 | + address agentOwnerRegistryAddress = assetManager.getSettings().agentOwnerRegistry; |
| 84 | + IAgentOwnerRegistry agentOwnerRegistry = IAgentOwnerRegistry(agentOwnerRegistryAddress); |
| 85 | +
|
| 86 | + // Retrieve all agent details |
| 87 | + name = agentOwnerRegistry.getAgentName(_managementAddress); |
| 88 | + description = agentOwnerRegistry.getAgentDescription(_managementAddress); |
| 89 | + iconUrl = agentOwnerRegistry.getAgentIconUrl(_managementAddress); |
| 90 | + termsOfUseUrl = agentOwnerRegistry.getAgentTermsOfUseUrl(_managementAddress); |
| 91 | +
|
| 92 | + return (name, description, iconUrl, termsOfUseUrl); |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +## Conclusion |
| 97 | + |
| 98 | +In this guide, you learned how to read FAssets agent details using the [AgentOwnerRegistry](/fassets/reference/IAgentOwnerRegistry) smart contract. |
| 99 | +This functionality is crucial for building user interfaces that display agent information and for validating agent credentials in your applications. |
| 100 | + |
| 101 | +The complete implementation examples are available in the [Flare Hardhat Starter Kit](/network/guides/hardhat-foundry-starter-kit). |
| 102 | + |
| 103 | +:::tip Next Steps |
| 104 | +To continue your FAssets development journey, you can: |
| 105 | + |
| 106 | +- Learn how to [mint FXRP](/fassets/developer-guides/fassets-mint) |
| 107 | +- Understand how to [redeem FXRP](/fassets/developer-guides/fassets-redeem) |
| 108 | +- Explore [FAssets system settings](/fassets/operational-parameters) |
| 109 | +::: |
0 commit comments