Polkadot Apps
    Preparing search index...

    Function applyWeightBuffer

    • Apply a safety buffer to weight estimates from a dry-run result.

      Dry-run weight estimates reflect the exact execution cost at the time of simulation. On-chain conditions can change between dry-run and actual submission (storage growth, state changes by other transactions), so a buffer prevents unexpected OutOfGas failures.

      The default 25% buffer matches the convention used across Polkadot ecosystem tooling.

      Parameters

      • weight: Weight

        The weight_required from a ReviveApi.call or ReviveApi.eth_transact dry-run.

      • Optionaloptions: { percent?: number }

        Override the buffer percentage (default: 25%).

      Returns Weight

      A new weight with both components scaled up.

      const dryRun = await api.apis.ReviveApi.call(origin, dest, value, undefined, undefined, data);

      const tx = api.tx.Revive.call({
      dest, value, data,
      weight_limit: applyWeightBuffer(dryRun.weight_required),
      storage_deposit_limit: dryRun.storage_deposit.value,
      });
      applyWeightBuffer(dryRun.weight_required, { percent: 50 });