Module opshin.ledger.api_v2

The PlutusV2 ledger API. All classes involved in defining the ScriptContext passed by the node.

Expand source code
"""
The PlutusV2 ledger API.
All classes involved in defining the ScriptContext passed by the node.
"""

from dataclasses import dataclass
from typing import Dict, List, Union

from pycardano import Datum as Anything, PlutusData


# Plutus V2
@dataclass(unsafe_hash=True)
class TxId(PlutusData):
    """
    A transaction id, a 64 bytes long hash of the transaction body (also called transaction hash).

    Example value: TxId(bytes.fromhex("842a4d37b036da6ab3c04331240e67d81746beb44f23ad79703e026705361956"))
    """

    CONSTR_ID = 0

    tx_id: bytes


@dataclass(unsafe_hash=True)
class TrueData(PlutusData):
    """
    A Datum that represents True in Haskell implementations.
    It is thus used as an encoding for True in the ScriptContext.

    Example value: TrueData()
    """

    CONSTR_ID = 0


@dataclass(unsafe_hash=True)
class FalseData(PlutusData):
    """
    A Datum that represents False in Haskell implementations.
    It is thus used as an encoding for False in the ScriptContext.

    Example value: FalseData()
    """

    CONSTR_ID = 1


# A Datum that represents a boolean value in Haskell implementations.
# It is thus used as an encoding for booleans in the ScriptContext.
#
# Example value: TrueData()
BoolData = Union[TrueData, FalseData]


@dataclass(unsafe_hash=True)
class TxOutRef(PlutusData):
    """
    A reference to a transaction output (hash/id + index)
    """

    CONSTR_ID = 0

    id: TxId
    idx: int


# A public key hash, used to identify signatures provided by a wallet
PubKeyHash = bytes


@dataclass(unsafe_hash=True)
class PubKeyCredential(PlutusData):
    """
    Part of an address that is authenticated by a public key hash

    Example value: PubKeyCredential(bytes.fromhex("c06ddaad12fc4ded18e56feac72957c1aa75fce6096b40e63ec88274"))
    """

    CONSTR_ID = 0
    credential_hash: PubKeyHash


# A validator hash, used to identify signatures provided by a smart contract
ValidatorHash = bytes


@dataclass(unsafe_hash=True)
class ScriptCredential(PlutusData):
    """
    Part of an address that is authenticated by a smart cotnract

    Example value: ScriptCredential(bytes.fromhex("c06ddaad12fc4ded18e56feac72957c1aa75fce6096b40e63ec88274"))
    """

    CONSTR_ID = 1
    credential_hash: ValidatorHash


# A credential, either smart contract or public key hash
Credential = Union[PubKeyCredential, ScriptCredential]


@dataclass(unsafe_hash=True)
class StakingHash(PlutusData):
    """
    Indicates that the stake of this address is controlled by the associated credential
    """

    CONSTR_ID = 0
    value: Credential


@dataclass(unsafe_hash=True)
class StakingPtr(PlutusData):
    """
    Indicates that the stake of this address is controlled by the associated pointer.

    In an address, a chain pointer refers to a point of the chain containing a stake key registration certificate.
    A point is identified by the 3 coordinates in this object.
    """

    CONSTR_ID = 1
    # an absolute slot number
    slot_no: int
    # a transaction index (within that slot)
    tx_index: int
    # a (delegation) certificate index (within that transaction)
    cert_index: int


# Part of an address that controls who can delegate the stake associated with an address
StakingCredential = Union[StakingHash, StakingPtr]


@dataclass(unsafe_hash=True)
class NoStakingCredential(PlutusData):
    """
    Indicates that this address has no staking credentials.
    Its funds can not be delegated.
    """

    CONSTR_ID = 1


@dataclass(unsafe_hash=True)
class SomeStakingCredential(PlutusData):
    """
    Indicates that this address has staking credentials.
    Its funds can be delegated by the credentialed user.
    """

    CONSTR_ID = 0
    staking_credential: StakingCredential


