Contract wrapper for pyrevm
pip install pyrevm-contract
from pyrevm_contract import Revm, Contract
revm = Revm("https://eth.llamarpc.com", block_number="latest") # revm singleton; sets backend for all contracts
caller = "0x00000000000000000000000000000000000021E8"
weth_addr = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
weth = Contract(weth_addr, abi_file_path="weth.json") # assuming a `weth.json` abi file
revm.set_balance(caller, 100) # revm cheatcode; sets ether balance of acct
weth.balanceOf(caller) # -> 0
weth.deposit(value=100, caller=caller) # provide tx level data with kwargs
weth.balanceOf(caller) # -> 100
weth_abi_path = ...
with open(weth_abi_path) as f:
abi = json.load(f)
weth = Contract(weth_addr, abi)
from pyrevm_contract import ABIFunction, ContractABI
funcs = [
ABIFunction(
name="balanceOf",
inputs=["address"],
outputs=["uint256"],
constant=True,
payable=False,
),
ABIFunction(
selector="0xd0e30db0" # support for selector based funcs
inputs=[],
outputs=[],
constant=False,
payable=True
)
]
weth = Contract(
weth_addr,
contract_abi=ContractABI(funcs),
)
coming soon