Skip to content

Instantly share code, notes, and snippets.

@Aviksaikat
Last active May 17, 2023 10:17
Various ways of getting the keccak256 hash in python
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())
@Aviksaikat
Copy link
Author

updated for ape & also for multiple parameter check out this gist https://gist.github.com/Aviksaikat/cc69acb525695e44db340d64e9889f5e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment