Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme out of date #87

Open
pochocosta opened this issue Jul 9, 2022 · 3 comments
Open

Readme out of date #87

pochocosta opened this issue Jul 9, 2022 · 3 comments

Comments

@pochocosta
Copy link

Hi! I was trying to use the library following the example code on the readme, but the code on the Calculate Fee section does not work any more. I wanted to fix the example, but I couldn't find the way.
Hope I can help in the future. Thanks in advance!

@safestak-keith
Copy link
Collaborator

Hi! I was trying to use the library following the example code on the readme, but the code on the Calculate Fee section does not work any more. I wanted to fix the example, but I couldn't find the way. Hope I can help in the future. Thanks in advance!

Hi @pochocosta and welcome to the CardanoSharp community! Could you please elaborate further on does not work any more? Do you mean a compilation or runtime error? The code for calculating fees should still compile and work as long as you have declared and set minFeeA and minFeeB with the right values.

It is also worth mentioning that we have simplified this process slightly so you should be able to handle fees in fewer lines of code. A PR to update the documentation to reflect this will be raised soon.

// Calculate Fee
var fee = transaction.CalculateAndSetFee(minFeeA, minFeeB);
transaction.TransactionBody.TransactionOutputs.Last().Value.Coin -= fee;

@pochocosta
Copy link
Author

pochocosta commented Jul 12, 2022

Hi @safestak-keith thanks for reply!

I will elaborate the problems I'm having. When I was creating the transaction, I receive an error at compilation time that says "Can't convert from 'CardanoSharp.Wallet.Models.Transactions.TransactionBody' to 'CardanoSharp.Wallet.TransactionBuilding.ITransactionBodyBuilder'" at the line:

var transaction = TransactionBuilder.Create
    .SetBody(transactionBody)
    .SetWitnesses(witnesses)
    .SetAuxData(auxData)
    .Build();

And at the section Calculate Fee there are 3 lines. The line in the middle does not compile also.

// Update Fee and Rebuild

transactionBody.SetFee(fee);
transaction = transactionBuilder.Build();
transaction.TransactionBody.TransactionOutputs.Last().Value.Coin -= fee;

The error says "the name transactionBuilder does not exist in the current context".

Do you know how to solve these problems?
Thanks in advance!

@safestak-keith
Copy link
Collaborator

I will elaborate the problems I'm having. When I was creating the transaction, I receive an error at compilation time that says "Can't convert from 'CardanoSharp.Wallet.Models.Transactions.TransactionBody' to 'CardanoSharp.Wallet.TransactionBuilding.ITransactionBodyBuilder'" at the line:

Thanks for elaborating, I can now see where the documentation could be a little confusing. The transactionBody variable in SetBody(transactionBody) should be of the ITransactionBodyBuilder type, and not a built TransactionBody object.

And at the section Calculate Fee there are 3 lines. The line in the middle does not compile also.

I can see that you have already built the transaction object from your previous block and therefore you can exclude the entire line transaction = transactionBuilder.Build();.

Also note it is now easier to do the fee calculation and setting the transaction body with one line transaction.CalculateAndSetFee(minFeeA, minFeeB); so you can also exclude the transactionBody.SetFee(fee); line too if you use the new method instead. Feel free to take a peek at this sample code if you want a full example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants