0

I'm new and I'm following cardano developers tutorial to create NFT. I arrived at some modified code for what I wanted to do. But get this "Invalid argument `"type":'" error. When building the transaction for minting. The other part of the transaction that is not the minting parts seems to work because I can make ordinary transaction and I'm using the testnet, running a testnet node with zsh. Cardano-cli version 1.33. Macbook pro M1 pro, macOS 12.2.1.

Here is the code:

cardano-cli query protocol-parameters \
--testnet-magic 1097911063 \
--out-file $HOME/nft/protocol.json

tokenname="5465737469616e"
tokenamount=1
txhash="989b03feb8885db90c6ca44065fe950a2208ba60c6d1b1f17aef87dcfd13c03b"
txix=0
policyid=$(cat $HOME/nft/policy/policyID)
script=$(cat $HOME/nft/policy/policy.json)
addressOut=$(cat $HOME/cardanotestwallet/keys/payment1.addr)
addressIn=$(cat $HOME/receive-ada-sample/keys/payment.addr)

fee=$(cardano-cli transaction build-raw \
--alonzo-era \
--tx-in ${txhash}#${txix} \
--tx-out ${addressOut}+0+"${tokenamount} ${policyid}.${tokenname}" \
--tx-out ${addressIn}+0 \
--mint="${tokenamount} ${policyid}.${tokenname}" \
--minting-script-file ${script} \
--invalid-hereafter ${slotnumber} \
--fee 0 \
--metadata-json-file $HOME/nft/metadata.json \
--out-file $HOME/nft/matx.raw

cardano-cli transaction calculate-min-fee \
--tx-body-file $HOME/nft/matx.raw \
--tx-in-count 1 \
--tx-out-count 2 \
--witness-count 1 \
--testnet-magic 1097911063 \
--protocol-params-file $HOME/nft/protocol.json)

fee=${fee%" Lovelace"}

funds=99829967
output=1700000
slotnumber=53264773
change=$((${funds}-${output}-${fee}))

cardano-cli transaction build-raw \
--alonzo-era \
--tx-in ${txhash}#${txix} \
--tx-out ${addressOut}+${output}+"${tokenamount} ${policyid}.${tokenname}" \
--tx-out ${addressIn}+${change} \
--mint="${tokenamount} ${policyid}.${tokenname}" \
--minting-script-file ${script} \
--invalid-hereafter ${slotnumber} \
--fee ${fee} \
--metadata-json-file $HOME/nft/metadata.json \
--out-file $HOME/nft/matx.raw

...And here is the full error code:

