<p>Checking the <code>man</code> page for <code>cardano-cli transaction build</code>, I see:</p>
<pre><code>  --mint-redeemer-value JSON VALUE
                           The JSON value for the script data. Supported JSON
                           data types: string, number, object &amp; array.
</code></pre>
<p>This is expecting a basic JSON value (no schema).</p>
<p>Since you are providing JSON that follows the schema for script data, you will need to write your JSON to a file and use <code>--mint-redeemer-file</code> instead:</p>
<pre><code>
cardano-cli transaction build \
--mint-redeemer-file my-file.json 
...
</code></pre>

CC BY-SA 4.0
2022-02-26T03:39:55.680Z
2022-02-26T03:39:55.680Z
base2c
<p>I started creating this python library with most of the Plutus types represented as classes. I get their values by calling the json method, which returns the JSON equivalent of this type so it can be passed to cardano-cli, like the following:</p>
<pre><code>class PubKeyHash(object):
    ...
    def json(self):
        return json.dumps({
            &quot;bytes&quot;: self.__pkh
        })
</code></pre>
<p>This worked well while I was writing these values to files and passing the files path to cardano-cli, but since I'm using ssh to connect to the node and writing files all the time is not very performant, I think it would be great to, instead, pass the JSON values directly.</p>
<p>When I try to do this using the <code>--mint-redeemer-value</code> argument, though, it returns me a weird error <code>Exception: option --mint-redeemer-value: Failed reading: not a valid json value</code>, which makes me assume my JSON is not formatted correctly.</p>
<p>This is the command I'm running:</p>
<pre><code>...
--mint-redeemer-value {&quot;constructor&quot;:0,&quot;fields&quot;:[{&quot;constructor&quot;:0,&quot;fields&quot;:[{&quot;bytes&quot;:&quot;
02fbd1c6934d888ec6575de3ec2f87dd75aec2891f20e0dc38fa7440e47a3803&quot;}]},{&quot;int&quot;:0}]} \
...
</code></pre>
<p>If it is the case that my JSON is formatted incorrectly, how should I format it? If it is not, can anyone bring me some light on why I'm running into this error?</p>

<cardano-cli><nft><json>
How to format a JSON value in the cardano-cli
# How to format a JSON value in the cardano-cli

(Asked by: username_0 on 2022-02-24)

I started creating this python library with most of the Plutus types represented as classes. I get their values by calling the json method, which returns the JSON equivalent of this type so it can be passed to cardano-cli, like the following:
class PubKeyHash(object):
    ...
    def json(self):
        return json.dumps({
            "bytes": self.__pkh
        })

This worked well while I was writing these values to files and passing the files path to cardano-cli, but since I'm using ssh to connect to the node and writing files all the time is not very performant, I think it would be great to, instead, pass the JSON values directly.
When I try to do this using the --mint-redeemer-value argument, though, it returns me a weird error Exception: option --mint-redeemer-value: Failed reading: not a valid json value, which makes me assume my JSON is not formatted correctly.
This is the command I'm running:
...
--mint-redeemer-value {"constructor":0,"fields":[{"constructor":0,"fields":[{"bytes":"
02fbd1c6934d888ec6575de3ec2f87dd75aec2891f20e0dc38fa7440e47a3803"}]},{"int":0}]} \
...

If it is the case that my JSON is formatted incorrectly, how should I format it? If it is not, can anyone bring me some light on why I'm running into this error?

**Tags:** cardano-cli, nft, json

---

## 1 answers

### Answer by username_1 on 2022-02-26. Score: 1 | Accepted answer

Checking the man page for cardano-cli transaction build, I see:
  --mint-redeemer-value JSON VALUE
                           The JSON value for the script data. Supported JSON
                           data types: string, number, object & array.

This is expecting a basic JSON value (no schema).
Since you are providing JSON that follows the schema for script data, you will need to write your JSON to a file and use --mint-redeemer-file instead:

cardano-cli transaction build \
--mint-redeemer-file my-file.json 
...


---

