Metadata-Version: 2.4
Name: python-web3-cli
Version: 0.1.0
Author: Hanzhichao
License: MIT
Project-URL: Homepage, https://github.com/hanzhichao/web3-cli
Project-URL: Issues, https://github.com/hanzhichao/web3-cli/issues
Keywords: web3_cli
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: web3>=6.0.0
Requires-Dist: click>=8.0.0
Requires-Dist: rich>=12.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: eth-account>=0.8.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Dynamic: license-file

# Python Web3 CLI

A simple and powerful Ethereum command-line interface built with `web3.py`.

![Language - Python](https://img.shields.io/badge/language-python-blue.svg)
![PyPI - License](https://img.shields.io/pypi/l/python-web3-cli)
![PyPI](https://img.shields.io/pypi/v/python-web3-cli)
![PyPI - Downloads](https://img.shields.io/pypi/dm/python-web3-cli)

## Features

- **Config**: Manage RPC URLs and private keys securely via a local `.env` file.
- **Account**: Check ETH balance for any address or your default account.
- **Blockchain**: Retrieve detailed information for blocks and transactions.
- **Transfers**: Send ETH to any Ethereum address.
- **Rich UI**: Beautiful terminal output using the `rich` library.

## Installation

```bash
pip install python-web3-cli
```

## Usage

### 1. Configuration

Set your RPC provider (e.g., Infura, Alchemy, or public nodes):
```bash
web3-cli config WEB3_RPC_URL https://eth.llamarpc.com
```

Set your private key to enable sending ETH:
```bash
web3-cli config WEB3_PRIVATE_KEY your_private_key_here
```

### 2. Commands

**Check Balance**
```bash
# Check your own balance (requires private key in config)
web3-cli balance

# Check balance of a specific address
web3-cli balance 0x...
```

**Get Block Info**
```bash
web3-cli block latest
web3-cli block 17000000
```

**Get Transaction Info**
```bash
web3-cli tx 0x...
```

**Send ETH**
```bash
web3-cli send 0x... 0.01
```

### 3. Advanced Features

#### Smart Contract Interaction

You can call contract functions using their signature or a full JSON ABI.

**Read Data (Call)**
```bash
# Using function signature (defaults to view/uint256)
web3-cli contract call 0x... "balanceOf(address)" 0x...

# Using full ABI file
web3-cli contract call 0x... name --abi ./erc20.json
```

**Write Data (Transact)**
```bash
web3-cli contract transact 0x... "transfer(address,uint256)" 0x... 1000000
```

#### Proxy Calls

To call a proxy contract, provide the proxy address and the ABI of the implementation:
```bash
web3-cli contract call [PROXY_ADDR] "someMethod()" --abi ./implementation.json
```

#### Multi-sig & Offline Signing

**Sign a transaction (without sending)**
```bash
web3-cli sign 0x... 0.1
```
This outputs a raw hex string that can be shared or saved.

**Send a pre-signed transaction**
```bash
web3-cli send-raw <RAW_HEX>
```

#### Advanced State & Event Queries

**Get contract bytecode**
```bash
web3-cli contract code 0x...
```

**Read raw storage slot**
```bash
web3-cli contract storage 0x... 0
```

**Get transaction receipt (execution status)**
```bash
web3-cli receipt 0x...
```

**Query event logs**
```bash
web3-cli logs --address 0x... --from-block 17000000
```

#### Account & Security

**Create a new account**
```bash
web3-cli account create
```

**Sign a message (EIP-191)**
```bash
web3-cli account sign-message "Hello Web3"
```

**Verify a signature**
```bash
web3-cli account verify-message "Hello Web3" <signature> <address>
```

## License

MIT
