Comments (11)
Hi, any update about that?
from cardano-serialization-lib.
Hey thanks for the very prompt update! It turns out I was using the older version, I just started using the 10 beta and with a few changes to my TransactionBuilder setup I'm now able to mint using blockfrost. Tested pretty thoroughly with different policy scripts too and I'm fairly confident it's behaving as expected. Thanks for the great work!
from cardano-serialization-lib.
It's about to be merged and will be in the next version 10.0
See #231
from cardano-serialization-lib.
Hi, @flexabyte ! Ah yes, I think the burning part got forgotten when the processing of the Int values were added. Lemme add few changes for this and I will ping you once the new revision is available
from cardano-serialization-lib.
But if I do it like I stated on my first comment; add_change_if_needed()
throws the following error:
missing input for some native asset
I was afraid of getting that non-balanced Transaction
, and it indeed happened.
As far as I know, when minting multi-assets, you must specify in which output of the transaction you want to have this minted tokens. E.g, on the cardano-cli
you do it as follows:
cardano-cli transaction build-raw \
--mary-era \
--fee 0 \
--tx-in dacb...7a5 \
--tx-out="+$LOVELACE+5 $POLICYID.couttscoin" \
--mint="5 $POLICYID.couttscoin" \
--out-file "$TX_BODY_FILE"
The transaction on this command
gets balanced to 0
with the --mint argument, but in the case of cardano-serialization-lib as I stated on my first comment, the set_mint()
comes after the TransactionBuilder
.
Therefor, the calling of add_change_if_needed()
throws missing input for some native asset
because it does not know yet that it'll have Minted Tokens.
So as of today, it's not possible yet to use add_change_if_needed()
when you going to Mint Tokens, and fees should be completely calculated manually with the given functions?
Would the transaction be built correctly even if the TransactionBuilder
outputs a non-balanced transaction?
from cardano-serialization-lib.
The TransactionBuilder doesn't support minting at the moment. You have to build the tx manually using the individual classes unless somebody adds support for it in the TransactionBuilder.
from cardano-serialization-lib.
would be interested too! (:
from cardano-serialization-lib.
Hey @vsubhuman thanks so much for your work on this, I've been trying to do this in the background for a while and was amazed to see your branch. However, I've come across an issue and I'm not sure where it's coming from. I have written some JS that mints a simple token and submits it to blockfrost, and it works if I manually set the fee and change, but when using add_change_if_needed
I get a fee too small error:
// THIS DOESN'T WORK
txBuilder.add_change_if_needed(
S.Address.from_bech32(paymentAddr)
);
// THIS DOES WORK (after manually computing the outputs and fee)
txBuilder.add_output(
S.TransactionOutput.new(
S.Address.from_bech32(wallet.paymentAddr),
S.Value.new(S.BigNum.from_str("15606829"))
)
);
txBuilder.set_fee(S.BigNum.from_str("172453"));
The error:
ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (FeeTooSmallUTxO (Coin 172277) (Coin 172057))))])
I've not spent any time debugging this on the rust wasm side yet but just wanted to share anyway. I will update once I've looked into it further.
from cardano-serialization-lib.
Hi, @flexabyte ! Have you been using the latest version of the branch at the moment of getting this error? There previously was an error of not including the mint witnesses into the estimated tx size but now it were supposed to be fixed. Try it out plz on latest branch commit or on new published beta2: #231 (comment)
Also show plz if possible how are you creating the tx-builder (and the linear-fee parameter specifically) and how are you building the tx itself. The error (FeeTooSmallUTxO (Coin 172277) (Coin 172057))
suggests the calculation is 220 lovelaces short, which is 5 bytes in case you have fee coefficient 44.
Latest fix to the size estimation adds fake witnesses for each distinct policy ID in the mint: https://github.com/Emurgo/cardano-serialization-lib/pull/231/files#diff-67896f615f1e60f7474eb6194c0614a005522dc35fb07046855d77260954b972R99-R111
The tests show that adding these witnesses increases the size by:
No. of distinct Policy IDs * 32 + 3 bytes
Can see the test here: https://github.com/Emurgo/cardano-serialization-lib/pull/231/files#diff-67896f615f1e60f7474eb6194c0614a005522dc35fb07046855d77260954b972R3172-R3173
Quick look through the serialisation implementations for witness lists and hashes suggests that result makes sense, if there were no script keys apart from the mint (script witnesses for inputs are not supported yet anyways) - the witness set writes tag 1
to include the now non-empty set of script witnesses, native scripts then start the array and write the size of the array (the number of script witnesses) which must be the 2 additional overhead bytes, and the ScriptPubkey
then writes an array of size 2 prefix (additioanal 2 bytes), adds an InsignedInteger
tag 0
(which takes two bytes, if I am not mistaken) and writes the actual 28 byte hash of the pub-key, which gives the 32-byte per witness + 3 byte overhead.
Can't imagine so far where and why additional 5 bytes would be missing in that scheme. We will be doing some internal testing with the latest beta2 as well and will see if we are hitting a similar issue 🤔
from cardano-serialization-lib.
Hey there, just for the sake of completeness, I've been trying to create burn transactions after successfully minting them and I've been having a few issues. Using the CLI you would normally build a transaction with a negative input, so I presumed I could use the add_mint_asset
function that I use when minting, but just pass in a negative amount
to be used as the input like so:
this.txBuilder.add_mint_asset(
this.scriptHash,
S.AssetName.new(Buffer.from(assetName, 'hex')),
S.Int.new_i32(-1),
S.Address.from_bech32(addr),
);
And I'm getting a mint.js:129 Uncaught (in promise) Asset amount cannot be negative!
. When I dig into the debugger a bit I can see that the error arises when calling txBuilder.build()
. The rest of my code remains unchanged from how it's used to Mint (i.e. I still call set_native_scripts
on the TxWitnessSet
etc.) so I'm not sure what could be the reason for it. Have you been able to successfully test burning by any chance?
Thanks!
from cardano-serialization-lib.
@flexabyte , I have made a couple of updates to that branch - can you plz check everything again now?
Btw, are you using it from Rust or do you need JS npm builds to try it out?
from cardano-serialization-lib.
Related Issues (20)
- Help please? Private Keys in code?
- Help please? Private Keys in code? HOT 1
- DatumSource struct makes the script input to be reference input
- Unable to deregistration stake raw transaction HOT 2
- Finding a Go library that can perform basic data signature validation. HOT 2
- Distribute as a single NPM package HOT 1
- Make JSON encoding total & standardize it HOT 11
- RewardAddress method naming: why payment_cred() and not stake_cred()? HOT 1
- `RewardAddress`, `BaseAddress`, `EnterpriseAddress`, `PointerAddress` have no getter for network id HOT 3
- OutputDatum is not used in TransactionOutput HOT 1
- TransactionMetadatum.as_* methods: wrong type annotation HOT 1
- Fee calculation mismatch with conway certificates HOT 4
- `add_change_if_needed` multiple change outputs on many assets causes Error from node `OutputTooSmallUTxO` HOT 3
- plutus script witness deserialization issue HOT 8
- Add inputs with assets. HOT 1
- Witness Set Serialization differs between v11.5 and v12a18 HOT 3
- when a transaction has 2 inputs the fees are miscalculated, and uses 1 ADA as fee HOT 4
- Reference script to_bytes() includes tag 24 cbor wrapper HOT 9
- Hash Mismatch HOT 1
- CIP-0116 compatibility
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cardano-serialization-lib.