# Read FAssets Settings

> Read FXRP Asset Manager settings and the XRP/USD price, in TypeScript or Solidity.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

Source: https://dev.flare.network/fassets/developer-guides/fassets-settings

Read FXRP settings from [`getSettings`](/fassets/reference/IAssetManager#getsettings) on `AssetManagerFXRP`. Examples below use Coston2.

The TypeScript tab calls the Asset Manager with viem and reads the XRP/USD price from the FTSO. The Solidity tab deploys a helper that reads the same asset decimals.

Resolve the Asset Manager from the registry first. See [Resolve Asset Manager and FXRP](/fassets/developer-guides/fassets-asset-manager-address-contracts-registry).

## TypeScript[​](#typescript "Direct link to TypeScript")

This script connects to [Coston2](/network/overview) and:

-   Reads [FAssets settings](/fassets/operational-parameters), including FXRP asset decimals.
-   Reads the XRP/USD price from the [FTSO](/ftso/overview).

### Prerequisites[​](#prerequisites "Direct link to Prerequisites")

-   [Node.js](https://nodejs.org/en/download/)
-   [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm/)
-   [TypeScript](https://www.typescriptlang.org/download/)
-   [Viem](https://viem.sh)
-   [Flare Wagmi Periphery Package](https://www.npmjs.com/package/@flarenetwork/flare-wagmi-periphery-package)

### Project setup[​](#project-setup "Direct link to Project setup")

Create a directory and initialize npm:

```
mkdir fassets-settings-ftsocd fassets-settings-ftsonpm init -y
```

Install the dependencies:

```
npm install --save-dev \  typescript \  viem \  @flarenetwork/flare-wagmi-periphery-package
```

Create `tsconfig.json`:

```
npx tsc --init
```

tsconfig.json

```
{  "compilerOptions": {    "rootDir": "./scripts",    "outDir": "./dist",    "module": "esnext",    "moduleResolution": "node",    "target": "esnext",    "lib": ["dom", "dom.iterable", "esnext"],    "types": ["node"],    "esModuleInterop": true,    "forceConsistentCasingInFileNames": true,    "strict": true,    "skipLibCheck": true  },  "include": ["scripts/**/*.ts"],  "exclude": ["node_modules"]}
```

In `package.json`, use ES modules and add a build script:

```
"type": "module","scripts": {  "build": "tsc"}
```

### Script[​](#script "Direct link to Script")

```
mkdir scriptstouch scripts/fassets-settings.ts
```

Import viem and the `coston2` namespace from [`@flarenetwork/flare-wagmi-periphery-package`](https://www.npmjs.com/package/@flarenetwork/flare-wagmi-periphery-package):

```
import { createPublicClient, http } from "viem";import { flareTestnet } from "viem/chains";import { coston2 } from "@flarenetwork/flare-wagmi-periphery-package";
```

```
const FLARE_CONTRACT_REGISTRY_ADDRESS =  "0xaD67FE66660Fb8dFE9d6b1b4240d8650e30F6019" as const;const XRP_USD_FEED_ID = "0x015852502f55534400000000000000000000000000" as const;
```

```
const client = createPublicClient({  chain: flareTestnet,  transport: http(),});
```

Resolve `AssetManagerFXRP` from the [Flare Contract Registry](/network/guides/flare-contracts-registry):

```
const assetManagerAddress = await client.readContract({  address: FLARE_CONTRACT_REGISTRY_ADDRESS,  abi: coston2.iFlareContractRegistryAbi,  functionName: "getContractAddressByName",  args: ["AssetManagerFXRP"],});
```

Read [`getSettings`](/fassets/reference/IAssetManager#getsettings) and log the asset decimals:

```
const settings = await client.readContract({  address: assetManagerAddress,  abi: coston2.iAssetManagerAbi,  functionName: "getSettings",});console.log("Asset decimals:", settings.assetDecimals);
```

The same call returns the rest of the [operational parameters](/fassets/operational-parameters#asset-manager-operational-parameters).

### Read the XRP/USD price[​](#read-the-xrpusd-price "Direct link to Read the XRP/USD price")

Read the XRP/USD [anchor feed](/ftso/scaling/anchor-feeds) from [FTSO](/ftso/overview).

```
const ftsoAddress = await client.readContract({  address: FLARE_CONTRACT_REGISTRY_ADDRESS,  abi: coston2.iFlareContractRegistryAbi,  functionName: "getContractAddressByName",  args: ["FtsoV2"],});
```

`getFeedById` is `payable`, so use `simulateContract`:

```
const {  result: [_value, _decimals, _timestamp],} = await client.simulateContract({  address: ftsoAddress,  abi: coston2.ftsoV2InterfaceAbi,  functionName: "getFeedById",  args: [XRP_USD_FEED_ID],  value: 0n,});
```

```
const xrpUsdPrice = Number(_value) / Math.pow(10, Number(_decimals));console.log("XRP/USD Price:", xrpUsdPrice);console.log("Timestamp:", _timestamp.toString());
```

### Full script[​](#full-script "Direct link to Full script")

scripts/fassets-settings.ts

```
import { createPublicClient, http } from "viem";import { flareTestnet } from "viem/chains";import { coston2 } from "@flarenetwork/flare-wagmi-periphery-package";const FLARE_CONTRACT_REGISTRY_ADDRESS =  "0xaD67FE66660Fb8dFE9d6b1b4240d8650e30F6019" as const;const XRP_USD_FEED_ID = "0x015852502f55534400000000000000000000000000" as const;const client = createPublicClient({  chain: flareTestnet,  transport: http(),});const assetManagerAddress = await client.readContract({  address: FLARE_CONTRACT_REGISTRY_ADDRESS,  abi: coston2.iFlareContractRegistryAbi,  functionName: "getContractAddressByName",  args: ["AssetManagerFXRP"],});const settings = await client.readContract({  address: assetManagerAddress,  abi: coston2.iAssetManagerAbi,  functionName: "getSettings",});console.log("Asset decimals:", settings.assetDecimals);const ftsoAddress = await client.readContract({  address: FLARE_CONTRACT_REGISTRY_ADDRESS,  abi: coston2.iFlareContractRegistryAbi,  functionName: "getContractAddressByName",  args: ["FtsoV2"],});const {  result: [_value, _decimals, _timestamp],} = await client.simulateContract({  address: ftsoAddress,  abi: coston2.ftsoV2InterfaceAbi,  functionName: "getFeedById",  args: [XRP_USD_FEED_ID],  value: 0n,});const xrpUsdPrice = Number(_value) / Math.pow(10, Number(_decimals));console.log("XRP/USD Price:", xrpUsdPrice);console.log("Timestamp:", _timestamp.toString());
```

### Run[​](#run "Direct link to Run")

```
npm run buildnode dist/fassets-settings.js
```

```
Asset decimals: 6XRP/USD Price: 2.843861Timestamp: 1756977702
```

## Solidity[​](#solidity "Direct link to Solidity")

Deploy a helper that reads FXRP asset decimals through `ContractRegistry`, then call it from Hardhat on Coston2.

### Prerequisites[​](#prerequisites-1 "Direct link to Prerequisites")

-   [Flare Hardhat Starter Kit](/network/guides/hardhat-foundry-starter-kit)
-   [Flare Network Periphery Contracts](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts)
-   Node.js, TypeScript, and a Hardhat config with Coston2

### Contract[​](#contract "Direct link to Contract")

contracts/FAssetsSettings.sol

```
// SPDX-License-Identifier: MITpragma solidity ^0.8.25;// 1. Import the Flare Contract Registryimport {ContractRegistry} from "@flarenetwork/flare-periphery-contracts/coston2/ContractRegistry.sol";// 2. Import the AssetManager interfaceimport {IAssetManager} from "@flarenetwork/flare-periphery-contracts/coston2/IAssetManager.sol";// 3. Contract for accessing FAssets settings from the asset managercontract FAssetsSettings {    // 4. Read how many decimal places FXRP uses.    // FAssets Operation Parameters https://dev.flare.network/fassets/operational-parameters    function getAssetDecimals() public view returns (uint8 assetDecimals) {        // 5. Get the AssetManager contract from the Flare Contract Registry        IAssetManager assetManager = ContractRegistry.getAssetManagerFXRP();        // 6. Read asset decimals from the AssetManager settings        assetDecimals = assetManager.getSettings().assetDecimals;        return assetDecimals;    }}
```

[Open in Remix](https://remix.ethereum.org/#url=https://github.com/flare-foundation/developer-hub/blob/main/examples/developer-hub-solidity/FAssetsAssetManagerSettings.sol&version=builtin&evmVersion=cancun&optimize=true&runs=200)

1.  Import the [ContractRegistry library](/network/guides/flare-contracts-registry#contract-registry-library).
2.  Import `IAssetManager` from [`@flarenetwork/flare-periphery-contracts`](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts).
3.  `FAssetsSettings` resolves the FXRP Asset Manager and calls [`getSettings`](/fassets/reference/IAssetManager#getsettings).
4.  `getAssetDecimals` returns `assetDecimals`. The full settings list is on [FAssets Operational Parameters](/fassets/operational-parameters#asset-manager-operational-parameters).

### Deploy and read[​](#deploy-and-read "Direct link to Deploy and read")

scripts/fassets/getAssetDecimals.ts

```
// yarn hardhat run scripts/fassets/getAssetDecimals.ts --network coston2const FAssetsSettings = artifacts.require("FAssetsSettings");async function main() {  const fAssetsSettings = await FAssetsSettings.new();  console.log("FAssetsSettings deployed to:", fAssetsSettings.address);  const assetDecimals = await fAssetsSettings.getAssetDecimals();  console.log("Asset decimals:", assetDecimals.toString());}main().catch((error) => {  console.error(error);  process.exitCode = 1;});
```

```
yarn hardhat run scripts/fassets/getAssetDecimals.ts --network coston2
```

```
Compiled 1 Solidity file successfully (evm target: cancun).Deploying FAssetsSettings...FAssetsSettings deployed to: 0x40deEaA76224Ca9439D4e1c86F827Be829b89D9EAsset decimals: 6
```

## Exploring Additional Parameters[​](#exploring-additional-parameters "Direct link to Exploring Additional Parameters")

The FAssets asset manager exposes key parameters like collateral ratios, minting fees, and liquidation thresholds via the `getSettings` function. See the [FAssets Operational Parameters](/fassets/operational-parameters#asset-manager-operational-parameters) for details.

What's next

-   [Mint FXRP](/fassets/developer-guides/fassets-mint).
-   [Redeem FXRP](/fassets/developer-guides/fassets-redeem-amount).
-   Browse [FAssets operational parameters](/fassets/operational-parameters).

FAssets demo dApp

The [FAssets demo dApp](https://fassets-demo-dapp.vercel.app/) showcases the FAssets system using the [Flare wagmi periphery package](https://www.npmjs.com/package/@flarenetwork/flare-wagmi-periphery-package). This app is a Next.js reference implementation for settings, minting, tags, transfer, and redeem functionality.

The source code is available in the [fassets-demo-dapp](https://github.com/flare-foundation/fassets-demo-dapp) repository.
