pub trait Chargeable:
Inputs
+ Witnesses
+ Policies {
// Required methods
fn metered_bytes_size(&self) -> usize;
fn gas_used_by_metadata(&self, gas_costs: &GasCosts) -> Word;
// Provided methods
fn min_gas(&self, gas_costs: &GasCosts, fee: &FeeParameters) -> Word { ... }
fn max_gas(&self, gas_costs: &GasCosts, fee: &FeeParameters) -> Word { ... }
fn min_fee(
&self,
gas_costs: &GasCosts,
fee: &FeeParameters,
gas_price: Word,
) -> u128 { ... }
fn max_fee(
&self,
gas_costs: &GasCosts,
fee: &FeeParameters,
gas_price: Word,
) -> u128 { ... }
fn refund_fee(
&self,
gas_costs: &GasCosts,
fee: &FeeParameters,
used_gas: Word,
gas_price: Word,
) -> Option<Word> { ... }
fn gas_used_by_inputs(&self, gas_costs: &GasCosts) -> Word { ... }
}
Expand description
Means that the blockchain charges fee for the transaction.
Required Methods§
sourcefn metered_bytes_size(&self) -> usize
fn metered_bytes_size(&self) -> usize
Used for accounting purposes when charging byte based fees.
sourcefn gas_used_by_metadata(&self, gas_costs: &GasCosts) -> Word
fn gas_used_by_metadata(&self, gas_costs: &GasCosts) -> Word
Used for accounting purposes when charging for metadata creation.
Provided Methods§
sourcefn min_gas(&self, gas_costs: &GasCosts, fee: &FeeParameters) -> Word
fn min_gas(&self, gas_costs: &GasCosts, fee: &FeeParameters) -> Word
Returns the minimum gas required to start transaction execution.
sourcefn max_gas(&self, gas_costs: &GasCosts, fee: &FeeParameters) -> Word
fn max_gas(&self, gas_costs: &GasCosts, fee: &FeeParameters) -> Word
Returns the maximum possible gas after the end of transaction execution.
The function guarantees that the value is not less than Self::min_gas.
sourcefn min_fee(
&self,
gas_costs: &GasCosts,
fee: &FeeParameters,
gas_price: Word,
) -> u128
fn min_fee( &self, gas_costs: &GasCosts, fee: &FeeParameters, gas_price: Word, ) -> u128
Returns the minimum fee required to start transaction execution.
sourcefn max_fee(
&self,
gas_costs: &GasCosts,
fee: &FeeParameters,
gas_price: Word,
) -> u128
fn max_fee( &self, gas_costs: &GasCosts, fee: &FeeParameters, gas_price: Word, ) -> u128
Returns the maximum possible fee after the end of transaction execution.
The function guarantees that the value is not less than Self::min_fee.
sourcefn refund_fee(
&self,
gas_costs: &GasCosts,
fee: &FeeParameters,
used_gas: Word,
gas_price: Word,
) -> Option<Word>
fn refund_fee( &self, gas_costs: &GasCosts, fee: &FeeParameters, used_gas: Word, gas_price: Word, ) -> Option<Word>
Returns the fee amount that can be refunded back based on the used_gas
and
current state of the transaction.
Return None
if overflow occurs.
sourcefn gas_used_by_inputs(&self, gas_costs: &GasCosts) -> Word
fn gas_used_by_inputs(&self, gas_costs: &GasCosts) -> Word
Returns the gas used by the inputs.