Help Burning NFTs

Hi, I’m running into an issue when trying to burn tokens and after several goes I can’t spot the error, any help would be appreciated!

utxo 1481480 + 10 PlutoNFTAqua
utxo 5000000

cardano-cli transaction build-raw
–mary-era
–fee 0
–tx-in 9da23f073e67b873828de20884fd5ad26ded16888a8e74715db97df3e3aee1a7#0
–tx-in 31f4eb0a03dd77c6f04a133f6b48d7f26d9b07b20687302afc3aace4f86f04bb#0
–tx-out addr1vy6fn9dal2d58j8m09q0zyqsdrmhgc94gr9klkyxnzppcng6a3csw+6481480+"
10 6bd9647a8fcb36cd4257a85f8bb0ddf7c4cac8fc87668ac3d65b698b.PlutoNFTAqua "
–mint="-10 6bd9647a8fcb36cd4257a85f8bb0ddf7c4cac8fc87668ac3d65b698b.PlutoNFTAqua "
–out-file BurnPNFT2matx.raw

cardano-cli transaction calculate-min-fee
–tx-body-file BurnPNFT2matx.raw
–tx-in-count 2
–tx-out-count 1
–witness-count 2
–mainnet
–protocol-params-file protocol.json

cardano-cli transaction build-raw \
         --mary-era \
             --fee 183101 \
             --tx-in 9da23f073e67b873828de20884fd5ad26ded16888a8e74715db97df3e3aee1a7#0 \
             --tx-in 31f4eb0a03dd77c6f04a133f6b48d7f26d9b07b20687302afc3aace4f86f04bb#0 \
             --tx-out addr1vy6fn9dal2d58j8m09q0zyqsdrmhgc94gr9klkyxnzppcng6a3csw+11298379+"
               10 6bd9647a8fcb36cd4257a85f8bb0ddf7c4cac8fc87668ac3d65b698b.PlutoNFTAqua " \
             --mint="-10 6bd9647a8fcb36cd4257a85f8bb0ddf7c4cac8fc87668ac3d65b698b.PlutoNFTAqua " \
             --out-file BurnPNFT2matx.raw

The error is always ValueNotConservedUTxO so the amounts are not matching up somewhere

Thanks

Hi!
Do you start with 10 tokens? If you are burning all 10 of them I don’t think they should be present in the tx-out. Unless you start with 20 tokens :slight_smile:

Ah ok! Will try that, yes just start with 10 :slight_smile:

Worked a treat, many thanks Freja!

1 Like

Burn NFT (minted nft) issue on transaction submit, using https://github.com/Berry-Pool/cardanocli-js.

Run this script:

const CardanocliJs = require("cardanocli-js");

const cardanocliJs = new CardanocliJs({
    network: "testnet-magic 1097911063",
    dir: __dirname + "/../",
    shelleyGenesisPath: __dirname + "/../testnet-shelley-genesis.json"
});


// 1. Get the wallet
const wallet = cardanocliJs.wallet("TGRISE");

// Define functions
const createTransaction = (tx) => {
    let raw = cardanocliJs.transactionBuildRaw(tx);
    let fee = cardanocliJs.transactionCalculateMinFee({
        ...tx,
        txBody: raw,
    });
    tx.txOut[0].value.lovelace -= fee;
    return cardanocliJs.transactionBuildRaw({ ...tx, fee });
};

const signTransaction = (wallet, tx, script) => {
    return cardanocliJs.transactionSign({
        signingKeys: [wallet.payment.skey, wallet.payment.skey],
        txBody: tx,
    });
};

// 2. Define mint script
const mintScript = {
    keyHash: cardanocliJs.addressKeyHash(wallet.name),
    type: "sig",
};

// 3. Create POLICY_ID
const POLICY_ID = cardanocliJs.transactionPolicyid(mintScript);

// 4. Define ASSET_NAME
const ASSET_NAME = "Abaidullah";

// 5. Create ASSET_ID
const ASSET_ID = POLICY_ID + "." + ASSET_NAME;

