# xSolvBTC Oracle on Stellar

## Introduction

Solv finance currently has one vault, xSolvBTC, deployed on the Stellar chain. This setup distinguishes the oracle contract from the vault contract.

<figure><img src="/files/MImdY40GuyJ02lJEafp8" alt=""><figcaption></figcaption></figure>

The xSolvBTC Oracle address is [CD2KTWZ3S7BDDNPHJMUYYUDY5B7J4JL4GXVITLMUEPSE5BNTESUOM4LQ](https://stellar.expert/explorer/public/contract/CD2KTWZ3S7BDDNPHJMUYYUDY5B7J4JL4GXVITLMUEPSE5BNTESUOM4LQ) and all information is stored in the data storage  of that address.&#x20;

The getLedgerEntries RPC method provided by Stellar allows for the retrieval of current ledger entry values, such as contract code and data. This functionality can be utilized to read data from our oracle contract.&#x20;

## Read Solv Oracle Contract Data

xSolvBTC Oracle is a soroban contract and compiled as WebAssembly (Wasm) for deployment. The contract data is stored in the Stellar ledger as a LedgerKeyContractInstance type. This information allows us to construct a ledger key to locate the desired data.

### Step1. KeyLedger Formation

The ledgerKey is obtained by providing the contract address and the relevant key type.

```typescript
import {xdr, Address, scValToNative} from "@stellar/stellar-sdk"
import { Server } from "@stellar/stellar-sdk/rpc";

const oracleContratId = "CD2KTWZ3S7BDDNPHJMUYYUDY5B7J4JL4GXVITLMUEPSE5BNTESUOM4LQ";
const oracleScAddress = Address.fromString(oracleContratId).toScAddress();
const url = "https://mainnet.sorobanrpc.com/";
const server = new Server(url);
// ledgerKeyContractInstance durability is persistent
const ledgerKeyContractInstance = xdr.LedgerKey.contractData(new xdr.LedgerKeyContractData({
        contract: oracleScAddress,
        key: xdr.ScVal.scvLedgerKeyContractInstance(),
        durability: xdr.ContractDataDurability.persistent()
    }));

```

### Step2. Get Nav and Decimal

This ledgerKey is then used to call the getLedgerEntries function to retrieve the associated data.

```typescript
let response = await server.getLedgerEntries(ledgerKeyContractInstance);
if (response.entries ) {
   for (const entry of response.entries) {
      const contractData = entry.val.contractData();
      const instanceValue = contractData.val();
      let storage = instanceValue.instance().storage();
      for (const item of storage) {
         console.log("key: ", scValToNative(item.key()), "value: ", scValToNative(item.val()));
      }
   }
}

```

The final outcome is obtained as follows.

```shellscript
key:  [ 'Nav' ] value:  100000000n
key:  [ 'NavDecimals' ] value:  8
key:  [ 'Owner' ] value:  GBHZ6UQZG2VGVGL4DGEX3B5KTRZ3CDLE27TOWOY5WQUZK2GQMUGUEQVN

```

## Conclusion

Oracle contract stores nav and navDecimal in its storage area. This is the general approach for accessing any data stored within the contract.

\ <br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.solv.finance/developer-guide/oracle-mechanism/xsolvbtc-oracle-on-stellar.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