@dataclass(unsafe_hash=True)
class Address(PlutusData):
    """
    A Shelley address, consisting of a payment and staking credential
    """

    CONSTR_ID = 0

    payment_credential: Credential
    staking_credential: Union[NoStakingCredential, SomeStakingCredential]


# The policy Id of a token
PolicyId = bytes

# The name of a token in bytes (not textual representation!)
TokenName = bytes

# The Plutus representation of amounts of tokens being spent, sent or minted
# It is a two-layered dictionary that stores for each policy id and token name
# the amount of the token that is being sent/minted/burned etc
#
# Lovelace is represented with policy id b"" and token name b""
Value = Dict[PolicyId, Dict[TokenName, int]]

# A hash of a Datum
DatumHash = bytes


@dataclass(unsafe_hash=True)
class SomeDatumHash(PlutusData):
    """
    Indicates that there is a datum associated with this output, which has the given hash.
    """

    CONSTR_ID = 1
    datum_hash: DatumHash


@dataclass(unsafe_hash=True)
class SomeScriptHash(PlutusData):
    """
    Indicates that there is a script associated with this output, which has the given hash.
    """

    CONSTR_ID = 0
    script_hash: DatumHash


# The abstract super type of any object in opshin.
# Use if you don't know what kind of object is being passed or if it doesn't matter.
BuiltinData = Anything


# An abstract type annotation that something is supposed to be used as a redeemer.
Redeemer = BuiltinData


# An abstract type annotation that something is supposed to be used as a datum.
Datum = BuiltinData


@dataclass(unsafe_hash=True)
class NoOutputDatum(PlutusData):
    """
    Indicates that there is no datum associated with an output
    """

    CONSTR_ID = 0


@dataclass(unsafe_hash=True)
class SomeOutputDatumHash(PlutusData):
    """
    Indicates that there is an datum associated with an output, which has the attached hash
    """

    CONSTR_ID = 1
    datum_hash: DatumHash


@dataclass(unsafe_hash=True)
class SomeOutputDatum(PlutusData):
    """
    Indicates that there is an datum associated with an output, which is inlined and equal to the attached datum
    """

    CONSTR_ID = 2
    datum: Datum


# Possible cases of datum association with an output
OutputDatum = Union[NoOutputDatum, SomeOutputDatumHash, SomeOutputDatum]


@dataclass(unsafe_hash=True)
class NoScriptHash(PlutusData):
    """
    Indicates that there is no script associated with an output
    """

    CONSTR_ID = 1


@dataclass(unsafe_hash=True)
class TxOut(PlutusData):
    """
    The plutus representation of an transaction output, consisting of
    - address: address owning this output
    - value: tokens associated with this output
    - datum: datum associated with this output
    - reference_script: reference script associated with this output
    """

    CONSTR_ID = 0

    address: Address
    value: Value
    datum: OutputDatum
    reference_script: Union[NoScriptHash, SomeScriptHash]


@dataclass(unsafe_hash=True)
class TxInInfo(PlutusData):
    """
    The plutus representation of an transaction output, that is consumed by the transaction.
    """

    CONSTR_ID = 0

    out_ref: TxOutRef
    resolved: TxOut


@dataclass(unsafe_hash=True)
class DCertDelegRegKey(PlutusData):
    CONSTR_ID = 0
    value: StakingCredential


@dataclass(unsafe_hash=True)
class DCertDelegDeRegKey(PlutusData):
    CONSTR_ID = 1
    value: StakingCredential


@dataclass(unsafe_hash=True)
class DCertDelegDelegate(PlutusData):
    CONSTR_ID = 2
    delegator: StakingCredential
    delegatee: PubKeyHash


@dataclass(unsafe_hash=True)
class DCertPoolRegister(PlutusData):
    CONSTR_ID = 3
    pool_id: PubKeyHash
    pool_vfr: PubKeyHash


@dataclass(unsafe_hash=True)
class DCertPoolRetire(PlutusData):
    CONSTR_ID = 4
    retirement_certificate: PubKeyHash
    epoch: int


