# Initialize

The `initialize` instruction creates the inscription accounts for you where the data will be stored. There are three types of initializations:

1. `initializeFromMint` - for Inscriptions attached to NFTs - **you probably want this**
2. `initialize` - for Inscriptions as a storage provider
3. `initializeAssociatedInscription` - Additional Data Accounts

After the initialization has been done you can [write Data](https://developers.metaplex.com/inscription/write) to the inscriptions.

When initializing you can choose a `shard` that is used for numbering. Make sure to use a random one to minimize locks. Read more about [Sharding here](https://developers.metaplex.com/inscription/sharding)

### `initializeFromMint` <a href="#initialize-from-mint" id="initialize-from-mint"></a>

These inscriptions are tradable similar to NFTs. If you are unsure you probably want to use this.

If you want a tradable inscription you want to use this kind of inscription. It is derived from your NFT. When using this function you have to be the update authority of the NFT.

It can be done like this:

Initialize Mint Inscription

JavaScript

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

const inscriptionShardAccount = await findInscriptionShardPda(umi, {
  shardNumber: 0, //random number between 0 and 31
})
await initializeFromMint(umi, {
  mintAccount: mint.publicKey,
  inscriptionShardAccount,
}).sendAndConfirm(umi)
```

### `Initialize` <a href="#initialize" id="initialize"></a>

This kind of inscriptions is **not tradable**. We recommended it only for advanced use cases like gaming.

An Inscription has to be initialized before data can written to it. It can be done like so:

Initialize Inscription

JavaScript

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

const inscriptionAccount = generateSigner(umi)

const inscriptionMetadataAccount = await findInscriptionMetadataPda(umi, {
  inscriptionAccount: inscriptionAccount.publicKey,
})
const inscriptionShardAccount = await findInscriptionShardPda(umi, {
  shardNumber: 0, //random number between 0 and 31
})

await initialize(umi, {
  inscriptionAccount,
  inscriptionShardAccount,
}).sendAndConfirm(umi)
```

### `initializeAssociatedInscription` <a href="#initialize-associated-inscription" id="initialize-associated-inscription"></a>

One Inscription account can have multiple Associated Inscription Accounts. They are derived based on the `associationTag`. For example the tag can be the datatype of the file, e.g. `image/png`.

Pointers to the associated inscriptions are stored in an array in the `inscriptionMetadata` Account in the field `associatedInscriptions`.

To initialize a new Associated Inscription you can use the following function:

Initialize Associated Inscription

JavaScript

```
import {
  findInscriptionMetadataPda,
  initializeAssociatedInscription,
} from '@metaplex-foundation/mpl-inscription'

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

await initializeAssociatedInscription(umi, {
  inscriptionMetadataAccount,
  associationTag: 'image/png',
}).sendAndConfirm(umi)
```


---

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