Cardano.Witness

Handling witnesses for Tx building intents.

type Voter
= WithCommitteeHotCred Credential
| WithDrepCred Credential
| WithPoolCred (Bytes CredentialHash)

Voting credentials can either come from a DRep, a stake pool, or Constitutional Committee member.

Helper function to convert a voter to a Gov.Voter.

= WithKey (Bytes CredentialHash)
| WithScript (Bytes CredentialHash) Script

The type of credential to provide.

It can either be a key, typically from a wallet, a native script, or a plutus script.

Helper function to convert a credential witness to an Address.Credential.

type Script
= Native NativeScript
| Plutus PlutusScript

Represents different types of script witnesses.

type alias NativeScript =
{ script : Source NativeScript
, expectedSigners : List (Bytes CredentialHash)
}

Represents a Native script witness.

Expected signatures are not put in the "required_signers" field of the Tx but are still used to estimate fees.

If you expect to sign with all credentials present in the multisig, you can use Dict.values (Cardano.Script.extractSigners script).

Otherwise, just list the credentials you intend to sign with.

type alias PlutusScript =
, redeemerData : TxContext -> Data
, requiredSigners : List (Bytes CredentialHash)
}

Represents a Plutus script witness.

type Source a
= ByValue a
| ByReference OutputReference

Represents different sources for witnesses.

type Error
= InvalidExpectedSigners
{ scriptHash : Bytes CredentialHash }
String
| ScriptHashMismatch
{ expected : Bytes CredentialHash
, witness : Bytes CredentialHash
}
String
| ExtraneousDatum (Source Data) String
| MissingDatum (Bytes DatumHash) String
| DatumHashMismatch
{ expected : Bytes DatumHash
, witness : Bytes DatumHash
}
String
| ReferenceOutputsMissingFromLocalState (List OutputReference)
| MissingReferenceScript OutputReference
| InvalidScriptRef OutputReference (Bytes Script) String

Error type describing all kind of errors that can happen while validating witnesses.

errorToString : Error -> String

Convert an error into a human-readable string.

True if the this is a credential witness for a Plutus script.

mapSource : (a -> b) -> Source a -> Source b

Map a function over a witness source (if by value).

toHex : (a -> Encoder) -> Source a -> String

Encode a witness source into a unique Hex string representation.

sourceToResult : Source a -> Result a OutputReference

Transform a witness source into a Result type.

This isn’t to semantically say it can fail, just to take advantage of all the functions operating on the Result type. In Haskell, we would have converted to Either.

extractRef : Source a -> Maybe OutputReference

Extract the [OutputReference] from a witness source, if passed by reference. Return [Nothing] if passed by value.

RefDict Output
-> Maybe DatumOption
-> Maybe (Source Data)
-> Result Error ()

Check that the datum witness matches the output datum option.

checkScript : RefDict Output -> Bytes CredentialHash -> Script -> Result Error ()

Check the witness of a script.

RefDict Output
-> NativeScript
-> Result Error ()

Check the witness of a native script. Both the script hash and the validity of expected signers.

RefDict Output
-> PlutusScript
-> Result Error ()

Check the validity of a Plutus script witness. Witness sources are checked, script hashes are matched.