Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

ZeroEkkusu/foundrycli.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

foundrycli.py (🔥, 🐍)

foundrycli.py is a Python library I've made for personal use; now open source.

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

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')["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

Coverage

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

Instructions

Clone repository

git clone https://github.com/ZeroEkkusu/foundrycli.py

Install library

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

Usage

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}')

About

Use `forge` and `cast` commands in Python scripts

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages