pub struct DataCost(_);

Implementations§

👎Deprecated since 11.0.0: Since babbage era we should use coins per byte. Use .new_coins_per_byte instead.

!!! DEPRECATED !!! Since babbage era we should use coins per byte. Use .new_coins_per_byte instead.

Examples found in repository?
src/tx_builder.rs (line 273)
271
272
273
274
275
    pub fn coins_per_utxo_word(&self, coins_per_utxo_word: &Coin) -> Self {
        let mut cfg = self.clone();
        cfg.data_cost = Some(DataCost::new_coins_per_word(coins_per_utxo_word));
        cfg
    }
More examples
Hide additional examples
src/output_builder.rs (line 107)
102
103
104
105
106
107
108
109
    pub fn with_asset_and_min_required_coin(
        &self,
        multiasset: &MultiAsset,
        coins_per_utxo_word: &Coin,
    ) -> Result<TransactionOutputAmountBuilder, JsError> {
        let data_cost = DataCost::new_coins_per_word(coins_per_utxo_word);
        self.with_asset_and_min_required_coin_by_utxo_cost(multiasset, &data_cost)
    }
src/utils.rs (line 1441)
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
pub fn min_ada_required(
    assets: &Value,
    has_data_hash: bool,          // whether the output includes a data hash
    coins_per_utxo_word: &BigNum, // protocol parameter (in lovelace)
) -> Result<BigNum, JsError> {
    let data_cost = DataCost::new_coins_per_word(coins_per_utxo_word);
    let mut calc = MinOutputAdaCalculator::new_empty(&data_cost)?;
    calc.set_amount(assets);
    if has_data_hash {
        calc.set_data_hash(&fake_data_hash(0));
    }
    calc.calculate_ada()
}
Examples found in repository?
src/tx_builder.rs (line 279)
277
278
279
280
281
    pub fn coins_per_utxo_byte(&self, coins_per_utxo_byte: &Coin) -> Self {
        let mut cfg = self.clone();
        cfg.data_cost = Some(DataCost::new_coins_per_byte(coins_per_utxo_byte));
        cfg
    }
Examples found in repository?
src/utils.rs (line 1412)
1408
1409
1410
1411
1412
1413
    pub fn calc_size_cost(data_cost: &DataCost, size: usize) -> Result<Coin, JsError> {
        //according to https://hydra.iohk.io/build/15339994/download/1/babbage-changes.pdf
        //See on the page 9 getValue txout
        to_bignum(size as u64).checked_add(&to_bignum(160))?
            .checked_mul(&data_cost.coins_per_byte())
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.