@dataclass(unsafe_hash=True)
class DCertGenesis(PlutusData):
    CONSTR_ID = 5


@dataclass(unsafe_hash=True)
class DCertMir(PlutusData):
    CONSTR_ID = 6


DCert = Union[
    DCertDelegRegKey,
    DCertDelegDeRegKey,
    DCertDelegDelegate,
    DCertPoolRegister,
    DCertPoolRetire,
    DCertGenesis,
    DCertMir,
]


POSIXTime = int


@dataclass(unsafe_hash=True)
class NegInfPOSIXTime(PlutusData):
    """
    Negative infinite POSIX time, used to indicate that there is no lower bound for the execution of this transaction
    """

    CONSTR_ID = 0


@dataclass(unsafe_hash=True)
class FinitePOSIXTime(PlutusData):
    """
    Finite POSIX time, used to indicate that there is a lower or upper bound for the execution of this transaction
    """

    CONSTR_ID = 1
    time: POSIXTime


@dataclass(unsafe_hash=True)
class PosInfPOSIXTime(PlutusData):
    """
    Infinite POSIX time, used to indicate that there is no upper bound for the execution of this transaction
    """

    CONSTR_ID = 2


ExtendedPOSIXTime = Union[NegInfPOSIXTime, FinitePOSIXTime, PosInfPOSIXTime]


@dataclass(unsafe_hash=True)
class UpperBoundPOSIXTime(PlutusData):
    """
    Upper bound for the execution of this transaction
    """

    CONSTR_ID = 0
    limit: ExtendedPOSIXTime
    closed: BoolData


@dataclass(unsafe_hash=True)
class LowerBoundPOSIXTime(PlutusData):
    """
    Lower bound for the execution of this transaction
    """

    CONSTR_ID = 0
    limit: ExtendedPOSIXTime
    closed: BoolData


@dataclass(unsafe_hash=True)
class POSIXTimeRange(PlutusData):
    """
    Time range in which this transaction can be executed
    """

    CONSTR_ID = 0

    lower_bound: LowerBoundPOSIXTime
    upper_bound: UpperBoundPOSIXTime


@dataclass(unsafe_hash=True)
class Minting(PlutusData):
    """
    Script purpose indicating that the given policy id is being minted or burned
    """

    CONSTR_ID = 0
    policy_id: PolicyId


@dataclass(unsafe_hash=True)
class Spending(PlutusData):
    """
    Script purpose indicating that the given transaction output is being spent, which is
    owned by the invoked contract
    """

    CONSTR_ID = 1
    tx_out_ref: TxOutRef


@dataclass(unsafe_hash=True)
class Rewarding(PlutusData):
    CONSTR_ID = 2
    staking_credential: StakingCredential


@dataclass(unsafe_hash=True)
class Certifying(PlutusData):
    CONSTR_ID = 3
    d_cert: DCert


# The reason that this script is being invoked
ScriptPurpose = Union[Minting, Spending, Rewarding, Certifying]


@dataclass(unsafe_hash=True)
class TxInfo(PlutusData):
    """
    A complex agglomeration of everything that could be of interest to the executed script, regarding the transaction
    that invoked the script
    """

    CONSTR_ID = 0
    inputs: List[TxInInfo]
    reference_inputs: List[TxInInfo]
    outputs: List[TxOut]
    fee: Value
    mint: Value
    dcert: List[DCert]
    wdrl: Dict[StakingCredential, int]
    valid_range: POSIXTimeRange
    signatories: List[PubKeyHash]
    redeemers: Dict[ScriptPurpose, Redeemer]
    data: Dict[DatumHash, Datum]
    id: TxId


@dataclass(unsafe_hash=True)
class ScriptContext(PlutusData):
    """
    Auxiliary information about the transaction and reason for invocation of the called script.
    """

    CONSTR_ID = 0
    tx_info: TxInfo
    purpose: ScriptPurpose

Classes

class Address (payment_credential: Union[PubKeyCredentialScriptCredential], staking_credential: Union[NoStakingCredentialSomeStakingCredential])

