Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Milestone: https://github.com/Emurgo/cardano-serialization-lib/milestone/5?closed=1
Breaking Changes
1. Old protocol param
minimum_utxo_val
is replaced withcoins_per_utxo_word
(#219 #248)The TransactionBuilder and the
min_ada_required
function now require new value introduced in Alonzo: coins per utxo word, see spec from IOHK: https://github.com/input-output-hk/cardano-ledger/blob/master/doc/explanations/min-utxo-alonzo.rstThe mainnet value for this at the moment is
34_482
(lovelaces).The
min_ada_required
function API changed from two required arguments to three: theValue
to be estimated, the boolean flaghas_data_hash
(// whether the output includes a plutus data hash
), and thecoins_per_utxo_word
asBigNum
.2. TransactionBuilder construction API changed (#261 #269 #270)
The list of arguments is replaced with a new config struct and the config-builder, see example of the new usage in Rust here: https://github.com/Emurgo/cardano-serialization-lib/blob/master/rust/src/tx_builder.rs#L1144-L1153
In JS it's something like:
3. Field replacement in ConstrPlutusData (#250)
The
ConstrPlutusData
fieldtag: Int
is replaced to bealternative: BigNum
4. NativeScript hash return type fixed (#234)
The function
ScriptHash.hash
return type changed from incorrectEd25519KeyHash
to correctScriptHash
. They are both defined as 28-byte hash types, so functionally there's no fifference but type-checking might fail in strict systems if the incorrect type were used on the client side.New API features
1. Minting in TransactionBuilder (#231 #273)
The
Mint
is now can be set to the tx-builder using new.set_mint
function, but this requires additional manual handling of witness scripts for minting using the new.set_mint_scripts
function. If the fee estimation is attempted without having all matching witness scripts for each used policy-id in the mint - an error will be raised as the correct estimation is not possible. You can still use Mint without providing witness scripts and use automatic change calculation if you set the fee value manually.Instead, new helper functions can be used:
.set_mint_asset
,.add_mint_asset
,.add_mint_asset_and_output
,.add_mint_asset_and_output_min_required_coin
. These function take the minting script itself instead of just the policy-id and they both produce the correct mint entry with the policy-id AND include the minting script into the list of witnesses so that the correct fee estimation is possible. The*_and_output
functions additionally produce a new output specifically for this new minted asset and either include the specified ADA value or automatically calculate and include the minimum required ADA value.NOTE: added mint is correctly considered as part of the total input so if you don't send it to any explicit output and calculate the change - it will be added to the change output.
2. Metadata in TransactionBuilder (#231)
Few new helper functions for easier metadata handling:
.set_metadata
,.add_metadatum
,.add_json_metadatum
,.add_json_metadatum_with_schema
. Theset
function overwrites the existing value. Alladd_*
functions are null-secure, meaning that in case the auxiliary data or the metadata does not exist yet - it will be safely created and then the new entry will be added to it.3. Building full Tx in TransactionBuilder (#231)
New function
.build_tx()
is added which produces an instance of the fullTransaction
, compared to the existing.build()
which returns only theTransactionBody
. The important difference is that the full returnedTransaction
contains thewitness_set
which will already include all the native scripts if minting were added, plus it contains theauxiliary_data
in case the metadata were added, and the validity flag for better compatibility with Alonzo.If NO minting and no metadata were used - there's not much difference which variant to use. But if minting and/or metadata were added - then it is much more recommended to use
.build_tx()
and then only add vkey witnesses into the existingwitness_set
after signing the transaction.4. Coin-selection in TransactionBuilder (#232 #253 #254 #264)
New function
.add_inputs_from
is now available which takes an array of available utxo and allows to select the selection strategy: largest-first or random-improve (see CIP2), the function will try to select enough utxo to add them as inputs to cover the required outputs and the fees, which is why it is better to call this function after all target outputs, the mint, and the metadata are added, and before calling.add_change_if_needed
.5. PrivateKey from bech32 (#244 #245)
New construction option
PrivateKey::from_bech32
is now available6. Cardano-wallet style multisig (#221)
New function are now available to create multisig scripts as supported by cardano-wallet, independent to CIP29.
7. Deprecated
Int.as_i32
(#258)Function
Int.as_i32()
is deprecated because it silently ignores potential overflow errors and does not indicate it with the name that well. New functions added:.as_i32_or_nothing()
which does the same thing and.as_i32_or_fail()
which potentially returns an error.Additionally new function
Int.to_str
is added, which produces normal decimal string rendering of the underlying i128. Without that function before clients were forced to either useas_i32
or use the awkward BigNum conversion API which requires to do a positive/negative check first.Internal improvements