MeshJS / mesh

TypeScript open-source library to advance Web3 development on Cardano
https://meshjs.dev
Apache License 2.0
221 stars 65 forks source link

Transaction was written incorrectly #382

Closed independenceee closed 2 weeks ago

independenceee commented 2 weeks ago

image

Can you tell me if this error is onchain or offchain?

image

twwu123 commented 2 weeks ago

Essentially, some of your inputs are owned by a script address, but you haven't provided any script witnesses.

This error is an offchain error, and is coming from CSL.

Any inputs owned by a script can only be unlocked by providing the script, datum and redeemer explicitly.

independenceee commented 2 weeks ago

image

Thanks for your reply. can you show me where I went wrong? I tried many times similar to mint but when I burn it it doesn't work. Onchain part I leave the condition always true.

Essentially, some of your inputs are owned by a script address, but you haven't provided any script witnesses.

This error is an offchain error, and is coming from CSL.

Any inputs owned by a script can only be unlocked by providing the script, datum and redeemer explicitly.

twwu123 commented 2 weeks ago

I would suggest not mixing up mint and txIn APIs. For example

.txIn(...)
.txIn(...)
.mintPlutusScriptV3()
.mint(...)
.mintingScript(...)
.mintRedeemerValue(...)

But from what I can tell, the most likely cause for your issue, is storeUtxos. My assumption is that your "Store" is a script. So, you would not be able to use it in selectUtxosFrom, that cannot be used with script inputs.

You would have to do something like

.spendingPlutusScriptV3()
.txIn(storeUtxo.input.txHash, storeUtxo.input.outputIndex)
.txInScript(...)
.txInDatumValue(...) // could also be .txInInlineDatumPresent() if your input has datum inlined
.txInRedeemerValie(...)
independenceee commented 2 weeks ago

Problem solved thank you very much.

Tôi đề nghị không nên trộn lẫn API mint và txIn. Ví dụ

.txIn(...)
.txIn(...)
.mintPlutusScriptV3()
.mint(...)
.mintingScript(...)
.mintRedeemerValue(...)

Nhưng theo những gì tôi biết, nguyên nhân có khả năng nhất gây ra sự cố của bạn là storeUtxos. Tôi cho rằng "Store" của bạn là một tập lệnh. Vì vậy, bạn sẽ không thể sử dụng nó trong selectUtxosFrom, không thể sử dụng với đầu vào tập lệnh.

Bạn sẽ phải làm điều gì đó như thế này

.spendingPlutusScriptV3()
.txIn(storeUtxo.input.txHash, storeUtxo.input.outputIndex)
.txInScript(...)
.txInDatumValue(...) // could also be .txInInlineDatumPresent() if your input has datum inlined
.txInRedeemerValie(...)