// 6. Define metadata
const metadata = {
    721: {
        [POLICY_ID]: {
            [ASSET_NAME]: {
                name: ASSET_NAME,
                image: "ipfs://QmQqzMTavQgT4f4T5v6PWBp7XNKtoPmC9jvn12WPT3gkSE",
                description: "Super Fancy Berry Space Green NFT",
                type: "image/png",
                src: "ipfs://Qmaou5UzxPmPKVVTM9GzXPrDufP55EDZCtQmpy3T64ab9N",
                // other properties of your choice
                authors: ["TGRISE"]
            }
        }
    }
}

// 7. Define transaction
const tx = {
    txIn: wallet.balance().utxo,
    txOut: [
        {
            address: wallet.paymentAddr,
            value: { ...wallet.balance().value, [ASSET_ID]: 1 },
        },
    ],
    mint: [
        { action: "burn", quantity: 1, asset: ASSET_ID, script: mintScript },
    ],
    metadata,
    witnessCount: 2,
};

// 8. Build transaction
const raw = createTransaction(tx);

// 9. Sign transaction
const signed = signTransaction(wallet, raw);
console.log(cardanocliJs.transactionView({ txFile: signed }));

// 10. Submit transaction
const txHash = cardanocliJs.transactionSubmit(signed);
console.log(assets, 'txHash:', txHash);

Gives the issue:

auxiliary data: AuxiliaryDataRaw {txMetadata = fromList [(721,Map [(S "c3ddef916f0db22eb19df1701db91625633501d01e76ad66edf26395",Map
  [(S "Abaidullah",Map [(S "authors",List [S "TGRISE",S "SBLYR"]),(S "description",S
  "Super Fancy Berry Space Green NFT"),(S "image",S "ipfs://QmQuSwUFfCHCwEAMtmecjB1AYAo4gsocxFQ8Ph8uG62ueK"),(S
  "name",S "Abaidullah"),(S "src",S "ipfs://QmQuSwUFfCHCwEAMtmecjB1AYAo4gsocxFQ8Ph8uG62ueK"),(S
  "type",S "image/png")])])])], auxiliaryScripts = StrictSeq {fromStrict = fromList
  []}}
auxiliary data hash: AuxiliaryDataHash {unsafeAuxiliaryDataHash = SafeHash "7535c3c8130eeee22ce62f2e1170e55a02d339b59135a63e88f7b8525e3e333c"}
certificates: []
era: Mary
fee: 197445
inputs:
- 4c5e4e6d92443f9cf783cd9cfb23dcb3c073437c224cdcdd0df61b29329079c6#0
mint:
  lovelace: 0
  policies:
    c3ddef916f0db22eb19df1701db91625633501d01e76ad66edf26395:
      4162616964756c6c6168: -1
outputs:
- address:
    Bech32: addr_test1qp56eal7uxkaz4zyylllcg2xj2vqv42jq62zng29y3v8e6f56lndw2dx3hhnltdwf7zan430pt7xaf2hr828qkdcddjsc3jmg4
    credential:
      key hash: 69acf7fee1add1544427fffc21469298065552069429a14524587ce9
    network: Testnet
    stake reference: StakeRefBase (KeyHashObj (KeyHash "34d7e6d729a68def3fadae4f85d9d62f0afc6ea55719d47059b86b65"))
  amount:
    lovelace: 8605110
    policies:
      c3ddef916f0db22eb19df1701db91625633501d01e76ad66edf26395:
        4162616964756c6c6168: 1
update: null
validity interval:
  invalid before: 0
  invalid hereafter: 41156111
withdrawals: []
Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 8802555 (fromList [])) (Value 8802555 (fromList [(PolicyID {policyID = ScriptHash "c3ddef916f0db22eb19df1701db91625633501d01e76ad66edf26395"},fromList [("Abaidullah",1)])])))))])

“cardanocli-js”: “^* 4.0.1”,

  • cardano-node 1.30.1
  • cardano-cli 1.30.1

Can anyone help me to resolve this blocker?