-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMain.hs
51 lines (39 loc) · 1.4 KB
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module Main (main) where
import System.FilePath ((</>))
import qualified Data.ByteString.Base16 as Base16
import qualified Data.ByteString.Short as SBS
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import PlutusLedgerApi.V3
import Ply
import UntypedPlutusCore
import Example.Type (MyParameter (MyParameter, myParameter'ref, myParameter'tn))
data MintingPolicy = MintingPolicy (Program DeBruijn DefaultUni DefaultFun ())
instance Show MintingPolicy where
show =
Text.unpack
. Text.decodeUtf8
. Base16.encode
. SBS.fromShort
. serialiseUPLC
. (\(MintingPolicy x) -> x)
toMintingPolicy :: TypedScript 'PlutusV3 '[()] -> MintingPolicy
toMintingPolicy (TypedScript' s) = MintingPolicy s
usePolicy :: MintingPolicy -> IO ()
usePolicy _ = putStrLn "Pretending to build and submit a transaction"
main :: IO ()
main = do
tb <- readBlueprint $ "compiled" </> "nftMp.plutus"
nftMp <- getTypedScript tb "NftMP"
-- Print the Plutus ledger version used by the minting policy.
putStr "NFT Minting Policy version: "
print $ getPlutusVersion nftMp
let policy =
toMintingPolicy $
nftMp
#! MyParameter
{ myParameter'ref = TxOutRef {txOutRefId = "2be7c999fda3c9d4c3540bc9f4f28b78f8aacf9662b4489d8000bcdc18131268", txOutRefIdx = 0}
, myParameter'tn = "A"
}
print policy
usePolicy policy