Skip to main content

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)

Source distribution for pyrevm-contract 0.3.1
File Size Uploaded
pyrevm-contract-0.3.1.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyrevm-contract 0.3.1
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

1 release file

0.2.0

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

2 release files

0.1.6

2 release files

0.1.5

1 release file

0.1.4

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page