# Read FAssets Settings (Node)

> Fetch FAsset Lot Size and Value in USD (via FTSO)

> 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-node

## Overview[​](#overview "Direct link to Overview")

In this guide, you will build a TypeScript script that connects to the [Flare Testnet Coston2](/network/solidity-reference) and:

-   Fetches [FAssets configuration settings](/fassets/operational-parameters) and gets the [lot size](/fassets/minting#lots) for FXRP
-   Retrieves the XRP/USD price from the [FTSO](/ftso/overview)
-   Calculates the USD value of one FAssets FXRP lot

This guide is a perfect first step for developers working with FAssets.

## 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 Project Directory[​](#create-project-directory "Direct link to Create Project Directory")

Create a new directory for your project and initialize a new npm project:

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

### Install Dependencies[​](#install-dependencies "Direct link to Install Dependencies")

Install the following dependencies:

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

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

Create a `tsconfig.json` file:

```
npx tsc --init
```

Update `tsconfig.json` as follows:

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"]}
```

### Update Package Configuration[​](#update-package-configuration "Direct link to Update Package Configuration")

Change `package.json` to use ES modules and add a build script:

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

## Implementation[​](#implementation "Direct link to Implementation")

### Create Script File[​](#create-script-file "Direct link to Create Script File")

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

Open `scripts/fassets-settings.ts` in your favorite code editor.

### Import Dependencies[​](#import-dependencies "Direct link to Import Dependencies")

Import viem to interact with the blockchain and the `coston2` namespace from the [`@flarenetwork/flare-wagmi-periphery-package`](https://www.npmjs.com/package/@flarenetwork/flare-wagmi-periphery-package), which provides all typed contract ABIs for the Coston2 network:

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

### Define Constants[​](#define-constants "Direct link to Define Constants")

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

### Create a Client[​](#create-a-client "Direct link to Create a Client")

Create a viem public client connected to Coston2:

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

### Get the FAssets FXRP Asset Manager Address[​](#get-the-fassets-fxrp-asset-manager-address "Direct link to Get the FAssets FXRP Asset Manager Address")

Resolve the FXRP Asset Manager address 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"],});
```

### Implement Settings Retrieval[​](#implement-settings-retrieval "Direct link to Implement Settings Retrieval")

Fetch the FAssets configuration settings using the [`getSettings`](/fassets/reference/IAssetManager#getsettings) function and calculate the FXRP lot size:

```
const settings = await client.readContract({  address: assetManagerAddress,  abi: coston2.iAssetManagerAbi,  functionName: "getSettings",});const lotSizeFXRP =  Number(settings.lotSizeAMG) / Math.pow(10, Number(settings.assetDecimals));console.log("Lot Size (FXRP):", lotSizeFXRP);
```

info

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.

## Convert Lot Size to USD[​](#convert-lot-size-to-usd "Direct link to Convert Lot Size to USD")

To convert the lot size to USD, fetch the XRP/USD [anchor price feed](/ftso/scaling/anchor-feeds) from the [FTSO](/ftso/overview).

### Get the FtsoV2 Address[​](#get-the-ftsov2-address "Direct link to Get the FtsoV2 Address")

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

### Get the Price Feed[​](#get-the-price-feed "Direct link to Get the Price Feed")

`getFeedById` is a `payable` function, so use `simulateContract` to call it without sending a transaction:

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

### Convert Lot Size to USD[​](#convert-lot-size-to-usd-1 "Direct link to Convert Lot Size to USD")

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

## Putting All Together[​](#putting-all-together "Direct link to Putting All Together")

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",});const lotSizeFXRP =  Number(settings.lotSizeAMG) / Math.pow(10, Number(settings.assetDecimals));console.log("Lot Size (FXRP):", lotSizeFXRP);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));const lotValueUSD = lotSizeFXRP * xrpUsdPrice;console.log("XRP/USD Price:", xrpUsdPrice);console.log("Lot value in USD:", lotValueUSD);console.log("Timestamp:", _timestamp.toString());
```

## Running the Script[​](#running-the-script "Direct link to Running the Script")

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

You should see the following output:

```
Lot Size (FXRP): 10XRP/USD Price: 2.843861Lot value in USD: 28.43861Timestamp: 1756977702
```

## 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.

## Summary[​](#summary "Direct link to Summary")

Congratulations! You have built a TypeScript script that connects to the Coston2 network and retrieves the FAsset configuration settings and the price of XRP in USD.

What's next

To continue your FAssets development journey, you can:

-   Learn how to [mint FXRP](/fassets/developer-guides/fassets-direct-minting).
-   Understand how to [redeem FXRP](/fassets/developer-guides/fassets-redeem).
-   Explore [FAssets system settings](/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.