A Shelley address, consisting of a payment and staking credential

Expand source code
@dataclass(unsafe_hash=True)
class Address(PlutusData):
    """
    A Shelley address, consisting of a payment and staking credential
    """

    CONSTR_ID = 0

    payment_credential: Credential
    staking_credential: Union[NoStakingCredential, SomeStakingCredential]

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var payment_credential : Union[PubKeyCredentialScriptCredential]
var staking_credential : Union[NoStakingCredentialSomeStakingCredential]
class Certifying (d_cert: Union[DCertDelegRegKeyDCertDelegDeRegKeyDCertDelegDelegateDCertPoolRegisterDCertPoolRetireDCertGenesisDCertMir])

Certifying(d_cert: Union[opshin.ledger.api_v2.DCertDelegRegKey, opshin.ledger.api_v2.DCertDelegDeRegKey, opshin.ledger.api_v2.DCertDelegDelegate, opshin.ledger.api_v2.DCertPoolRegister, opshin.ledger.api_v2.DCertPoolRetire, opshin.ledger.api_v2.DCertGenesis, opshin.ledger.api_v2.DCertMir])

Expand source code
@dataclass(unsafe_hash=True)
class Certifying(PlutusData):
    CONSTR_ID = 3
    d_cert: DCert

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var d_cert : Union[DCertDelegRegKeyDCertDelegDeRegKeyDCertDelegDelegateDCertPoolRegisterDCertPoolRetireDCertGenesisDCertMir]
class DCertDelegDeRegKey (value: Union[StakingHashStakingPtr])

DCertDelegDeRegKey(value: Union[opshin.ledger.api_v2.StakingHash, opshin.ledger.api_v2.StakingPtr])

Expand source code
@dataclass(unsafe_hash=True)
class DCertDelegDeRegKey(PlutusData):
    CONSTR_ID = 1
    value: StakingCredential

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var value : Union[StakingHashStakingPtr]
class DCertDelegDelegate (delegator: Union[StakingHashStakingPtr], delegatee: bytes)

DCertDelegDelegate(delegator: Union[opshin.ledger.api_v2.StakingHash, opshin.ledger.api_v2.StakingPtr], delegatee: bytes)

Expand source code
@dataclass(unsafe_hash=True)
class DCertDelegDelegate(PlutusData):
    CONSTR_ID = 2
    delegator: StakingCredential
    delegatee: PubKeyHash

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var delegatee : bytes
var delegator : Union[StakingHashStakingPtr]
class DCertDelegRegKey (value: Union[StakingHashStakingPtr])

DCertDelegRegKey(value: Union[opshin.ledger.api_v2.StakingHash, opshin.ledger.api_v2.StakingPtr])

Expand source code
@dataclass(unsafe_hash=True)
class DCertDelegRegKey(PlutusData):
    CONSTR_ID = 0
    value: StakingCredential

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var value : Union[StakingHashStakingPtr]
class DCertGenesis

DCertGenesis()

Expand source code
@dataclass(unsafe_hash=True)
class DCertGenesis(PlutusData):
    CONSTR_ID = 5

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
class DCertMir

DCertMir()

Expand source code
@dataclass(unsafe_hash=True)
class DCertMir(PlutusData):
    CONSTR_ID = 6

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
class DCertPoolRegister (pool_id: bytes, pool_vfr: bytes)

DCertPoolRegister(pool_id: bytes, pool_vfr: bytes)

Expand source code
@dataclass(unsafe_hash=True)
class DCertPoolRegister(PlutusData):
    CONSTR_ID = 3
    pool_id: PubKeyHash
    pool_vfr: PubKeyHash

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var pool_id : bytes
var pool_vfr : bytes
class DCertPoolRetire (retirement_certificate: bytes, epoch: int)

DCertPoolRetire(retirement_certificate: bytes, epoch: int)

Expand source code
@dataclass(unsafe_hash=True)
class DCertPoolRetire(PlutusData):
    CONSTR_ID = 4
    retirement_certificate: PubKeyHash
    epoch: int

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var epoch : int
var retirement_certificate : bytes
class FalseData

