Hot answers tagged

11 votes
Accepted

What does @ prefix means?

It means type application. In this case, the function is polymorphic with the following type: logInfo :: forall a effs. Member (LogMsg a) effs => a -> Eff effs () by using TypeApplications ...
  • 477
8 votes
Accepted

How can I find the Haskell source code for the sqrt function?

By entering :i sqrt using ghci, we can see that sqrt is -- Defined in ‘GHC.Float’ A quick google shows that the source code repo is on https://gitlab.haskell.org/ghc/ghc. Entering sqrt in the search ...
  • 1,527
8 votes
Accepted

Why not just simply use Haskell instead of Plutus?

There are many reasons. For example: You need tooling for the communication between the on-chain and the off-chain code and many other tasks. You need tooling that generates code where the on-chain ...
  • 141
5 votes

Logging in validator

You're running into trouble because logInfo is meant to be used inside the Contract monad. The Wallet code uses the Contract monad but the validator code doesn't. If you're not familiar with how ...
5 votes
Accepted

Meaning of <$> notation

It's a functor map which is essentially an fmap function for the functor class. This might be of some use: https://www.fpcomplete.com/haskell/tutorial/operators/
4 votes
Accepted

Understanding do notation with Monads in Plutus Pioneer Week 04

The 'secret' is in the bindWriter function that drive the Writer monad. instance Monad Writer where return a = Writer a [] (>>=) = bindWriter It is the bindWriter function that ...
  • 460
4 votes

Is there documentation on the Prerequisites for Plutus Pioneer code?

There are instructions on the official input-output-hk/plutus-pioneer-program repo in the exercises chapter here: https://github.com/input-output-hk/plutus-pioneer-program#exercises I think you may be ...
  • 3,313
4 votes
Accepted

What do unusual symbols "@" and ".\/" in off-chain code mean?

@String is from TypeApplications. logInfo has type logInfo :: forall a effs. Member (LogMsg a) effs => a -> Eff effs (), so logInfo @String fixes a to be String. (That this is needed here is ...
3 votes
Accepted

Insufficient funds when trying to use script unspent output

expected: Value (Map [(,Map [(\\\"\\\",3242)])])\")" Try adding a few zeros to the starting balances. It's saying it doesn't have enough to pay the fees. I'm surprised that the ...
3 votes
Accepted

Pioneer Lecture 4 recursion - how is it not infinite?

payContract blocks on the first line of the do block until the pay endpoint is invoked. The input of the invocation is put in pp. pp <- endpoint @"pay" It then executes the endpoint ...
  • 460
3 votes
Accepted

Haskell IDE INLINABLE error help

The way HLS is enabled without plugin errors is discussed here: https://github.com/input-output-hk/plutus-starter/pull/23 https://github.com/input-output-hk/plutus-starter/pull/29 https://github.com/...
3 votes

Haskell IDE INLINABLE error help

The pragma {-# LANGUAGE NoImplicitPrelude #-} and import PlutusTx.Prelude might help. It replaces the implicitly defined functions in Haskell by inlinable alternatives. Here is an example for Boolean ...
3 votes

What does two consecutive apostrophes mean in Haskell and Plutus?

The apostrophe(s) in Haskell (and thus Plutus) are part of the name; they do not hold any specific meaning. Haskell as a functional programming language borrows from mathematical notation. An ...
  • 1,527
3 votes
Accepted

How can I convert `Slot` to `TokenName`

I've just run this in the REPL with success. Not sure if it is the best way, though. TokenName { unTokenName = Data.ByteString.Char8.pack $ show (toInteger (getSlot 1)) }
  • 514
3 votes

haskell-language-server used in VSCode Haskell extension produces spurious INLINABLE compilation error message

I found a workaround that is sufficient to get my IDE usable. **WORKAROUND: ** By comparing the cabal files for Plutus week10 (which compiles OK in IDE) with week07 (error), I discovered that adding ...
  • 161
3 votes

Type instance syntax

This code is implementing the ValidatorTypes "Typeclass" for the Auctioning datatype. Typeclasses are Haskell's way of handling polymorphism, like abstract classes in an OO language. In this ...
3 votes
Accepted

The PAB is no longer working after upgrading the Plutus version

Plutus is still in active development, so changes in the API can occur every week. For your case, go look at a similar example in the PAB. In your specific case, you'll need to change your handlers ...
  • 365
3 votes
Accepted

Where is the Haskell course mentioned by Lars?

Lars's courses are spread around various Youtube channels. I think that the one you are referring to is "Crypto Mongolia". Here it is: https://youtube.com/playlist?list=...
  • 141
3 votes

Meaning of <$> notation

For Haskell questions of this sort Hoogle is the ultimate resource. For operators like <$> you need to enclose them in parenthesis eg (<$>).
3 votes
Accepted

Lesson 3 - unsure how "sigs" is created or where txInfoSignatories comes from or how it works

TxInfo is a Record type and one of the fields of the TxInfo-record is txInfoSignatories. The fields in the records work as "getters". You may refer e.g. to learnyouhaskell-records for an ...
3 votes
Accepted

What's the difference between Ledger.CurrencySymbol and Plutus.V1.Ledger.Value.CurrencySymbol?

If you look at the source of Ledger, you will see that it reexports CurrencySymbol from the Value module, so yes, they are the same: module Ledger ( module Export, AssetClass, ...
3 votes

Continue to be utterly disoriented as to where these magic words come from and how they might be connected

I am very familiar with the Haskell language (of which Plutus is a dialect) but not super familiar with this course. The message Data constructor not in scope: EmulatorTrace means you are using an ...
3 votes
Accepted

What is a library stanza?

I recommend you this article: https://vrom911.github.io/blog/common-stanzas Take into account that stanzas is a cabal thing (not Haskell, not Plutus). However Plutus projects can be created using ...
  • 1,264
3 votes
Accepted

Empty TokenName Literal Overloading in Week05 Homework2

After digging into Plutus source, I think I've found why tn == "" crashes at runtime. The problem might be that the instance of TokenName IsString doesn't use the INLINABLE pragma in the ...
  • 1,264
3 votes
Accepted

Haskell + Blockfrost toolchain?

I think you want the cardano-api, part of the cardano-node repo. Most things that can be done, it can do. At the very least its the place to start. The cardano-cli provides a set of examples of how to ...
  • 363
3 votes
Accepted

Can I Use TraceIfFalse in deployment?

it strictly depends on your needs and how your validator is supposed to work. traces in general (trace, traceIfFalse, traceIfTrue, traceError) are known to be one of the causes of larger scripts. so ...
  • 621
2 votes
Accepted

How to get the funds available at a script using Plutus?

If you are trying to do this in your offchain code, I would suggest using Plutus.Contract.utxoAt instead. Here is an example of it being used in the gift code.
2 votes

Pioneer Lecture 4 recursion - how is it not infinite?

Simply put, it could recurse infinitely. Haskell doesn't have loops, so this is the equivalent of a while loop or something, where the exit case is the Contract monad throwing an error. If you want to ...
2 votes

Is there documentation on the Prerequisites for Plutus Pioneer code?

I am running the Plutus Pioneer code in a nixos/nix based Docker container and it works a treat. I use the nix-shell as recommended in the pioneer program repo and I only needed to set up the IOHK ...
  • 460

Only top scored, non community-wiki answers of a minimum length are eligible