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
Metadata
Release files for pyrevm-contract 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyrevm-contract-0.3.1.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyrevm_contract-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.8 kB
Release files / pyrevm-contract-0.3.1.tar.gz
| Download URL | pyrevm-contract-0.3.1.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fadd7e1efd7a94747431b77ab702786f252b33c5c016b5e18c21f82b8dea3cfd
|
|
BLAKE2b-256 checksum How to use checksums |
094232d86193e42ef9e9545b03f64955c7c55c419948bdcd9b827c82baf5e88b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.5
|
Release files / pyrevm_contract-0.3.1-py3-none-any.whl
| Download URL | pyrevm_contract-0.3.1-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9fcdd415d3b4ae1f962236748946129295ce7add9ed78e64ffb019fa2f3428ca
|
|
BLAKE2b-256 checksum How to use checksums |
c8154526bc9fc59d034a56649983d00fe8194e919ab274a026e4099d084a36f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.5
|