Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

ValueNotConservedUTxO #7

Open
nemanjamil opened this issue May 2, 2022 · 1 comment
Open

ValueNotConservedUTxO #7

nemanjamil opened this issue May 2, 2022 · 1 comment

Comments

@nemanjamil
Copy link

nemanjamil commented May 2, 2022

Error: Command failed: cardano-cli transaction submit --testnet-magic 1097911063 --tx-file ../cnode/tmp/tx_iyc13iwv6.signed
Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 156502547 (fromList [(PolicyID {policyID = ScriptHash "XXXXXX"},fromList [("Blokaria_Pink",1),("Blokaria_Pink_1",1),("Blokaria_Pink_11",1),("Blokaria_Pink_12",1),("Blokaria_Pink_13",1),("Blokaria_Pink_15",1),("Blokaria_Pink_18",1),("Blokaria_Pink_19",1),("NemanjaNFT",1),("NemanjaNFT_1",1),("NemanjaNFT_2",1),("NemanjaNFT_3",1),("NemanjaNFT_4",1),("NemanjaNFT_5",1),("NemanjaNFT_6",1),("NemanjaNFT_7",1),("NemanjaNFT_8",1)])])) (Value 156502547 (fromList [(PolicyID {policyID = ScriptHash "53d92437974def198c38e9d9481fafdc70366ff91dadc1bddf7e7ecf"},fromList [("NemanjaNFT_8",1)])])))))])

https://github.com/armada-alliance/cardano-minter/blob/master/src/send-asset-back-to-wallet.js
After trying and analyzing the cause of the error, still can't find the root cause problem.
Also tried with https://github.com/shareslake/cardanocli-js/blob/main/examples/simpleTransaction.js but the same error got.

The calculation is correct.

Fee: 182617

{
    "txIn": [
        {
            "txHash": "0f7b2ca8738221e79c36045fdf55a58a4b7e8edcffc72ea0d1bdeccf44edc0d1",
            "txId": 0,
            "value": {
                "lovelace": 56502547,
                "53d92437974def198c38e9d9481fafdc70366ff91dadc1bddf7e7ecf.426c6f6b617269615f50696e6b": 1,
                "... ... ..."
                "53d92437974def198c38e9d9481fafdc70366ff91dadc1bddf7e7ecf.4e656d616e6a614e46545f37": 1,
                "53d92437974def198c38e9d9481fafdc70366ff91dadc1bddf7e7ecf.4e656d616e6a614e46545f38": 1,
                "undefined": null
            }
        },
        {
            "txHash": "fec8662e1d9d9fdeb61804afcc14eaf6c1495e1f7e3104e137f58c0215cd9419",
            "txId": 0,
            "value": {
                "lovelace": 100000000,
                "undefined": null
            }
        }
    ],
    "txOut": [
        {
            "address": "addr_test1qqgyuatyqd35qv8s6jqufg65h0apv6qztdzmzc0thj4gpshgaxr09l20qws02zs889qcwqsnp0z7at6dq245kylayzssfernhl",
            "value": {
                "lovelace": 154319930
            }
        },
        {
            "address": "addr_test1qqpwywyhja7pts2404j8arxr5uhvmku7d8k53hrfypqsss05nrlujs9z7afw0cguvjuzzxq6dtmhjhcz8auach6p7s7qr957hv",
            "value": {
                "lovelace": 2000000,
                "53d92437974def198c38e9d9481fafdc70366ff91dadc1bddf7e7ecf.4e656d616e6a614e46545f38": 1
            }
        }
    ]
}

Appreciate support
Thx
Nemanja


PS. This is my code

const cardano = require("./cardano")
const sender = cardano.wallet("BLOKARIA")

const receiver = "addr_test1qqpwywyhja7pts2404j8arxr5uhvmku7d8k53hrfypqsss05nrlujs9z7afw0cguvjuzzxq6dtmhjhcz8auach6p7s7qr957hv"

let amountValue = 2

const txInfo = {
    txIn: cardano.queryUtxo(sender.paymentAddr),
    txOut: [
        {
            address: sender.paymentAddr,
            value: {
                lovelace: sender.balance().value.lovelace - cardano.toLovelace(amountValue)
            }
        },
        {
            address: receiver,
            value: {
                lovelace: cardano.toLovelace(amountValue),
                "53d92437974def198c38e9d9481fafdc70366ff91dadc1bddf7e7ecf.4e656d616e6a614e46545f38": 1
            }
        }
    ]
}

const raw = cardano.transactionBuildRaw(txInfo)

const fee = cardano.transactionCalculateMinFee({
    ...txInfo,
    txBody: raw,
    witnessCount: 1
})


txInfo.txOut[0].value.lovelace -= fee

const tx = cardano.transactionBuildRaw({ ...txInfo, fee })

const txSigned = cardano.transactionSign({
    txBody: tx,
    signingKeys: [sender.payment.skey]
})

const txHash = cardano.transactionSubmit(txSigned)

console.log(txHash)
@nemanjamil
Copy link
Author

Answer to question :

"value": {
                "lovelace": 56502547,
                "53d92437974def198c38e9d9481fafdc70366ff91dadc1bddf7e7ecf.426c6f6b617269615f50696e6b": 1,
                "... ... ..."
                "53d92437974def198c38e9d9481fafdc70366ff91dadc1bddf7e7ecf.4e656d616e6a614e46545f37": 1,
                "53d92437974def198c38e9d9481fafdc70366ff91dadc1bddf7e7ecf.4e656d616e6a614e46545f38": 1,
                
}

Code will only work with on token in a value object

"value": {
                "lovelace": 56502547,
                "53d92437974def198c38e9d9481fafdc70366ff91dadc1bddf7e7ecf.426c6f6b617269615f50696e6b": 1,
             }

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

No branches or pull requests

1 participant