Skip to content

Mismatch between returned script and provided script hash in mainnet with BlockfrostContext #217

Closed
@bhatt-deep

Description

@bhatt-deep

Describe the bug
I attempted to retrieve a script using the BlockfrostContext class's _get_script() method by providing a script hash in the mainnet. However, the returned script did not match the provided script hash.

After making the following modification, the method returned the expected output:

elif script_type == "plutusV2":
            return PlutusV2Script(cbor2.loads(bytes.fromhex(self.api.script_cbor(script_hash).cbor)))

To Reproduce
try with this script hash on mainnet. "1a7c64521bd1849e693730558db5bc3d9c514f96eceb004471b5fa49"

def get_plutus_script(context: BlockfrostContext, scripthash: ScriptHash) -> PlutusV2Script:
    """function to get plutus script and verify it's script hash"""
    plutus_script = context._get_script(str(scripthash))
    if plutus_script_hash(plutus_script) == scripthash:
        return plutus_script
    else:
        print("script hash mismatch")

Expected behavior
The _get_script() method should return the correct script, which can be verified using the plutus_script_hash() method.

Environment and software version (please complete the following information):

  • PyCardano Version: 0.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions