(?, ?) is a Python library I’ve made for personal use; now open source.

It let’s you access forge and cast CLIs from Python scripts and correctly handles the output, with some handy features:


Run any command as if you were using the terminal

# Get VB's address
vitalik = foundry_cli('cast resolve-name "vitalik.eth"')

Use in scripts with composable commands

# Calculate VB's $$$ in stables
for coin in stables:
    sum += foundry_cli(f'cast call {coin} "balanceOf(address)(uint256)" {vitalik}')

Access anything, effortlessly

# Get the hash of the 100th transaction from the latest block
foundry_cli('cast block latest').get("transactions")[100]

Automatic output conversion: str, int, Decimal, dict, JSON (str)

  • Whole numbers will be returned as int and decimal as Decimal, for max precision
  • Multiple values, such as deployer, deployedTo, transactionHash will be returned as dict
  • JSON will be converted to dict for superior UX


  • forge (forge create only)
  • cast (100% 837209b)


Clone repository

git clone

Install libraray

pip install dist/foundrycli-0.1.0-py3-none-any.whl


Import foundry_cli in your script

from foundrycli import foundry_cli

Pass command and force_string_output (if you want to disable conversion)

balance = foundry_cli('cast balance "vitalik.eth"')

Compose commands instead of hardcoding them

ens_name = "vitalik.eth"
balance = foundry_cli(f'cast balance {ens_name}')


View Github