Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bhatt-deep opened this issue Apr 18, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@bhatt-deep
Copy link
Contributor

bhatt-deep commented Apr 18, 2023

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
@cffls cffls added the bug Something isn't working label Apr 19, 2023
@cffls
Copy link
Collaborator

cffls commented Apr 19, 2023

Looks like blockfrost returns inconsistent script cbor. Sometimes we need to reload it through cbor, but sometime not. This PR fixes it: #218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants