question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rename ScriptHash to Hash160 and add Hash256 to align neow3j with other Neo projects

See original GitHub issue

Other Neo SDKs and devpacks use the UInt160 type to represent script hashes, i.e., hashes produced with RIPEMD, and UInt256 for hashes produced from SHA-256. Neow3j uses the ScriptHash class for UInt160 and does not have any type for UInt256.

We should adapt neow3j to use UInt160 instead of ScriptHash and add UInt256.

Update after discussion (see below): The class ScriptHash will be renamed to Hash160 and a new class Hash256 will be added.

  • Rename ScriptHash to Hash160
  • Add Hash256

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
csmullercommented, Nov 10, 2020

After an internal discussion we came to the following conclusion.

Using UInt160 and UInt256 is not intuitive to new developers. Hash160 and Hash256 on the other hand are more informative. It becomes clear that the values behind are results of hashing algorithms and that the values are 160 and 256 bits long, respectively. Having specific types like TransactionHash and BlockHash that inherit from Hash256 doesn’t add much value. No other rules would be enforced by such types additionally to the rules enforced by Hash256, i.e. the restriction to 256 bits. We therefore propose to use Hash160 (e.g., for script hashes) and Hash256 (e.g., for block hashes). Hash160 replaces ScriptHash.

This change does not have a high priority but is definitely breaking and needs a bump in the major version number.

2reactions
csmullercommented, Nov 9, 2020

UInt256 is not connected to script hashes in my understanding. Script hashes are hashes of scripts, as the name points out 😉 They are always produces by hasing with sha-256 and then ripmd which produces a 160-bit hash. On the other hand block and transaction hashses, for example, are only hashed with sha-256 and, therefore, produce a 256-bit hash. For them UInt256 is used. Dor the script hashes UInt160 is use.

I think we should rename ScriptHash to UInt160 and add UInt256 as a new type to neow3j using it for example in our io.neow3j.transaction.Transaction class for the getTxId() method.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found