A cli tool to generate Python code from EVM ABI.
Project description
py-contract-codegen
py-contract-codegen
is a command-line tool for generating Python code from Ethereum ABI.
Installation
pip install py-contract-codegen
Commands
gen
: Generate Python code from an Ethereum ABI file.version
: Show the version of the code generator.
gen
Command
The gen
command is used to generate Python code from an Ethereum ABI.
py-contract-codegen gen [OPTIONS]
Options
--abi-path PATH
: Path to ABI file. If not provided,--abi-stdin
or--contract-address
must be set.--abi-stdin/--no-abi-stdin
: ABI content from stdin (default: no-abi-stdin).--contract-address TEXT
: Auto fetch ABI from Etherscan and generate code. Please set environment variableETHERSCAN_API_KEY
.--out-file PATH
: Path to save the generated code file. If not provided, prints to stdout.--class-name TEXT
: Contract Class Name for the generated code. If not provided, usesGeneratedContract
.--template-name [web3]
: Directory containing custom Jinja2 templates (default: web3).--network [mainnet|sepolia]
: Ethereum network for fetching ABI (default: mainnet).--help
: Show this message and exit.
Examples
From ABI file
py-contract-codegen gen --abi-path {ABI_FILE_PATH} --out-file generated_contract.py
From stdin
cat {ABI_FILE_PATH} | py-contract-codegen gen --abi-stdin --out-file generated_contract.py
From Contract Address
It automatically generates code by fetching the ABI through Etherscan API.
Please set environment variable ETHERSCAN_API_KEY
.
py-contract-codegen gen --contract-address {CONTRACT_ADDRESS} --out-file generated_contract.py
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_contract_codegen-0.1.0.tar.gz
(12.5 kB
view details)
Built Distribution
File details
Details for the file py_contract_codegen-0.1.0.tar.gz
.
File metadata
- Download URL: py_contract_codegen-0.1.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5564d7f9be044b3649eea8a5f85daaf80de338b8ff9aa59c01a5481e0919c40 |
|
MD5 | 460769b351f936993c9fa98af23bfc0a |
|
BLAKE2b-256 | ec54f63c279c43b55c151ef5dabd37a6e80ac8b2b301af3e01e78710711b683d |
File details
Details for the file py_contract_codegen-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: py_contract_codegen-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a045ba4061c7508a7f654d0ab44007a75d0154756b0aebc1ba021b07377d7958 |
|
MD5 | acd0c8bf824d9cb978be2695da03a38d |
|
BLAKE2b-256 | 2c92d98a8f71333a7b704821c77d02b60bbf06ed16e489491c4cbd7a7cf8421e |