<p>I think your endpoint looks something like this</p>
<pre><code>endpoints :: forall  e. AsContractError e =&gt; Contract () yourSchema e ()
</code></pre>
<p>now in TraceMonad its confused what type should we put for variable e.</p>
<p>if you change your endpoint definition  to</p>
<pre><code>endpoints :: Contract () yourSchema Text ()
</code></pre>
<p>This worked fine for me as now we are passing concrete types for endpoint.</p>

CC BY-SA 4.0
2022-06-05T14:16:33.487Z
2022-06-05T14:17:30.743Z
2022-06-05T14:17:30.743Z
Piyush
<p>This is changed in newer versions so you need to change:</p>
<pre><code>h1 &lt;- activateContractWallet (Wallet 1) endpoints
</code></pre>
<p>to</p>
<pre><code>h1 &lt;- activateContractWallet w1 (endpoints @ContractError)
</code></pre>
<p>For w1 you need to import <code>Plutus.Contract.Test</code> and for ContractError <code>Wallet.Types</code></p>

CC BY-SA 4.0
2021-12-07T06:18:51.543Z
2021-12-07T06:18:51.543Z
zarej
<p>Well, it's because you're not specifying where the <code>endpoints</code> variable comes from. So, basically the error is saying: You've various instances of <code>endpoints</code> variable, which of those is it?</p>
<p>Try to specify it on your imports, something like this:</p>
<p><code>import OffChainCode (endpoints)</code></p>
<p>And if your offchain code is in the <code>Contract</code> file, try to change the name of the module Contract, as it's a Plutus type.</p>

CC BY-SA 4.0
2021-12-06T15:45:20.720Z
2021-12-06T15:45:20.720Z
georgeos
<p>I'm writing emulator trace tests for the spacebudz contracts. Here is a minimum example:</p>
<pre><code>{-# LANGUAGE DataKinds             #-}
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude     #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE ScopedTypeVariables   #-}
{-# LANGUAGE TypeApplications      #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ExtendedDefaultRules  #-}

module Test.EmulatorTrace where

import           Control.Monad           hiding ( fmap )
import           Control.Monad.Freer.Extras    as Extras
import           Data.Default                   ( Default(..) )
import qualified Data.Map                      as Map
import           Ledger
import           Ledger.Ada                    as Ada
import           Ledger.TimeSlot
import           Ledger.Value
import           Plutus.Contract.Trace
import           Plutus.Trace.Emulator         as Emulator
import           PlutusTx.Prelude
import           Prelude                        ( IO
                                                , Show(..)
                                                )
import           Wallet.Emulator.Wallet

import           Contract


test :: IO ()
test = do
  test'

test' :: IO ()
test' = runEmulatorTraceIO' def def myTrace

myTrace :: EmulatorTrace ()
myTrace = do

  h1 &lt;- activateContractWallet (Wallet 1) endpoints
  callEndpoint @&quot;init&quot; h1 ()

  void $ Emulator.waitNSlots 10
</code></pre>
<p>However, when trying to activate the wallets for the emulator, I get this error:</p>
<pre><code>src/Test/EmulatorTrace.hs:45:43: error:
    • Ambiguous type variable ‘e0’ arising from a use of ‘endpoints’
      prevents the constraint ‘(Wallet.Types.AsContractError
                                  e0)’ from being solved.
      Probable fix: use a type annotation to specify what ‘e0’ should be.
      These potential instances exist:
        two instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘activateContractWallet’, namely
        ‘endpoints’
      In a stmt of a 'do' block:
        h1 &lt;- activateContractWallet (Wallet 1) endpoints
      In the expression:
        do h1 &lt;- activateContractWallet (Wallet 1) endpoints
           callEndpoint @&quot;init&quot; h1 ()
           void $ waitNSlots 10
   |
45 |   h1 &lt;- activateContractWallet (Wallet 1) endpoints
</code></pre>
<p>How is it possible, when every contract example has the same code?</p>

<plutus><haskell>
Ambiguous type variable ‘e0’ arising from a use of ‘endpoints’
# Ambiguous type variable ‘e0’ arising from a use of ‘endpoints’

(Asked by: username_0 on 2021-12-06)

I'm writing emulator trace tests for the spacebudz contracts. Here is a minimum example:
{-# LANGUAGE DataKinds             #-}
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude     #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE ScopedTypeVariables   #-}
{-# LANGUAGE TypeApplications      #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ExtendedDefaultRules  #-}

module Test.EmulatorTrace where

import           Control.Monad           hiding ( fmap )
import           Control.Monad.Freer.Extras    as Extras
import           Data.Default                   ( Default(..) )
import qualified Data.Map                      as Map
import           Ledger
import           Ledger.Ada                    as Ada
import           Ledger.TimeSlot
import           Ledger.Value
import           Plutus.Contract.Trace
import           Plutus.Trace.Emulator         as Emulator
import           PlutusTx.Prelude
import           Prelude                        ( IO
                                                , Show(..)
                                                )
import           Wallet.Emulator.Wallet

import           Contract


test :: IO ()
test = do
  test'

test' :: IO ()
test' = runEmulatorTraceIO' def def myTrace

myTrace :: EmulatorTrace ()
myTrace = do

  h1 <- activateContractWallet (Wallet 1) endpoints
  callEndpoint @"init" h1 ()

  void $ Emulator.waitNSlots 10

However, when trying to activate the wallets for the emulator, I get this error:
src/Test/EmulatorTrace.hs:45:43: error:
    • Ambiguous type variable ‘e0’ arising from a use of ‘endpoints’
      prevents the constraint ‘(Wallet.Types.AsContractError
                                  e0)’ from being solved.
      Probable fix: use a type annotation to specify what ‘e0’ should be.
      These potential instances exist:
        two instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘activateContractWallet’, namely
        ‘endpoints’
      In a stmt of a 'do' block:
        h1 <- activateContractWallet (Wallet 1) endpoints
      In the expression:
        do h1 <- activateContractWallet (Wallet 1) endpoints
           callEndpoint @"init" h1 ()
           void $ waitNSlots 10
   |
45 |   h1 <- activateContractWallet (Wallet 1) endpoints

How is it possible, when every contract example has the same code?

**Tags:** plutus, haskell

---

## 3 answers

### Answer by username_1 on 2022-06-05. Score: 0

I think your endpoint looks something like this
endpoints :: forall  e. AsContractError e => Contract () yourSchema e ()

now in TraceMonad its confused what type should we put for variable e.
if you change your endpoint definition  to
endpoints :: Contract () yourSchema Text ()

This worked fine for me as now we are passing concrete types for endpoint.


---

### Answer by username_2 on 2021-12-07. Score: 0

This is changed in newer versions so you need to change:
h1 <- activateContractWallet (Wallet 1) endpoints

to
h1 <- activateContractWallet w1 (endpoints @ContractError)

For w1 you need to import Plutus.Contract.Test and for ContractError Wallet.Types


---

### Answer by username_3 on 2021-12-06. Score: 0

Well, it's because you're not specifying where the `endpoints` variable comes from. So, basically the error is saying: You've various instances of `endpoints` variable, which of those is it?

Try to specify it on your imports, something like this:

`import OffChainCode (endpoints)`

And if your offchain code is in the `Contract` file, try to change the name of the module Contract, as it's a Plutus type.


---

