3

In the Plutus Pionner Lectures, Lars instructed us to use txSignedBy in order to ensure that a user signed the transaction. The function tries to find a public key hash in the txInfoSignatories list, if it's able to find, it returns True.

Everything was working in the emulator, but now, when I tried to manually build and sign the transaction with cardano-cli, the transaction doesn't appear to add the public key hash from the user who signed it to txInfoSignatories and the script validation fails. My question is: how do I add the user pubkeyhash to txInfoSignatories with cardano-cli? No information regarding the signature appears when I execute cardano-cli transaction build -- help

2 Answers 2

3

------ UPDATE------

Since version 1.31 of cardano-cli, there is the following option to sign the transaction when it is built, so you can avoid that error from the script:

--required-signer FILE   Input filepath of the signing key (zero or more)
                         whose signature is required.

-----------------------

It's related to this bug: Cli to pass required signer (reqSignerHashes) to plutus script for txInfoSignatories

In a near future, there will be a --required-signer option in cardano-cli

As a workaround try to combine toPubKeyHash and txOutAddress function to get the PubKeyHash from any output.

info :: TxInfo
info = scriptContextTxInfo ctx

txOuts :: [TxOut]
txOuts = txInfoOutputs info

outPubKeyHash :: Maybe PubKeyHash
outPubKeyHash = toPubKeyHash $ txOutAddress $ head txOuts
1

@georgeos answer was correct, but from node version 1.32 there is

--required-signer-hash HASH
                           Hash of the verification key (zero or more) whose
                           signature is required.

(so you don't need to know users signing key, just pass the PubKeyHash)

Your Answer

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

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