ITZABUILD PORTAL · v0.8 Start building ↗
GUIDELINE 08

Plan storage and rent early

Create asset metadata and its rent relationship before uploading bytes, and decide who owns, funds, upgrades, and deletes the object.

← All guidelines

Choose the lifecycle

  • Direct rent-funded asset: create_tx_asset_deploy authenticates the rent key and creates the metadata directly.
  • Contract-funded asset: a normal contract call can create the file modification using the contract's configured rent wallet.
  • Caller-funded contract asset: create_tx_contract_call_with_rent authenticates a caller-supplied rent override while the contract validates and creates the asset metadata.
  • Permanent: use an empty authenticated wallet and a contract modification with make_permanent, or use create_tx_make_permanent for an existing asset, only after estimating the full cost.

Required checks

  • Derive and initialize the rent wallet predictably.
  • Hash bytes locally and keep filename, MIME type, byte length, and owner explicit.
  • Wait for successful metadata creation before upload_asset.
  • Treat upload success and transaction execution as separate states.
  • Expose rent depletion, permanence, transfer, upgrade, and deletion behavior in the UI.
Rent-funded direct asset
const bytes = new Uint8Array(await file.arrayBuffer());
const rent = await deriveRentWallet();
const asset = await deriveAssetWallet(fileId);
const submitFinal = tx => new Promise((resolve, reject) => {
  itza.submit_tx_with_result(tx, event => {
    try { ensureWasmSucceeded(event); resolve(event); } catch (error) { reject(error); }
  }).catch(reject);
});

// Start this deterministic rent wallet once; tolerate "already exists".
await submitFinal(itza.create_tx_rent_start(rent.keypair));

const tx = itza.create_tx_asset_deploy(
  asset.keypair, file.name, file.type || "application/octet-stream",
  rent.keypair, wallet.address, bytes, 4, "ssd"
);
renderAssetCreation(await submitFinal(tx));

// Upload only after asset metadata has been accepted.
await itza.upload_asset(asset.address, bytes);
Bottom line

Storage is a lifecycle, not one upload call. Model metadata creation, byte upload, funding, ownership, and deletion as separate observable steps.