Contract wrapper for pyrevm
Project description
pyrevm_contract
Minimal Brownie like contract wrapper for Pyrevm
pip install pyrevm_contract
init revm
from pyrevm_contract import Revm, Contract
revm = Revm("https://eth.llamarpc.com", block_number=5282490) # revm singleton; sets backend for all contracts
caller = "0x00000000000000000000000000000000000021E8"
weth_addr = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
init contract via json file object
weth_abi_path = ...
with open(weth_abi_path) as f:
abi = json.load(f)
weth = Contract(weth_addr, abi)
init contract via json abi file path
weth_abi_path = ...
weth = Contract(weth_addr, abi_file_path=weth_abi_path)
create contract abi manually
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),
)
call contract
revm.set_balance(caller, 100) # revm cheatcode; sets ether balance of acct
weth.balanceOf(caller) # -> 0
weth["0xd0e30db0"](value=100, caller=caller) # call via selector
weth.balanceOf(caller) # -> 100
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyrevm-contract-0.3.1.tar.gz
(6.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyrevm-contract-0.3.1.tar.gz.
File metadata
- Download URL: pyrevm-contract-0.3.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fadd7e1efd7a94747431b77ab702786f252b33c5c016b5e18c21f82b8dea3cfd
|
|
| MD5 |
7dd679c266b90be4b12287fba499c93e
|
|
| BLAKE2b-256 |
094232d86193e42ef9e9545b03f64955c7c55c419948bdcd9b827c82baf5e88b
|
File details
Details for the file pyrevm_contract-0.3.1-py3-none-any.whl.
File metadata
- Download URL: pyrevm_contract-0.3.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fcdd415d3b4ae1f962236748946129295ce7add9ed78e64ffb019fa2f3428ca
|
|
| MD5 |
350b097627c95a2a55c5eba392d4cc8d
|
|
| BLAKE2b-256 |
c8154526bc9fc59d034a56649983d00fe8194e919ab274a026e4099d084a36f6
|