<p>The error states a missing file: matx.raw</p>
<p>I sugguest separating the build-raw and calc fee commands.</p>
<p>Edit: $slotnumber was not set before use in the first 'build-raw' statement.</p>
<p>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.</p>
<p>Edit: --minting-script-file expects a file path not data</p>
<p>Edit: User recreated the policy ID and the policy script - now working ok.</p>
<pre><code>#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=&quot;5465737469616e&quot;
tokenamount=1
txhash=&quot;989b03feb8885db90c6ca44065fe950a2208ba60c6d1b1f17aef87dcfd13c03b&quot;
txix=0
policyid=$(cat $HOME/nft/policy/policyID)
#script=$(cat $HOME/nft/policy/policy.json)
script=&quot;$HOME/nft/policy/policy.json&quot;
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 &quot;This is step 3&quot;
echo &quot;A $txhash &quot;
echo &quot;B $txix&quot;
echo &quot;C $addressOut&quot;
echo &quot;D $tokenamount&quot;
echo &quot;E $policyid&quot;
echo &quot;F $tokenname&quot;
echo &quot;G $addressIn&quot;
echo &quot;H $script&quot;
echo &quot;I $slotnumber&quot;

echo &quot;About to run the first build-raw command&quot;

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

echo &quot;After the first build-raw&quot;
</code></pre>

CC BY-SA 4.0
2022-03-19T01:01:57.193Z
Also, keep in mind that each command should be on one line, or use the line continuation character \ if split over multiple lines.
MC_Brisbane - JUST Pool
CC BY-SA 4.0
2022-03-20T14:07:53.657Z
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
CC BY-SA 4.0
2022-03-21T00:48:38.347Z
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
MC_Brisbane - JUST Pool
CC BY-SA 4.0
2022-03-21T18:34:07.177Z
Okey. Tried moving the slotnumber higher above the first build-raw attempt, but still exact same error code.
Koki
CC BY-SA 4.0
2022-03-22T02:40:20.903Z
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....
MC_Brisbane - JUST Pool
CC BY-SA 4.0
2022-03-22T05:36:07.760Z
Builds-raw and calc fee commands are now separated as suggested and slot number is set before first build-raw command (right after/under addressIn). Same error code created.
Koki
CC BY-SA 4.0
2022-03-22T08:20:59.310Z
Can you try these steps in my updated answer.
MC_Brisbane - JUST Pool
CC BY-SA 4.0
2022-03-22T09:09:23.617Z
Can you link in the document guide that you are following.
MC_Brisbane - JUST Pool
CC BY-SA 4.0
2022-03-22T18:29:55.353Z
About to run the first build-raw
Command failed: transaction build-raw  Error: {
  "type": "all",
  "scripts":
  [
   {
     "type": "before",
     "slot": 53612937
   },
   {
     "type": "sig",
     "keyHash": "13589c57f20c76a46b508cca1f4434d0a1e3f568c3f359c02d2a8327"
   }
  ]
}: {
  "type": "all",
  "scripts":
  [
   {
     "type": "before",
     "slot": 53612937
   },
   {
     "type": "sig",
     "keyHash": "13589c57f20c76a46b508cca1f4434d0a1e3f568c3f359c02d2a8327"
   }
  ]
}: openBinaryFile: does not exist (No such file or directory)
After the first build-raw
Koki
CC BY-SA 4.0
2022-03-22T18:33:15.407Z
Seems something wrong with my policy script?

