Skip to main content

PScriptContext

info

The modifications in PScriptContext from V2 version are highlighted.

Type that provides the context of a script execution. This includes details about the transaction and the purpose of the script within that transaction.

The Script Context is probably the most important piece of data your script receives. That is because this data is passed directly by the cardano node during the contract evaluation; hence it can always be trusted.

definition:

export const PScriptContext = pstruct({
PScriptContext: {
tx: PTxInfo.type,
redeemer: data,
purpose: PScriptInfo.type
}
});

We see it has a single constructor that includes 3 fields:

tx

Information about the transaction in which the script is being executed

type: PTxInfo.type

redeemer

Redeemer data that represents the inputs/parameters used for script execution

type: data

purpose

Purpose of the script being executed

type: PScriptInfo.type