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

Overview

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}')
You might also like...
A Curated Collection of Awesome Python Scripts
A Curated Collection of Awesome Python Scripts

A Curated Collection of Awesome Python Scripts that will make you go wow. This repository will help you in getting those green squares. Hop in and enjoy the journey of open source. 🚀

A simple python script to convert Rubber Ducky payloads into AutoHotKey scripts

AHKDuckyReplacer A simple python script to convert Rubber Ducky payloads into AutoHotKey scripts. I have also added a sample payload for testing. I wi

A collection of daily usage utility scripts in python. Helps in automation of day to day repetitive tasks.
A collection of daily usage utility scripts in python. Helps in automation of day to day repetitive tasks.

Kush's Utils Tool is my personal collection of scripts which is used to automated daily tasks. It is a evergrowing collection of scripts and will continue to evolve till the day I program. This is also my first python project.

Python scripts to interact with Upper Deck ePack online trading card platform

This script should connect to the Upper Deck ePack API using your browser cookies and download a list of your current collection and save it as a CSV.

Some Python scripts that fx(hash) users might find useful.

fx_hash_utils Some Python scripts that fx(hash) users might find useful. get_images This script downloads all the static images of the tokens generate

Timetable scripts for python

Timetable Scripts timetable_to_json: https://beta.elektronplus.pl/timetable classes_taught_by_teacher: a.adam (aa) ['1Tc', '1Td', '3Te', '3Ti', '4Tf',

Basic infrastructure for writing scripts in Python

Base Script Python is an excellent language that makes writing scripts very straightforward. Over the course of writing many scripts, we realized that

Collection of Python scripts to perform Eikonal Tomography

Collection of Python scripts to perform Eikonal Tomography

Cool little Python scripts & projects I've made.

Little Python Projects A repository for neat little Python scripts I've made! How to run a script: *NOTE: You'll need to install Python v3 or higher.

Owner
Zero Ekkusu
Web3 obsessed
Zero Ekkusu
python scripts - mostly automation scripts

python python scripts - mostly automation scripts You can set your environment in various ways bash #!/bin/bash python - locally on remote host #!/bi

Enyi 1 Jan 5, 2022
Collection of system-wide scripts that I use on my Gentoo

linux-scripts Collection of scripts that I use on my Gentoo machine. I tend to put all scripts in /scripts directory. It is not likely that you would

Xoores 1 Jan 9, 2022
A simple service that allows you to run commands on the server using text

Server Text A simple flask service that allows you to run commands on the server/computer over sms. Think of it as a shell where you run commands over

MT Devs 49 Nov 9, 2021
NotesToCommands - a fully customizable notes / command template program, allowing users to instantly execute terminal commands

NotesToCommands is a fully customizable notes / command template program, allowing users to instantly execute terminal commands with dynamic arguments grouped into sections in their notes/files. It was originally created for pentesting uses, to avoid the needed remembrance and retyping of sets of commands for various attacks.

zxro 5 Jul 2, 2022
Run python scripts and pass data between multiple python and node processes using this npm module

Run python scripts and pass data between multiple python and node processes using this npm module. process-communication has a event based architecture for interacting with python data and errors inside nodejs.

Tyler Laceby 2 Aug 6, 2021
IG Trading Algos and Scripts in Python

IG_Trading_Algo_Scripts_Python IG Trading Algos and Scripts in Python This project is a collection of my work over 2 years building IG Trading Algorit

null 191 Oct 11, 2022
python scripts and other files to generate induction encoder PCBs in Kicad

induction_encoder python scripts and other files to generate induction encoder PCBs in Kicad Targeting the Renesas IPS2200 encoder chips.

Taylor Alexander 8 Feb 16, 2022
These are the scripts used for the project of ‘Assembly of a pan-genome for global cattle reveals missing sequence and novel structural variation, providing new insights into their diversity and evolution history’

script-SV-genotyping These are the scripts used for the project of ‘Assembly of a pan-genome for global cattle reveals missing sequence and novel stru

null 2 Aug 26, 2022
Python based scripts for obtaining system information from Linux.

sysinfo Python based scripts for obtaining system information from Linux. Python2 and Python3 compatible Output in JSON format Simple scripts and exte

Petr Vavrin 70 Dec 20, 2022
Repo Home WPDrawBot - (Repo, Home, WP) A powerful programmatic 2D drawing application for MacOS X which generates graphics from Python scripts. (graphics, dev, mac)

DrawBot DrawBot is a powerful, free application for macOS that invites you to write Python scripts to generate two-dimensional graphics. The built-in

Frederik Berlaen 342 Dec 27, 2022