Rename ScriptHash to Hash160 and add Hash256 to align neow3j with other Neo projects
See original GitHub issueOther 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
toHash160
- Add
Hash256
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After an internal discussion we came to the following conclusion.
Using
UInt160
andUInt256
is not intuitive to new developers.Hash160
andHash256
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 likeTransactionHash
andBlockHash
that inherit fromHash256
doesn’t add much value. No other rules would be enforced by such types additionally to the rules enforced byHash256
, i.e. the restriction to 256 bits. We therefore propose to useHash160
(e.g., for script hashes) andHash256
(e.g., for block hashes).Hash160
replacesScriptHash
.This change does not have a high priority but is definitely breaking and needs a bump in the major version number.
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 themUInt256
is used. Dor the script hashesUInt160
is use.I think we should rename
ScriptHash
toUInt160
and addUInt256
as a new type to neow3j using it for example in ourio.neow3j.transaction.Transaction
class for thegetTxId()
method.