A Datum that represents False in Haskell implementations. It is thus used as an encoding for False in the ScriptContext.

Example value: FalseData()

Expand source code
@dataclass(unsafe_hash=True)
class FalseData(PlutusData):
    """
    A Datum that represents False in Haskell implementations.
    It is thus used as an encoding for False in the ScriptContext.

    Example value: FalseData()
    """

    CONSTR_ID = 1

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
class FinitePOSIXTime (time: int)

Finite POSIX time, used to indicate that there is a lower or upper bound for the execution of this transaction

Expand source code
@dataclass(unsafe_hash=True)
class FinitePOSIXTime(PlutusData):
    """
    Finite POSIX time, used to indicate that there is a lower or upper bound for the execution of this transaction
    """

    CONSTR_ID = 1
    time: POSIXTime

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var time : int
class LowerBoundPOSIXTime (limit: Union[NegInfPOSIXTimeFinitePOSIXTimePosInfPOSIXTime], closed: Union[TrueDataFalseData])

Lower bound for the execution of this transaction

Expand source code
@dataclass(unsafe_hash=True)
class LowerBoundPOSIXTime(PlutusData):
    """
    Lower bound for the execution of this transaction
    """

    CONSTR_ID = 0
    limit: ExtendedPOSIXTime
    closed: BoolData

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var closed : Union[TrueDataFalseData]
var limit : Union[NegInfPOSIXTimeFinitePOSIXTimePosInfPOSIXTime]
class Minting (policy_id: bytes)

Script purpose indicating that the given policy id is being minted or burned

Expand source code
@dataclass(unsafe_hash=True)
class Minting(PlutusData):
    """
    Script purpose indicating that the given policy id is being minted or burned
    """

    CONSTR_ID = 0
    policy_id: PolicyId

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var policy_id : bytes
class NegInfPOSIXTime

Negative infinite POSIX time, used to indicate that there is no lower bound for the execution of this transaction

Expand source code
@dataclass(unsafe_hash=True)
class NegInfPOSIXTime(PlutusData):
    """
    Negative infinite POSIX time, used to indicate that there is no lower bound for the execution of this transaction
    """

    CONSTR_ID = 0

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
class NoOutputDatum

Indicates that there is no datum associated with an output

Expand source code
@dataclass(unsafe_hash=True)
class NoOutputDatum(PlutusData):
    """
    Indicates that there is no datum associated with an output
    """

    CONSTR_ID = 0

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
class NoScriptHash

Indicates that there is no script associated with an output

Expand source code
@dataclass(unsafe_hash=True)
class NoScriptHash(PlutusData):
    """
    Indicates that there is no script associated with an output
    """

    CONSTR_ID = 1

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
class NoStakingCredential

Indicates that this address has no staking credentials. Its funds can not be delegated.

Expand source code
@dataclass(unsafe_hash=True)
class NoStakingCredential(PlutusData):
    """
    Indicates that this address has no staking credentials.
    Its funds can not be delegated.
    """

    CONSTR_ID = 1

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
class POSIXTimeRange (lower_bound: LowerBoundPOSIXTime, upper_bound: UpperBoundPOSIXTime)

Time range in which this transaction can be executed

Expand source code
@dataclass(unsafe_hash=True)
class POSIXTimeRange(PlutusData):
    """
    Time range in which this transaction can be executed
    """

    CONSTR_ID = 0

    lower_bound: LowerBoundPOSIXTime
    upper_bound: UpperBoundPOSIXTime

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var lower_boundLowerBoundPOSIXTime
var upper_boundUpperBoundPOSIXTime
class PosInfPOSIXTime

Infinite POSIX time, used to indicate that there is no upper bound for the execution of this transaction

Expand source code
@dataclass(unsafe_hash=True)
class PosInfPOSIXTime(PlutusData):
    """
    Infinite POSIX time, used to indicate that there is no upper bound for the execution of this transaction
    """

    CONSTR_ID = 2

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
class PubKeyCredential (credential_hash: bytes)

