# Preimage

### Calls

#### notePreimage

Register a preimage on-chain.

If the preimage was previously requested, no fees or deposits are taken for providing the preimage. Otherwise, a deposit is taken proportional to the size of the preimage.

**Namespace**

```
api.tx.preimage.notePreimage
```

**Type**

```typescript
function notePreimage(
  bytes: Bytes
)
```

#### requestPreimage

Request a preimage be uploaded to the chain without paying any fees or deposits.

If the preimage requests has already been provided on-chain, we unreserve any deposit a user may have paid, and take the control of the preimage out of their hands.

**Namespace**

```
api.tx.preimage.requestPreimage
```

**Type**

```typescript
function requestPreimage(
  hash: H256
)
```

#### unnotePreimage

Clear an unrequested preimage from the runtime storage.

**Namespace**

```
api.tx.preimage.unnotePreimage
```

**Type**

```typescript
function unnotePreimage(
  hash: H256
)
```

#### unrequestPreimage

Clear a previously made request for a preimage.

{% hint style="danger" %}
IMPORTANT: This must not be called on`hash`more times than`request_preimage`.
{% endhint %}

**Namespace**

```
api.tx.preimage.unrequestPreimage
```

**Type**

```typescript
function unrequestPreimage(
  hash: H256
)
```

### Storage

#### preimageFor

The preimages stored by this pallet.

**Namespace**

```
api.query.preimage.preimageFor
```

**Type**

```typescript
function preimageFor(
  H256
): Option<Bytes>
```

#### statusFor

The request status of a given hash.

**Namespace**

```
api.query.preimage.statusFor
```

**Type**

```typescript
function statusFor(
  H256
): Option<PalletPreimageRequestStatus>
```

### Events

#### Cleared

A preimage has ben cleared.

**Namespace**

```
api.events.preimage.Cleared
```

**Type**

```typescript
type Cleared = {
  hash: H256
}
```

#### Noted

A preimage has been noted.

**Namespace**

```
api.events.preimage.Noted
```

**Type**

```typescript
type Noted = {
  hash: H256
}
```

#### Requested

A preimage has been requested.

**Namespace**

```
api.events.preimage.Requested
```

**Type**

```typescript
type Requested = {
  hash: H256
}
```

### Errors

#### AlreadyNoted

Preimage has already been noted on-chain.

**Namespace**

```
api.errors.preimage.AlreadyNoted
```

#### NotAuthorized

The user is not authorized to perform this action.

**Namespace**

```
api.errors.preimage.NotAuthorized
```

#### NotNoted

The preimage cannot be removed since it has not yet been noted.

**Namespace**

```
api.errors.preimage.NotNoted
```

#### NotRequested

The preimage request cannot be removed since no outstanding requests exist.

**Namespace**

```
api.errors.preimage.NotRequested
```

#### Requested

A preimage may not be removed when there are outstanding requests.

**Namespace**

```
api.errors.preimage.Requested
```

#### TooLarge

Preimage is too large to store on-chain.

**Namespace**

```
api.errors.preimage.TooLarge
```

undefined
