Skip to main content

ScriptContext

The ScriptContext is a builtin namepspace containing all information related to signed Cardano transaction being validated.

ScriptContext will commonly be used to import tx:

import { tx } from Scriptcontext

get_current_input

A function that returns the current UTXO being spent as a TxInput.

Can only be called during spending validations, and throws an error otherwise.

import { get_current_input } from ScriptContext

...

get_current_input() -> TxInput

get_spending_purpose_output_id

A function that returns the TxOutputId of the current UTXO being spent.

Can only be called during spending validations, and throws an error otherwise.

import { get_spending_purpose_output_id } from ScriptContext

...

get_spending_purpose_output_id() -> TxOutputId

get_cont_outputs

A function that returns the outputs sent back to the current validator script.

Can only be called during spending validations, and throws an error otherwise.

import { get_cont_outputs } from ScriptContext

...

get_cont_outputs() -> []TxOutput

get_current_validator_hash

A function that returns the ValidatorHash of the current script.

Can only be called during spending validations, and throws an error otherwise.

import { get_current_validator_hash } from ScriptContext

...

get_current_validator_hash() -> ValidatorHash

get_current_minting_policy_hash

A function that returns the MintingPolicyHash of the minting policy being evaluated.

Can only be called during minting validations, and throws an error otherwise.

import { get_current_minting_policy_hash } from ScriptContext

...

get_current_minting_policy_hash() -> MintingPolicyHash

get_staking_purpose

A function that returns the current StakingPurpose (Rewarding or Certifying).

Can only be called during staking validations, and throws an error otherwise.

import { get_staking_purpose } from ScriptContext

...

get_staking_purpose() -> StakingPurpose

purpose

The current validation purpose.

import { purpose } from ScriptContext

...

purpose -> ScriptPurpose

tx

Get the current Tx data structure.

import { tx } from ScriptContext

...

tx -> Tx