<p>This is probably not possible as the redeemer code is manipulated/examined from within a template haskell splice and you are running into what is called the &quot;template haskell stage restriction&quot;.</p>

CC BY-SA 4.0
2022-10-09T21:18:16.733Z
2022-10-09T21:18:16.733Z
Erik de Castro Lopo
<p>What I've done to debug <code>Integer</code>s is to write a function that converts them into a <code>BuiltinByteString</code> and then decodeUtf8 it into a <code>BuiltinString</code> which is passed to any of the available <code>trace</code> functions.</p>
<p>I assume it could work for more complex data as well, but I have not tried that yet.</p>
<p>Example of what I described above:</p>
<pre><code>{-# INLINABLE intBS #-}
intBS :: Integer -&gt; BuiltinByteString
intBS i
  | i &lt; 10    = consByteString (48 + i) emptyByteString
  | otherwise = appendByteString (intBS (divide i 10)) (intBS (modulo i 10))


-- ...
    traceIfFalse (decodeUtf8 $ intBS coolInt) $ ...
--...
</code></pre>
<p>Hope this helps.</p>

CC BY-SA 4.0
2022-10-10T16:55:25.000Z
2022-10-10T16:55:25.000Z
CantTouchDis
<p>Is this even possible?</p>
<pre><code>traceIfFalse  (&quot;A&quot;++show(scriptContextTxInfo)) FoundIt
</code></pre>
<p>As logging onchain is just possible with this traceIfFalse ... I'm not finding a solution to make that line work</p>

<transaction><on-chain>
traceIfFalse is it possible to pass a string not "fixed"
# traceIfFalse is it possible to pass a string not "fixed"

(Asked by: username_0 on 2022-10-08)

Is this even possible?
traceIfFalse  ("A"++show(scriptContextTxInfo)) FoundIt

As logging onchain is just possible with this traceIfFalse ... I'm not finding a solution to make that line work

**Tags:** transaction, on-chain

---

## 2 answers

### Answer by username_2 on 2022-10-10. Score: 1 | Accepted answer

What I've done to debug Integers is to write a function that converts them into a BuiltinByteString and then decodeUtf8 it into a BuiltinString which is passed to any of the available trace functions.
I assume it could work for more complex data as well, but I have not tried that yet.
Example of what I described above:
{-# INLINABLE intBS #-}
intBS :: Integer -> BuiltinByteString
intBS i
  | i < 10    = consByteString (48 + i) emptyByteString
  | otherwise = appendByteString (intBS (divide i 10)) (intBS (modulo i 10))


-- ...
    traceIfFalse (decodeUtf8 $ intBS coolInt) $ ...
--...

Hope this helps.


---

### Answer by username_1 on 2022-10-09. Score: 2

This is probably not possible as the redeemer code is manipulated/examined from within a template haskell splice and you are running into what is called the "template haskell stage restriction".


---

