Skip to content

Instantly share code, notes, and snippets.

@Aviksaikat
Created May 15, 2023 13:27
Show Gist options
  • Save Aviksaikat/41c058e47fa3f78124ba82daf6f70c65 to your computer and use it in GitHub Desktop.
Save Aviksaikat/41c058e47fa3f78124ba82daf6f70c65 to your computer and use it in GitHub Desktop.
convert an integer to bytes32
from brownie import web3
value = 1
# * convert it to bytes32
value = value.to_bytes(32, byteorder="big")
>>> value
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'
>>> value.hex()
'0000000000000000000000000000000000000000000000000000000000000001'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment