ScriptPubkey

class cometa.scripts.native_scripts.script_pubkey.ScriptPubkey(ptr)[source]

Bases: object

Represents a public key script (signature requirement).

This script evaluates to true if the transaction includes a valid key witness where the witness verification key hashes to the given hash. In other words, this checks that the transaction is signed by a particular key, identified by its verification key hash.

__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

ScriptPubkey

__exit__(exc_type, exc_val, exc_tb)[source]
Return type:

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod new(key_hash)[source]

Creates a new public key script.

Parameters:

key_hash (bytes) – The 28-byte Blake2b hash of the verification key.

Returns:

A new ScriptPubkey instance.

Raises:

CardanoError – If creation fails.

Return type:

ScriptPubkey

classmethod from_cbor(reader)[source]

Deserializes a ScriptPubkey from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the script data.

Returns:

A new ScriptPubkey deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

ScriptPubkey

to_cbor(writer)[source]

Serializes the script to CBOR format.

Parameters:

writer (CborWriter) – A CborWriter to write the serialized data to.

Raises:

CardanoError – If serialization fails.

Return type:

None

property key_hash: bytes

The verification key hash that must sign the transaction.

Returns:

The 28-byte Blake2b hash.

property hash: bytes

The hash of this native script.

Returns:

The 28-byte Blake2b hash.

__eq__(other)[source]

Checks equality with another ScriptPubkey.

Parameters:

other (object)

Return type:

bool

__hash__ = None