<p><code>RedeemerType</code> and <code>DatumType</code> both require the data type to be specified, e.g. <code>RedeemerType Integer</code>.</p>
<p>If you use <code>AllowAmbiguousTypes</code> language extension you can do, e.g. <code>RedeemerType a</code>.</p>

CC BY-SA 4.0
2023-04-12T15:00:07.063Z
2023-04-12T15:00:07.063Z
james
<p>My code is here.</p>
<pre class="lang-haskell prettyprint-override"><code>{-# LANGUAGE DeriveAnyClass        #-}
{-# LANGUAGE DataKinds             #-}
{-# LANGUAGE DeriveGeneric         #-}
{-# LANGUAGE ScopedTypeVariables   #-}
{-# LANGUAGE TemplateHaskell       #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators         #-}

module MarketState (
  createMarket
)where

import Plutus.Contract as Contract
import Control.Monad (void)
import Control.Applicative
import Data.Aeson (ToJSON, FromJSON)
import GHC.Generics (Generic)
import Schema (ToSchema)
import Data.String (String)
import Data.Text (Text)
import qualified PlutusTx
import Ledger (PubKeyHash(..))
import qualified Plutus.V1.Ledger.Ada as Ada
import Ledger.Constraints (TxConstraints)
import Ledger.Contexts (ScriptContext)
import Ledger.Typed.Scripts (DatumType, RedeemerType)

-- Define the market parameters
data MarketParams = MarketParams {
  event :: String,
  outcomes :: [String],
  fees :: Integer
} deriving (Generic, ToJSON, FromJSON, ToSchema)

PlutusTx.makeLift ''MarketParams

-- Define the smart contract logic
data Market = Market {
  params :: MarketParams,
  creator :: PubKeyHash
} deriving (Generic, ToJSON, FromJSON, ToSchema)

PlutusTx.makeLift ''Market

-- Create a function to deploy the smart contract
createMarket :: MarketParams -&gt; Contract w s Text ()
createMarket params = do
  pk &lt;- PubKeyHash &lt;$&gt; ownPubKey
  let market = Market params pk
  void $ submitTxConstraints (marketConstraints market) (tx market)
  logInfo $ &quot;Market deployed at &quot; &lt;&gt; show (address market)

-- Define the market constraints
marketConstraints :: Market -&gt; TxConstraints (RedeemerType -&gt; ScriptContext -&gt; Bool)(DatumType, ())
marketConstraints market = mustValidateIn (to $ scriptAddress market)

-- Define the transaction logic
tx :: Market -&gt; TxConstraints () ()
tx market = mustSpendScriptOutput (scriptTxOut $ market) (Redeemer $ PlutusTx.toBuiltinData BuyShares)
         &lt;&gt; mustPayToPubKey (creator market) (Ada.lovelaceValueOf $ fees $ params market)
</code></pre>
<p>I am a Plutus Smart Contract beginner. I don't sure how to fix this error. Please help me to fix the error.</p>
<pre><code>src/MarketState.hs:58:47: error:
    • Expecting one more argument to ‘RedeemerType’
      Expected a type, but ‘RedeemerType’ has kind ‘* -&gt; *’
    • In the first argument of ‘TxConstraints’, namely
        ‘(RedeemerType -&gt; ScriptContext -&gt; Bool)’
      In the type signature:
        marketConstraints :: Market
                             -&gt; TxConstraints (RedeemerType
                                               -&gt; ScriptContext -&gt; Bool) (DatumType, ())
   |
58 | marketConstraints :: Market -&gt; TxConstraints (RedeemerType -&gt; ScriptContext -&gt; Bool) (DatumType, ())
   |                                               ^^^^^^^^^^^^

src/MarketState.hs:58:87: error:
    • Expecting one more argument to ‘DatumType’
      Expected a type, but ‘DatumType’ has kind ‘* -&gt; *’
    • In the second argument of ‘TxConstraints’, namely
        ‘(DatumType, ())’
      In the type signature:
        marketConstraints :: Market
                             -&gt; TxConstraints (RedeemerType
                                               -&gt; ScriptContext -&gt; Bool) (DatumType, ())
   |
58 | marketConstraints :: Market -&gt; TxConstraints (RedeemerType -&gt; ScriptContext -&gt; Bool) (DatumType, ())
</code></pre>

<plutus><smart-contract><haskell><blockchain><marketing>
how to use ownPubKey and RedeemerType and DatumType
# how to use ownPubKey and RedeemerType and DatumType

(Asked by: username_0 on 2023-04-12)

My code is here.
{-# LANGUAGE DeriveAnyClass        #-}
{-# LANGUAGE DataKinds             #-}
{-# LANGUAGE DeriveGeneric         #-}
{-# LANGUAGE ScopedTypeVariables   #-}
{-# LANGUAGE TemplateHaskell       #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators         #-}

module MarketState (
  createMarket
)where

import Plutus.Contract as Contract
import Control.Monad (void)
import Control.Applicative
import Data.Aeson (ToJSON, FromJSON)
import GHC.Generics (Generic)
import Schema (ToSchema)
import Data.String (String)
import Data.Text (Text)
import qualified PlutusTx
import Ledger (PubKeyHash(..))
import qualified Plutus.V1.Ledger.Ada as Ada
import Ledger.Constraints (TxConstraints)
import Ledger.Contexts (ScriptContext)
import Ledger.Typed.Scripts (DatumType, RedeemerType)

-- Define the market parameters
data MarketParams = MarketParams {
  event :: String,
  outcomes :: [String],
  fees :: Integer
} deriving (Generic, ToJSON, FromJSON, ToSchema)

PlutusTx.makeLift ''MarketParams

-- Define the smart contract logic
data Market = Market {
  params :: MarketParams,
  creator :: PubKeyHash
} deriving (Generic, ToJSON, FromJSON, ToSchema)

PlutusTx.makeLift ''Market

-- Create a function to deploy the smart contract
createMarket :: MarketParams -> Contract w s Text ()
createMarket params = do
  pk <- PubKeyHash <$> ownPubKey
  let market = Market params pk
  void $ submitTxConstraints (marketConstraints market) (tx market)
  logInfo $ "Market deployed at " <> show (address market)

-- Define the market constraints
marketConstraints :: Market -> TxConstraints (RedeemerType -> ScriptContext -> Bool)(DatumType, ())
marketConstraints market = mustValidateIn (to $ scriptAddress market)

-- Define the transaction logic
tx :: Market -> TxConstraints () ()
tx market = mustSpendScriptOutput (scriptTxOut $ market) (Redeemer $ PlutusTx.toBuiltinData BuyShares)
         <> mustPayToPubKey (creator market) (Ada.lovelaceValueOf $ fees $ params market)

I am a Plutus Smart Contract beginner. I don't sure how to fix this error. Please help me to fix the error.
src/MarketState.hs:58:47: error:
    • Expecting one more argument to ‘RedeemerType’
      Expected a type, but ‘RedeemerType’ has kind ‘* -> *’
    • In the first argument of ‘TxConstraints’, namely
        ‘(RedeemerType -> ScriptContext -> Bool)’
      In the type signature:
        marketConstraints :: Market
                             -> TxConstraints (RedeemerType
                                               -> ScriptContext -> Bool) (DatumType, ())
   |
58 | marketConstraints :: Market -> TxConstraints (RedeemerType -> ScriptContext -> Bool) (DatumType, ())
   |                                               ^^^^^^^^^^^^

src/MarketState.hs:58:87: error:
    • Expecting one more argument to ‘DatumType’
      Expected a type, but ‘DatumType’ has kind ‘* -> *’
    • In the second argument of ‘TxConstraints’, namely
        ‘(DatumType, ())’
      In the type signature:
        marketConstraints :: Market
                             -> TxConstraints (RedeemerType
                                               -> ScriptContext -> Bool) (DatumType, ())
   |
58 | marketConstraints :: Market -> TxConstraints (RedeemerType -> ScriptContext -> Bool) (DatumType, ())

**Tags:** plutus, smart-contract, haskell, blockchain, marketing

---

## 1 answers

### Answer by username_1 on 2023-04-12. Score: 0

`RedeemerType` and `DatumType` both require the data type to be specified, e.g. `RedeemerType Integer`.

If you use `AllowAmbiguousTypes` language extension you can do, e.g. `RedeemerType a`.


---

