<p>&quot;Unpaired digit&quot; is an error from the <code>fromHex</code> function, which needs pairs of hexadecimal digits. So I think the error comes from your fifth argument <code>&quot;a12&quot;</code>.</p>

CC BY-SA 4.0
2022-01-28T12:09:48.907Z
Thanks. I spent some months looking for "Unpaired digit" in the libraries to no avail.
Aoaddeola
CC BY-SA 4.0
2022-01-28T09:37:52.573Z
2022-01-28T09:37:52.573Z
Sjoerd Visscher
<p>Command:</p>
<p><code>cabal run my-app &quot;a1&quot; 100 &quot;a2&quot; 120000 &quot;a12&quot; &quot;Token&quot; &quot;Product&quot; True 234532453452 True 120000 32432342234234 &quot;a2&quot; &quot;a2&quot; 1 &quot;a3&quot;</code></p>
<p>Output:</p>
<pre><code>my-app: unpaired digit
CallStack (from HasCallStack):
  error, called at src/Data/Either/Extras.hs:6:34 in plutus-ledger-api-0.1.0.0-722448a5fae0f9232a42f0b4d7b674e63f6fcb91b2188125b0779e3215e4fb4f:Data.Either.Extras
</code></pre>
<p>Code snippet:</p>
<pre><code>
data STP = STP
    { stpA      :: !Bool
    , stpB      :: !POSIXTime
    , stpC      :: !Bool
    , stpD      :: !(Maybe Integer)
    , stpE      :: !(Maybe POSIXTime)
    , stpF      :: !(Maybe BuiltinByteString)
    } deriving (Show, Generic, FromJSON, ToJSON, Prelude.Eq, ToSchema)

data GOP = GOP
    { gopG      :: !PaymentPubKeyHash
    , gopH      :: !Integer
    , gopI      :: !BuiltinByteString 
    , gopJ      :: !Integer
    , gopK      :: !CurrencySymbol
    , gopL      :: !TokenName 
    , gopM      :: !TokenName
    , gopType   :: !STP
    , gopToken  :: !(Maybe ThreadToken)
    } deriving (Show, Generic, Eq, Ord, FromJSON, ToJSON, Prelude.Eq, ToSchema)

-------------

main :: IO ()
main = do
    [gopG', gopH', gopI', gopJ', gopK', gopL', gopM', stpA', stpB', stpC', stpD', stpE', stpF', txOutRefId', txOutRefIdx', ttCurrencySymbol'] &lt;- getArgs
    let b   = POSIXTime (read stpB')
        d   = Just (read stpD')
        e   = Just $ POSIXTime (read stpE')
        stp         = STP
                    { stpA      = read stpA'
                    , stpB      = b
                    , stpC      = read stpC'
                    , stpD      = d
                    , stpE      = e
                    , stpF      = Nothing
                    }
        gop         = GOP
                    { gopG      = PaymentPubKeyHash (fromString gopG')
                    , gopH      = read gopH'              
                    , gopI      = fromString gopI'
                    , gopJ      = read gopJ'           
                    , gopK      = fromString gopK'
                    , gopL      = fromString gopL'
                    , gopM      = fromString gopM'
                    , gopType   = stp
                    , gopToken  = Just $ ThreadToken (TxOutRef (fromString txOutRefId') txOutRefIdx') $ fromString ttCurrencySymbol'
                    }
        orderFile = &quot;scripts/app.plutus&quot;
    writePlutusScript orderFile (dagribizOrderSerialised gop) (dagribizOrderSBS gop)


writePlutusScript :: FilePath -&gt; PlutusScript PlutusScriptV1 -&gt; SBS.ShortByteString -&gt; IO ()
writePlutusScript filename scriptSerial scriptSBS =
  do
  result &lt;- writeFileTextEnvelope filename Nothing scriptSerial
  case result of
    Left err -&gt; print $ displayError err
    Right () -&gt; return ()
</code></pre>

<plutus>
Problem serializing on-chain code into Plutus Script
# Problem serializing on-chain code into Plutus Script

(Asked by: username_0 on 2022-01-27)

Command:
cabal run my-app "a1" 100 "a2" 120000 "a12" "Token" "Product" True 234532453452 True 120000 32432342234234 "a2" "a2" 1 "a3"
Output:
my-app: unpaired digit
CallStack (from HasCallStack):
  error, called at src/Data/Either/Extras.hs:6:34 in plutus-ledger-api-0.1.0.0-722448a5fae0f9232a42f0b4d7b674e63f6fcb91b2188125b0779e3215e4fb4f:Data.Either.Extras

Code snippet:

data STP = STP
    { stpA      :: !Bool
    , stpB      :: !POSIXTime
    , stpC      :: !Bool
    , stpD      :: !(Maybe Integer)
    , stpE      :: !(Maybe POSIXTime)
    , stpF      :: !(Maybe BuiltinByteString)
    } deriving (Show, Generic, FromJSON, ToJSON, Prelude.Eq, ToSchema)

data GOP = GOP
    { gopG      :: !PaymentPubKeyHash
    , gopH      :: !Integer
    , gopI      :: !BuiltinByteString 
    , gopJ      :: !Integer
    , gopK      :: !CurrencySymbol
    , gopL      :: !TokenName 
    , gopM      :: !TokenName
    , gopType   :: !STP
    , gopToken  :: !(Maybe ThreadToken)
    } deriving (Show, Generic, Eq, Ord, FromJSON, ToJSON, Prelude.Eq, ToSchema)

-------------

main :: IO ()
main = do
    [gopG', gopH', gopI', gopJ', gopK', gopL', gopM', stpA', stpB', stpC', stpD', stpE', stpF', txOutRefId', txOutRefIdx', ttCurrencySymbol'] <- getArgs
    let b   = POSIXTime (read stpB')
        d   = Just (read stpD')
        e   = Just $ POSIXTime (read stpE')
        stp         = STP
                    { stpA      = read stpA'
                    , stpB      = b
                    , stpC      = read stpC'
                    , stpD      = d
                    , stpE      = e
                    , stpF      = Nothing
                    }
        gop         = GOP
                    { gopG      = PaymentPubKeyHash (fromString gopG')
                    , gopH      = read gopH'              
                    , gopI      = fromString gopI'
                    , gopJ      = read gopJ'           
                    , gopK      = fromString gopK'
                    , gopL      = fromString gopL'
                    , gopM      = fromString gopM'
                    , gopType   = stp
                    , gopToken  = Just $ ThreadToken (TxOutRef (fromString txOutRefId') txOutRefIdx') $ fromString ttCurrencySymbol'
                    }
        orderFile = "scripts/app.plutus"
    writePlutusScript orderFile (dagribizOrderSerialised gop) (dagribizOrderSBS gop)


writePlutusScript :: FilePath -> PlutusScript PlutusScriptV1 -> SBS.ShortByteString -> IO ()
writePlutusScript filename scriptSerial scriptSBS =
  do
  result <- writeFileTextEnvelope filename Nothing scriptSerial
  case result of
    Left err -> print $ displayError err
    Right () -> return ()

**Tags:** plutus

---

## 1 answers

### Answer by username_1 on 2022-01-28. Score: 2 | Accepted answer

"Unpaired digit" is an error from the `fromHex` function, which needs pairs of hexadecimal digits. So I think the error comes from your fifth argument `"a12"`.

> **Comments:**
> **username_0**: Thanks. I spent some months looking for "Unpaired digit" in the libraries to no avail.  

---

