Skip to content

Instantly share code, notes, and snippets.

@Aviksaikat
Created May 16, 2023 23:51
Show Gist options
  • Save Aviksaikat/cfd09cfc16c429dc4f6326d9347c6c56 to your computer and use it in GitHub Desktop.
Save Aviksaikat/cfd09cfc16c429dc4f6326d9347c6c56 to your computer and use it in GitHub Desktop.
How to do `abi.encodeWithSignature` in python
value = Contract.methodName.encode_input()
print(value)
# wrong
# >> '0xa7a7e4e8'
value = Contract.methodName.encode_input()
# add padding to make it 32 bytes
value = value + "0" * (66 - len(value))
print(value)
# correct
#>> '0xa7a7e4e800000000000000000000000000000000000000000000000000000000'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment