0

Is the line scriptOutputsAt ownHash equivalent to pubKeyOutputsAt scrptAddress?

More importantly, is (valueLockedBy (scriptContextInfoTx ctx) ownHash) just the sum of the outputs at the script address? IE is it the same as

let values = pubKeyOutputsAt scptAddress (scriptContextInfoTx ctx) in fold values

1 Answer 1

0

Looking at source code of scriptOutputsAt, pubKeyOutputsAt and valueLockedBy I think, that (correct me if I wrong):

  1. One important think to note right away, is that pubKeyOutputsAt requires PubKeyHash as first argument, so pubKeyOutputsAt scptAddress ... won't type check, if script hash used as scptAddress (otherwise - naming is a bit misleading =) ). Script hash defines script address, and public key, which defines public key hash, used to derive a Cardano wallet address.
  2. scriptOutputsAt ownHash is not equivalent to pubKeyOutputsAt pubKeyHash (note: pubKeyHashs for pubKeyOutputsAt, not scptAddress). pubKeyOutputsAt is values paid to a public key address by a pending transaction (when/if transaction succeeds). scriptOutputsAt is basically the same, but for scripts - values paid to a script address (defined by hash) by current transaction. So scriptOutputsAt ownHash will get you Value that will be paid to the current script (the script that does current validation) when transaction succeeds.
  3. valueLockedBy uses scriptOutputsAt under the hood, applying one extra step to accumulate total Value (i.e. go from [(DatumHash, Value)] to just Value summing values from list). So it will give you total Value that will be paid to a script (and locked by that script). So valueLockedBy (scriptContextInfoTx ctx) ownHash is not the total Value of UTxOs that currently locked by the current script, but total Value of UTxOs which will be produced by this transaction and will be locked at the current script when transaction succeeds.
  4. So, (valueLockedBy (scriptContextInfoTx ctx) ownHash) and fold $ pubKeyOutputsAt pubKeyHash (scriptContextInfoTx ctx) are not the same in principle, as former uses script hash, and latter - public key hash , giving value for different kinds of addresses.
1
  • Yes in my example scptAddress is the PubKeyHash associated with the script. Sorry if this was misleading. But essentially, in point 4 you are saying that the types of parameters differ, but they both do return the same result correct? Commented Feb 22, 2022 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.