I follow these guides: 
1. https://developers.cardano.org/docs/native-tokens/minting-nfts#crafting-the-transaction
2. https://developers.cardano.org/docs/native-tokens/minting
3. https://devslug.com/how-to-mint-an-nft-on-cardano-testnet-using-the-command-line
Koki
CC BY-SA 4.0
2022-03-22T18:39:26.500Z
Error at step #3. See above comment.
Koki
CC BY-SA 4.0
2022-03-22T21:48:45.743Z
Ok good, that's moving along. One thing I noticed is that '--minting-script-file' accepts a file path. In your case it should be: '--minting-script-file $HOME/nft/policy/policy.json'
MC_Brisbane - JUST Pool
CC BY-SA 4.0
2022-03-23T19:01:15.167Z
When I change from variable to path as suggested, I get this error instead: 
About to run the first build-raw command
Command failed: transaction build-raw  Error: The "--mint" flag specifies an asset with a policy Id, but no corresponding monetary policy script has been provided as a witness (via the "--minting-script-file" flag). The policy Id in question is: 3d700373099c2b932990d812c02909223bc6587f2ef25b587e8d03e7
After the first build-raw
Koki
CC BY-SA 4.0
2022-03-23T23:25:57.057Z
Ok good, that has progressed to the next issue. It looks like the policy.json and/or policyID need checking. Back up a few steps and look closely at how these are created and if there is something missing or incorrect.
MC_Brisbane - JUST Pool
CC BY-SA 4.0
2022-03-29T17:36:20.610Z
Yes you are right! I recreated the policy ID and the policy script and together with the filepath change earlier it now works. Thanks a lot man! 
Koki
CC BY-SA 4.0
2022-03-29T23:25:12.610Z
That's great, glad to help
MC_Brisbane - JUST Pool
CC BY-SA 4.0
2022-03-19T00:51:49.397Z
2022-03-29T23:25:58.043Z
2022-03-29T23:25:58.043Z
MC_Brisbane - JUST Pool
<p>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 &quot;Invalid argument `&quot;type&quot;:'&quot; 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.</p>
<p><strong>Here is the code:</strong></p>
<pre><code>cardano-cli query protocol-parameters \
--testnet-magic 1097911063 \
--out-file $HOME/nft/protocol.json

tokenname=&quot;5465737469616e&quot;
tokenamount=1
txhash=&quot;989b03feb8885db90c6ca44065fe950a2208ba60c6d1b1f17aef87dcfd13c03b&quot;
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+&quot;${tokenamount} ${policyid}.${tokenname}&quot; \
--tx-out ${addressIn}+0 \
--mint=&quot;${tokenamount} ${policyid}.${tokenname}&quot; \
--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%&quot; Lovelace&quot;}

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}+&quot;${tokenamount} ${policyid}.${tokenname}&quot; \
--tx-out ${addressIn}+${change} \
--mint=&quot;${tokenamount} ${policyid}.${tokenname}&quot; \
--minting-script-file ${script} \
--invalid-hereafter ${slotnumber} \
--fee ${fee} \
--metadata-json-file $HOME/nft/metadata.json \
--out-file $HOME/nft/matx.raw
</code></pre>
<p><strong>...And here is the full error code:</strong></p>
<pre><code>Invalid argument `&quot;type&quot;:'

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 &quot;-&quot;)
</code></pre>
<p>Am I missing something really easy? can't find out what the problem is, would be very happy for getting some help. Been stuck...
<strong>Thank you very much in advance.</strong></p>
<p>//Koki</p>

<cardano-cli><nft><native-assets><minting><error>
Cardano-cli error: "Invalid argument `"type":'"
# Cardano-cli error: "Invalid argument `"type":'"

(Asked by: username_0 on 2022-03-18)

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

**Tags:** cardano-cli, nft, native-assets, minting, error

---

## 1 answers

### Answer by username_1 on 2022-03-19. Score: 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"

> **Comments:**
> **username_1**: Also, keep in mind that each command should be on one line, or use the line continuation character \ if split over multiple lines.  
> **username_0**: 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 .  
> **username_1**: 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  
> **username_0**: Okey. Tried moving the slotnumber higher above the first build-raw attempt, but still exact same error code.  
> **username_1**: 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....  
> **username_0**: Builds-raw and calc fee commands are now separated as suggested and slot number is set before first build-raw command (right after/under addressIn). Same error code created.  
> **username_1**: Can you try these steps in my updated answer.  
> **username_1**: Can you link in the document guide that you are following.  
> **username_0**: About to run the first build-raw Command failed: transaction build-raw  Error: {   "type": "all",   "scripts":   [    {      "type": "before",      "slot": 53612937    },    {      "type": "sig",      "keyHash": "13589c57f20c76a46b508cca1f4434d0a1e3f568c3f359c02d2a8327"    }   ] }: {   "type": "all",   "scripts":   [    {      "type": "before",      "slot": 53612937    },    {      "type": "sig",      "keyHash": "13589c57f20c76a46b508cca1f4434d0a1e3f568c3f359c02d2a8327"    }   ] }: openBinaryFile: does not exist (No such file or directory) After the first build-raw  
> **username_0**: Seems something wrong with my policy script?  I follow these guides:  1. https://developers.cardano.org/docs/native-tokens/minting-nfts#crafting-the-transaction 2. https://developers.cardano.org/docs/native-tokens/minting 3. https://devslug.com/how-to-mint-an-nft-on-cardano-testnet-using-the-command-line  
> **username_0**: Error at step #3. See above comment.  
> **username_1**: Ok good, that's moving along. One thing I noticed is that '--minting-script-file' accepts a file path. In your case it should be: '--minting-script-file $HOME/nft/policy/policy.json'  
> **username_0**: When I change from variable to path as suggested, I get this error instead:  About to run the first build-raw command Command failed: transaction build-raw  Error: The "--mint" flag specifies an asset with a policy Id, but no corresponding monetary policy script has been provided as a witness (via the "--minting-script-file" flag). The policy Id in question is: 3d700373099c2b932990d812c02909223bc6587f2ef25b587e8d03e7 After the first build-raw  
> **username_1**: Ok good, that has progressed to the next issue. It looks like the policy.json and/or policyID need checking. Back up a few steps and look closely at how these are created and if there is something missing or incorrect.  
> **username_0**: Yes you are right! I recreated the policy ID and the policy script and together with the filepath change earlier it now works. Thanks a lot man!   
> **username_1**: That's great, glad to help  

---