Part of an address that is authenticated by a public key hash

Example value: PubKeyCredential(bytes.fromhex("c06ddaad12fc4ded18e56feac72957c1aa75fce6096b40e63ec88274"))

Expand source code
@dataclass(unsafe_hash=True)
class PubKeyCredential(PlutusData):
    """
    Part of an address that is authenticated by a public key hash

    Example value: PubKeyCredential(bytes.fromhex("c06ddaad12fc4ded18e56feac72957c1aa75fce6096b40e63ec88274"))
    """

    CONSTR_ID = 0
    credential_hash: PubKeyHash

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var credential_hash : bytes
class Rewarding (staking_credential: Union[StakingHashStakingPtr])

Rewarding(staking_credential: Union[opshin.ledger.api_v2.StakingHash, opshin.ledger.api_v2.StakingPtr])

Expand source code
@dataclass(unsafe_hash=True)
class Rewarding(PlutusData):
    CONSTR_ID = 2
    staking_credential: StakingCredential

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var staking_credential : Union[StakingHashStakingPtr]
class ScriptContext (tx_info: TxInfo, purpose: Union[MintingSpendingRewardingCertifying])

Auxiliary information about the transaction and reason for invocation of the called script.

Expand source code
@dataclass(unsafe_hash=True)
class ScriptContext(PlutusData):
    """
    Auxiliary information about the transaction and reason for invocation of the called script.
    """

    CONSTR_ID = 0
    tx_info: TxInfo
    purpose: ScriptPurpose

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var purpose : Union[MintingSpendingRewardingCertifying]
var tx_infoTxInfo
class ScriptCredential (credential_hash: bytes)

Part of an address that is authenticated by a smart cotnract

Example value: ScriptCredential(bytes.fromhex("c06ddaad12fc4ded18e56feac72957c1aa75fce6096b40e63ec88274"))

Expand source code
@dataclass(unsafe_hash=True)
class ScriptCredential(PlutusData):
    """
    Part of an address that is authenticated by a smart cotnract

    Example value: ScriptCredential(bytes.fromhex("c06ddaad12fc4ded18e56feac72957c1aa75fce6096b40e63ec88274"))
    """

    CONSTR_ID = 1
    credential_hash: ValidatorHash

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var credential_hash : bytes
class SomeDatumHash (datum_hash: bytes)

Indicates that there is a datum associated with this output, which has the given hash.

Expand source code
@dataclass(unsafe_hash=True)
class SomeDatumHash(PlutusData):
    """
    Indicates that there is a datum associated with this output, which has the given hash.
    """

    CONSTR_ID = 1
    datum_hash: DatumHash

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var datum_hash : bytes
class SomeOutputDatum (datum: Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData])

Indicates that there is an datum associated with an output, which is inlined and equal to the attached datum

Expand source code
@dataclass(unsafe_hash=True)
class SomeOutputDatum(PlutusData):
    """
    Indicates that there is an datum associated with an output, which is inlined and equal to the attached datum
    """

    CONSTR_ID = 2
    datum: Datum

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var datum : Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]
class SomeOutputDatumHash (datum_hash: bytes)

Indicates that there is an datum associated with an output, which has the attached hash

Expand source code
@dataclass(unsafe_hash=True)
class SomeOutputDatumHash(PlutusData):
    """
    Indicates that there is an datum associated with an output, which has the attached hash
    """

    CONSTR_ID = 1
    datum_hash: DatumHash

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var datum_hash : bytes
class SomeScriptHash (script_hash: bytes)

Indicates that there is a script associated with this output, which has the given hash.

Expand source code
@dataclass(unsafe_hash=True)
class SomeScriptHash(PlutusData):
    """
    Indicates that there is a script associated with this output, which has the given hash.
    """

    CONSTR_ID = 0
    script_hash: DatumHash

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var script_hash : bytes
class SomeStakingCredential (staking_credential: Union[StakingHashStakingPtr])

