Skip to main content

PScriptPurpose

It is the second field of the PScriptContext structure.

It tells us what specific role or purpose the script is used for based on the constructor. It passes some useful information that would be hard to access otherwise.

Definition:

export const PScriptPurpose = pstruct({
Minting: { currencySym: PCurrencySymbol.type },
Spending: { utxoRef: PTxOutRef.type },
Rewarding: { stakeCredential: PStakingCredential.type },
Certifying: { dCert: PDCert.type }
});

Minting

Represents the purpose of the script when it is involved in minting/burning new tokens.

currencySym

Currency symbol for identifying the tokens being minted

type: PCurrencySymbol

Spending

Represents the purpose of the script when it is used for spending funds from a specific UTXO (Unspent Transaction Output).

utxoRef

References the UTXO being spent

type: PTxOutRef.type

Rewarding

Represents the purpose of the script when it is involved in rewarding stakeholders.

stakeCredential

Staking credential (or address) to be rewarded. This could involve distributing rewards based on staking participation.

type: PStakingCredential.type

Certifying

Represents the purpose of the script when it is used for certifying delegation certificates.

dCert

Delegation certificate information

type: PDCert.type