Skip to main content

resize

Resizes an asset account. This instruction is used when adding extension data over the 10 kilobytes account resize limit to an asset via the update instruction. While it is possible to add the extension data to a buffer (uninitialized asset) account, executing an update with the buffer account will require resizing the asset account over the maximum realloc limit — using this instruction avoids this limitation, since the asset account can be resized multiple times up to the require size before the update instruction.

Accounts

Below is the list of accounts expected by the resize instruction.

NameWritableSignerOptionalDescription
assetInitialized asset account
authorityAuthority of the asset
payer(optional)Account paying for the storage fees
system programSystem program

The payer pays for storage fees when the account size is extended and needs to be a signer; in this case, the system program account is required. When the account is trimmed, the payer receives the refunded rent.

Arguments

The resize instruction expects the type of the resize.

FieldOffsetSizeDescription
strategy01Type of the resize.
size12Extend size.

The resize strategy is specified as one of the values of the Strategy enum:

  • Trim: the account is resized to the minimum required size;
  • Extend: the account is resized by size bytes.

Examples

import { resize, strategy } from '@nifty-oss/asset';

// Accounts:
// - asset: PublicKey
// - authority: KeypairSigner
// - payer: KeypairSigner
await resize(umi, {
asset,
authority,
payer,
strategy: strategy('Extend', { value: 1000 }),
}).sendAndConfirm(umi);