Indicates that this address has staking credentials. Its funds can be delegated by the credentialed user.

Expand source code
@dataclass(unsafe_hash=True)
class SomeStakingCredential(PlutusData):
    """
    Indicates that this address has staking credentials.
    Its funds can be delegated by the credentialed user.
    """

    CONSTR_ID = 0
    staking_credential: StakingCredential

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var staking_credential : Union[StakingHashStakingPtr]
class Spending (tx_out_ref: TxOutRef)

Script purpose indicating that the given transaction output is being spent, which is owned by the invoked contract

Expand source code
@dataclass(unsafe_hash=True)
class Spending(PlutusData):
    """
    Script purpose indicating that the given transaction output is being spent, which is
    owned by the invoked contract
    """

    CONSTR_ID = 1
    tx_out_ref: TxOutRef

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var tx_out_refTxOutRef
class StakingHash (value: Union[PubKeyCredentialScriptCredential])

Indicates that the stake of this address is controlled by the associated credential

Expand source code
@dataclass(unsafe_hash=True)
class StakingHash(PlutusData):
    """
    Indicates that the stake of this address is controlled by the associated credential
    """

    CONSTR_ID = 0
    value: Credential

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var value : Union[PubKeyCredentialScriptCredential]
class StakingPtr (slot_no: int, tx_index: int, cert_index: int)

Indicates that the stake of this address is controlled by the associated pointer.

In an address, a chain pointer refers to a point of the chain containing a stake key registration certificate. A point is identified by the 3 coordinates in this object.

Expand source code
@dataclass(unsafe_hash=True)
class StakingPtr(PlutusData):
    """
    Indicates that the stake of this address is controlled by the associated pointer.

    In an address, a chain pointer refers to a point of the chain containing a stake key registration certificate.
    A point is identified by the 3 coordinates in this object.
    """

    CONSTR_ID = 1
    # an absolute slot number
    slot_no: int
    # a transaction index (within that slot)
    tx_index: int
    # a (delegation) certificate index (within that transaction)
    cert_index: int

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var cert_index : int
var slot_no : int
var tx_index : int
class TrueData

A Datum that represents True in Haskell implementations. It is thus used as an encoding for True in the ScriptContext.

Example value: TrueData()

Expand source code
@dataclass(unsafe_hash=True)
class TrueData(PlutusData):
    """
    A Datum that represents True in Haskell implementations.
    It is thus used as an encoding for True in the ScriptContext.

    Example value: TrueData()
    """

    CONSTR_ID = 0

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
class TxId (tx_id: bytes)

A transaction id, a 64 bytes long hash of the transaction body (also called transaction hash).

Example value: TxId(bytes.fromhex("842a4d37b036da6ab3c04331240e67d81746beb44f23ad79703e026705361956"))

Expand source code
@dataclass(unsafe_hash=True)
class TxId(PlutusData):
    """
    A transaction id, a 64 bytes long hash of the transaction body (also called transaction hash).

    Example value: TxId(bytes.fromhex("842a4d37b036da6ab3c04331240e67d81746beb44f23ad79703e026705361956"))
    """

    CONSTR_ID = 0

    tx_id: bytes

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var tx_id : bytes
class TxInInfo (out_ref: TxOutRef, resolved: TxOut)

The plutus representation of an transaction output, that is consumed by the transaction.

Expand source code
@dataclass(unsafe_hash=True)
class TxInInfo(PlutusData):
    """
    The plutus representation of an transaction output, that is consumed by the transaction.
    """

    CONSTR_ID = 0

    out_ref: TxOutRef
    resolved: TxOut

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var out_refTxOutRef
var resolvedTxOut
class TxInfo (inputs: List[TxInInfo], reference_inputs: List[TxInInfo], outputs: List[TxOut], fee: Dict[bytes, Dict[bytes, int]], mint: Dict[bytes, Dict[bytes, int]], dcert: List[Union[DCertDelegRegKeyDCertDelegDeRegKeyDCertDelegDelegateDCertPoolRegisterDCertPoolRetireDCertGenesisDCertMir]], wdrl: Dict[Union[StakingHashStakingPtr], int], valid_range: POSIXTimeRange, signatories: List[bytes], redeemers: Dict[Union[MintingSpendingRewardingCertifying], Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]], data: Dict[bytes, Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]], id: TxId)

