I have a multiple lock-guess game with many Lockers and many Guess'ers. I initiate each lockers and guessers with:

 lockcid <- Simulator.activateContract (Wallet 1) Lock

 lockcid2 <- Simulator.activateContract (Wallet 2) Lock

after Wallet1 lock some amount:

 callEndpointOnInstance  cid "lock" LockParams{secretWord="world", amount= Ada.adaValueOf 200}

Now te guesser has to address the specific lock with a extra parameter besides the guess word, which is the identifier of the Lock contract, the cid, which is of type ContractInstanceId:

 callEndpointOnInstance  guesscid "lock" GuessParams{guessWord="world",gameId=lockcid}

But the guess verb in the contract, [which is a sligh modification of the standard guess game](https://github.com/agocorona/DAppFlow/blob/main/ContractExample/GuessGameIndexed.hs#:~:text=utxos%20%3C-%20fundsAtAddressGeq%20%20%20cid%20(Ada.lovelaceValueOf%201)

expect an Address:

utxos <- fundsAtAddressGeq   xxxxherexxxx (Ada.lovelaceValueOf 1)

How I can solve this?


Ok there is no evident direct relation because my game address depend on the hash of the user following the plutus pioneer program example Plutus Pioneer Program - Iteration #2 - Lecture #3 parameterized contracts. Alternatively I can make it depend on the contractInstance directly, instead of the user hash.That would be even more flexible since a single user could make more than one lock.

For the latter, I would need to pass explicity the contract instance to lock and guess

Or alternatively, in lock, extract the own contract instance from some magic primitive.


Since PubKeyHashes or ContractInstanceIds between off-chain and on-chain code is not possible (makeLift complains about that) I used an Integer as parameter of the on-chain script to differentiate between different Locks. And that works.

  • I looked at the Plutus code and there is no evident relation between the two types. But they should be related in some way, although Plutus is quite new for me
    – agocorona
    Nov 2, 2021 at 14:51
  • Ok there is no evident direct relation because the game address depend on the hash of the user and the validator script:
    – agocorona
    Nov 2, 2021 at 15:03


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.