4

In Plutus, Ledger.Constraints has the following Constraints

mustPayToOtherScript, mustPayToPubKey, mustPayToTheScript,

Is there a similar constraint that can used send funds to a payment address in Daedalus or Yoroi wallets, using Plutus? None of the above there constraints deal with payment addresses the way I understand.

1
  • Should one of the answers be marked as accepted?
    – gRebel
    Commented Apr 28, 2022 at 5:31

2 Answers 2

1

To pay to a full address, you can use mustPayToPubKeyAddress pkh skh v

This is not using the bech32 format though. You still need to decode the bech32 string into the public key hash (pkh) and the stake key hash (skh).

0

It's the mustPayToPubKey fn. It takes the hash of the public key of the wallet. From the validator fn:

let tx = mustPayToPubKey (ppRecipient pp) $ lovelaceValueOf $ ppLovelace pp 

where pp is constructed in the off chain code like this (note the use of pubKeyHash fn):

payTrace :: Integer -> Integer -> EmulatorTrace ()
payTrace x y = do
    h1 <- activateContractWallet (Wallet 1) payContractOfficialSolution
    s0 <- Emulator.waitNSlots 1
    Extras.logInfo $ "reached slot " ++ show s0
    callEndpoint @"pay" h1 $ PayParams
        { ppRecipient = pubKeyHash $ walletPubKey $ Wallet 2
          , ppLovelace      = x
        }
...

This is all from the week04 of the Plutus Pioneer Program iteration 1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.