Closed gpsanant closed 2 years ago
The error happens because of truthMarketAddress
usage. Scripts.mkTypedValidator
and Scripts.validatorScript
are off-chain functions and plutus can't compile them. You should use mkTruthMarketValidator
directly.
The error happens because of
truthMarketAddress
usage.Scripts.mkTypedValidator
andScripts.validatorScript
are off-chain functions and plutus can't compile them. You should usemkTruthMarketValidator
directly.
Thanks for the clarification. How would I go about getting the address from the mkTruthMarketValidator
output?
I guess you need to introduce a new argument validatorHash
to policy
and mkPolicy
functions and pass the hash to them.
I guess you need to introduce a new argument
validatorHash
topolicy
andmkPolicy
functions and pass the hash to them.
What if the validator is parameterized as in this case? Within another script, how would I refer to the address of a script with a parameterized validator given the parameter?
Well I can only suggest to try and check. There is a limitation that you can't mix on-chain and off-chain code. You can pass values as arguments, but without direct calling.
Well I can only suggest to try and check. There is a limitation that you can't mix on-chain and off-chain code. You can pass values as arguments, but without direct calling.
People haven't run into this before? Getting a parameterized script address from within another script seems like it would be a pretty common task. Have you seen any solutions for this?
Within another script, how would I refer to the address of a script with a parameterized validator given the parameter?
What I think you're asking is impossible. I think you're asking: "on-chain, I want to be passed a parameter at runtime, and then calculate the hash of whatever the parameterized validator would look like, given that parameter". That would require running the whole compiler. If you want to compute with scripts themselves you have to do that off-chain, and then you can pass in the hash to another script.
Closing this issue as the initial problem was solved.
Area
[x] Plutus Foundation Related to the GHC plugin, Haskell-to-Plutus compiler, on-chain code [] Plutus Application Framework Related to the Plutus application backend (PAB), emulator, Plutus libraries [] Marlowe Related to Marlowe [] Other Any other topic (Playgrounds, etc.)
Summary
I keep running into the following compiler error
Steps to reproduce
Copy the following files into the same directory.
I am trying to load the
TruthMarketFactory.hs
contract.This is
TruthMarket.hs
Where
Expected behavior
I want this to compile but something seems to be uncompilable here...
System info (please complete the following information):