# Fetch

Once Inscription Accounts are [initialized](https://developers.metaplex.com/inscription/initialize) their Metadata can be read from chain again. Once data is [written](https://developers.metaplex.com/inscription/write) it can also be read. To fetch inscriptions you also have to use different functions according to the inscription type.

### Fetch inscription Metadata <a href="#fetch-inscription-metadata" id="fetch-inscription-metadata"></a>

Both inscription types use a metadata account. This Account contains for example the `inscriptionRank`, `associatedInscriptions`, `updateAuthorities` and [more](https://mpl-inscription.typedoc.metaplex.com/types/InscriptionMetadata.html). The Metadata can be fetched like so:

Fetch Inscription Metadata

JavaScript

```
import { safeFetchInscriptionMetadataFromSeeds } from '@metaplex-foundation/mpl-inscription'

const inscriptionMetadataAccount = await safeFetchInscriptionMetadataFromSeeds(
  umi,
  {
    inscriptionAccount: inscriptionAccount.publicKey,
  }
)

console.log(inscriptionMetadataAccount)
```

### Fetch mint inscription <a href="#fetch-mint-inscription" id="fetch-mint-inscription"></a>

To fetch the deserialized mint inscription you can use `safeFetchMintInscriptionFromSeeds` like so:

Fetch Mint Inscription

JavaScript

```
import { fetchInscription, safeFetchMintInscriptionFromSeeds, safeFetchInscriptionMetadataFromSeeds } from '@metaplex-foundation/mpl-inscription'

const mintInscription = await safeFetchMintInscriptionFromSeeds(umi, {
  mint,
})

const inscriptionMetadataAccount = await safeFetchInscriptionMetadataFromSeeds(
  umi,
  {
    inscriptionAccount: inscriptionAccount.publicKey,
  }
)

const associatedInscriptionAccount = findAssociatedInscriptionPda(umi, {
  associated_tag: inscriptionMetadataAccount.associatedInscriptions[0].tag,
  inscriptionMetadataAccount.publicKey,
})
const imageData = await fetchInscription(umi, associatedInscriptionAccount[0])
```

### Fetch data inscription <a href="#fetch-data-inscription" id="fetch-data-inscription"></a>

To read Inscription Data that is not attached to NFTs a different function is used:

Fetch Inscription

JavaScript

```
import { fetchInscription } from '@metaplex-foundation/mpl-inscription'

const inscription = fetchInscription(umi, inscriptionAddress)
```

### Fetch current Inscription count <a href="#fetch-current-inscription-count" id="fetch-current-inscription-count"></a>

The current total inscription count can be fetched like so:

Fetch current Inscription count

JavaScript

```
import {
  fetchAllInscriptionShard,
  findInscriptionShardPda,
} from '@metaplex-foundation/mpl-inscription'

const shardKeys: Pda[]
for (let shardNumber = 0; shardNumber < 32; shardNumber += 1) {
  shardKeys.push(findInscriptionShardPda(umi, { shardNumber }))
}

const shards = await fetchAllInscriptionShard(umi, shardKeys)
let numInscriptions = 0
shards.forEach((shard) => {
  const rank = 32 * Number(shard.count) + shard.shardNumber
  numInscriptions = Math.max(numInscriptions, rank)
})

console.log(`Currently there are ${numInscriptions} Metaplex Inscriptions`)
```


---

# 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://8bit-1.gitbook.io/solibrary/fetch.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.