A complex agglomeration of everything that could be of interest to the executed script, regarding the transaction that invoked the script

Expand source code
@dataclass(unsafe_hash=True)
class TxInfo(PlutusData):
    """
    A complex agglomeration of everything that could be of interest to the executed script, regarding the transaction
    that invoked the script
    """

    CONSTR_ID = 0
    inputs: List[TxInInfo]
    reference_inputs: List[TxInInfo]
    outputs: List[TxOut]
    fee: Value
    mint: Value
    dcert: List[DCert]
    wdrl: Dict[StakingCredential, int]
    valid_range: POSIXTimeRange
    signatories: List[PubKeyHash]
    redeemers: Dict[ScriptPurpose, Redeemer]
    data: Dict[DatumHash, Datum]
    id: TxId

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var data : Dict[bytes, Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]
var dcert : List[Union[DCertDelegRegKeyDCertDelegDeRegKeyDCertDelegDelegateDCertPoolRegisterDCertPoolRetireDCertGenesisDCertMir]]
var fee : Dict[bytes, Dict[bytes, int]]
var idTxId
var inputs : List[TxInInfo]
var mint : Dict[bytes, Dict[bytes, int]]
var outputs : List[TxOut]
var redeemers : Dict[Union[MintingSpendingRewardingCertifying], Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]
var reference_inputs : List[TxInInfo]
var signatories : List[bytes]
var valid_rangePOSIXTimeRange
var wdrl : Dict[Union[StakingHashStakingPtr], int]
class TxOut (address: Address, value: Dict[bytes, Dict[bytes, int]], datum: Union[NoOutputDatumSomeOutputDatumHashSomeOutputDatum], reference_script: Union[NoScriptHashSomeScriptHash])

The plutus representation of an transaction output, consisting of - address: address owning this output - value: tokens associated with this output - datum: datum associated with this output - reference_script: reference script associated with this output

Expand source code
@dataclass(unsafe_hash=True)
class TxOut(PlutusData):
    """
    The plutus representation of an transaction output, consisting of
    - address: address owning this output
    - value: tokens associated with this output
    - datum: datum associated with this output
    - reference_script: reference script associated with this output
    """

    CONSTR_ID = 0

    address: Address
    value: Value
    datum: OutputDatum
    reference_script: Union[NoScriptHash, SomeScriptHash]

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var addressAddress
var datum : Union[NoOutputDatumSomeOutputDatumHashSomeOutputDatum]
var reference_script : Union[NoScriptHashSomeScriptHash]
var value : Dict[bytes, Dict[bytes, int]]
class TxOutRef (id: TxId, idx: int)

A reference to a transaction output (hash/id + index)

Expand source code
@dataclass(unsafe_hash=True)
class TxOutRef(PlutusData):
    """
    A reference to a transaction output (hash/id + index)
    """

    CONSTR_ID = 0

    id: TxId
    idx: int

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var idTxId
var idx : int
class UpperBoundPOSIXTime (limit: Union[NegInfPOSIXTimeFinitePOSIXTimePosInfPOSIXTime], closed: Union[TrueDataFalseData])

Upper bound for the execution of this transaction

Expand source code
@dataclass(unsafe_hash=True)
class UpperBoundPOSIXTime(PlutusData):
    """
    Upper bound for the execution of this transaction
    """

    CONSTR_ID = 0
    limit: ExtendedPOSIXTime
    closed: BoolData

Ancestors

  • pycardano.plutus.PlutusData
  • pycardano.serialization.ArrayCBORSerializable
  • pycardano.serialization.CBORSerializable

Class variables

var CONSTR_ID
var closed : Union[TrueDataFalseData]
var limit : Union[NegInfPOSIXTimeFinitePOSIXTimePosInfPOSIXTime]