Invalid argument `"type":'

Usage: cardano-cli transaction build-raw 
            [ --byron-era
            | --shelley-era
            | --allegra-era
            | --mary-era
            | --alonzo-era
            ]
            [--script-valid | --script-invalid]
            (--tx-in TX-IN
              [--tx-in-script-file FILE
                [(--tx-in-datum-file FILE | --tx-in-datum-value JSON VALUE)
                  ( --tx-in-redeemer-file FILE
                  | --tx-in-redeemer-value JSON VALUE
                  )
                  --tx-in-execution-units (INT, INT)]])
            [--tx-in-collateral TX-IN]
            [--required-signer FILE | --required-signer-hash HASH]
            [--tx-out ADDRESS VALUE
              [ --tx-out-datum-hash HASH
              | --tx-out-datum-hash-file FILE
              | --tx-out-datum-hash-value JSON VALUE
              | --tx-out-datum-embed-file FILE
              | --tx-out-datum-embed-value JSON VALUE
              ]]
            [--mint VALUE
              (--mint-script-file FILE
                [(--mint-redeemer-file FILE | --mint-redeemer-value JSON VALUE)
                  --mint-execution-units (INT, INT)])]
            [--invalid-before SLOT]
            [--invalid-hereafter SLOT]
            [--fee LOVELACE]
            [--certificate-file CERTIFICATEFILE
              [--certificate-script-file FILE
                [
                  ( --certificate-redeemer-file FILE
                  | --certificate-redeemer-value JSON VALUE
                  )
                  --certificate-execution-units (INT, INT)]]]
            [--withdrawal WITHDRAWAL
              [--withdrawal-script-file FILE
                [
                  ( --withdrawal-redeemer-file FILE
                  | --withdrawal-redeemer-value JSON VALUE
                  )
                  --withdrawal-execution-units (INT, INT)]]]
            [--json-metadata-no-schema | --json-metadata-detailed-schema]
            [--auxiliary-script-file FILE]
            [--metadata-json-file FILE | --metadata-cbor-file FILE]
            [--genesis FILE | --protocol-params-file FILE]
            [--update-proposal-file FILE]
            --out-file FILE

  Build a transaction (low-level, inconvenient)

  Please note the order of some cmd options is crucial. If used incorrectly may produce undesired tx body. See nested [] notation above for details.
Command failed: transaction calculate-min-fee  Error: /Users/myyenongianggiang/nft/matx.raw: /Users/myyenongianggiang/nft/matx.raw: openBinaryFile: does not exist (No such file or directory)
createN.sh: line 38: 99829967-1700000-: syntax error: operand expected (error token is "-")

Am I missing something really easy? can't find out what the problem is, would be very happy for getting some help. Been stuck... Thank you very much in advance.

//Koki

1 Answer 1

1

The error states a missing file: matx.raw

I sugguest separating the build-raw and calc fee commands.

Edit: $slotnumber was not set before use in the first 'build-raw' statement.

Edit: Try the steps below manually one by one to confirm that things are as we expect before carrying on. Set the slotnumber to the appropriate value.

Edit: --minting-script-file expects a file path not data

Edit: User recreated the policy ID and the policy script - now working ok.

#Step 0 - Remove $HOME/nft/matx.raw if it exists
rm $HOME/nft/matx.raw

#Step 1
cardano-cli query protocol-parameters \
--testnet-magic 1097911063 \
--out-file $HOME/nft/protocol.json

#Step 2
tokenname="5465737469616e"
tokenamount=1
txhash="989b03feb8885db90c6ca44065fe950a2208ba60c6d1b1f17aef87dcfd13c03b"
txix=0
policyid=$(cat $HOME/nft/policy/policyID)
#script=$(cat $HOME/nft/policy/policy.json)
script="$HOME/nft/policy/policy.json"
addressOut=$(cat $HOME/cardanotestwallet/keys/payment1.addr)
addressIn=$(cat $HOME/receive-ada-sample/keys/payment.addr)

slotnumber=53264773

#Step 3 - Check each is set correctly
echo "This is step 3"
echo "A $txhash "
echo "B $txix"
echo "C $addressOut"
echo "D $tokenamount"
echo "E $policyid"
echo "F $tokenname"
echo "G $addressIn"
echo "H $script"
echo "I $slotnumber"

echo "About to run the first build-raw command"

cardano-cli transaction build-raw \
--alonzo-era \
--tx-in ${txhash}#${txix} \
--tx-out ${addressOut}+0+"${tokenamount} ${policyid}.${tokenname}" \
--tx-out ${addressIn}+0 \
--mint="${tokenamount} ${policyid}.${tokenname}" \
--minting-script-file ${script} \
--invalid-hereafter ${slotnumber} \
--fee 0 \
--metadata-json-file $HOME/nft/metadata.json \
--out-file $HOME/nft/matx.raw

echo "After the first build-raw"
16
  • Also, keep in mind that each command should be on one line, or use the line continuation character \ if split over multiple lines. Commented Mar 19, 2022 at 1:01
  • Thank you for your quick response. I tried your suggestion as mentioned and got the exact same error. And yes everything is on same line or "\" is used when multiple lines. The "\" don't seems to show when posting here. However they are there 🙂.
    – Koki
    Commented Mar 20, 2022 at 14:07
  • Thanks for the update. I just noticed that slotnumber does not appear to be set before the first 'build-raw' attempt. --invalid-hereafter ${slotnumber} Can you set it at the top before running 'cardano-cli transaction build-raw...' eg slotnumber=53264773 Commented Mar 21, 2022 at 0:48
  • Okey. Tried moving the slotnumber higher above the first build-raw attempt, but still exact same error code.
    – Koki
    Commented Mar 21, 2022 at 18:34
  • slotnumber needs to be set before you use it eg BEFORE the line beginning: fee=$(cardano-cli transaction build-raw...... Set it at the TOP right after the line: addressIn=$(cat.... Commented Mar 22, 2022 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.