Skip to main content

write

Writes data to an extension. This is used when the extension data is greater than the transaction size (~1232 bytes), which requires the data to be sent over multiple transactions. The write instruction is used after allocating the extension.

Accounts

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

NameWritableSignerOptionalDescription
assetUninitialized asset account
payerAccount paying for the storage fees
system programSystem Program account

Arguments

The allocate instruction expects the information of the extension to be added to the asset.

FieldOffsetSizeDescription
overwrite 01Indicates whether to overwrite the existing data or not.
bytes 1~The data to write.

Examples

import { write } from '@nifty-oss/asset';

// Accounts:
// - asset: KeypairSigner
// - payer: KeypairSigner
await write(umi, {
asset,
payer,
overwrite: false,
bytes,
}).sendAndConfirm(umi);