Last active
May 17, 2023 10:17
Various ways of getting the keccak256 hash in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from brownie import web3 | |
# but for mutile parameters this is not the correct way. This is the correct way https://gist.github.com/Aviksaikat/cc69acb525695e44db340d64e9889f5e | |
print(web3.soliditySha3(["uint8"], [0]).hex()) | |
print(web3.solidityKeccak(["uint8"], [0]).hex()) | |
print(web3.keccak(0).hex()) | |
# using ape | |
from ape import networks | |
web3 = networks.provider._web3 | |
print(web3.solidity_keccak(["uint8"], [0]).hex()) | |
print(web3.keccak(0).hex()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated for
ape
& also for multiple parameter check out this gist https://gist.github.com/Aviksaikat/cc69acb525695e44db340d64e9889f5e