Skip to main content

GasCostSummary

GasCostSummary

struct GasCostSummary

Summary of gas charges.

Storage is charged independently of computation. There are 3 parts to the storage charges:

  • storage_cost: it is the charge of storage at the time the transaction is executed. The cost of storage is the number of bytes of the objects being mutated multiplied by a variable storage cost per byte
  • storage_rebate: this is the amount a user gets back when manipulating an object. The storage_rebate is the storage_cost for an object minus fees.
  • non_refundable_storage_fee: not all the value of the object storage cost is given back to user and there is a small fraction that is kept by the system. This value tracks that charge.

When looking at a gas cost summary the amount charged to the user is computation_cost + storage_cost - storage_rebate and that is the amount that is deducted from the gas coins. non_refundable_storage_fee is collected from the objects being mutated/deleted and it is tracked by the system in storage funds.

Objects deleted, including the older versions of objects mutated, have the storage field on the objects added up to a pool of "potential rebate". This rebate then is reduced by the "nonrefundable rate" such that: potential_rebate(storage cost of deleted/mutated objects) = storage_rebate + non_refundable_storage_fee

BCS

The BCS serialized form for this type is defined by the following ABNF:

gas-cost-summary = u64 ; computation-cost
u64 ; storage-cost
u64 ; storage-rebate
u64 ; non-refundable-storage-fee

init(computationCost:computationCostBurned:storageCost:storageRebate:nonRefundableStorageFee:)

init(computationCost: UInt64, computationCostBurned: UInt64, storageCost: UInt64, storageRebate: UInt64, nonRefundableStorageFee: UInt64)

computationCost

var computationCost: UInt64

Cost of computation/execution

computationCostBurned

var computationCostBurned: UInt64

The burned component of the computation/execution costs

nonRefundableStorageFee

var nonRefundableStorageFee: UInt64

The fee for the rebate. The portion of the storage rebate kept by the system.

storageCost

var storageCost: UInt64

Storage cost, it's the sum of all storage cost for all objects created or mutated.

storageRebate

var storageRebate: UInt64

The amount of storage cost refunded to the user for all objects deleted or mutated in the transaction.

!=(_:_:)

static func != (lhs: Self, rhs: Self) -> Bool

Returns a Boolean value indicating whether two values are not equal.

Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.

This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.

  • Parameters:
    • lhs: A value to compare.
    • rhs: Another value to compare.