Skip to content

hanzhichao/web3-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Web3 CLI

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

Language - Python PyPI - License PyPI PyPI - Downloads

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

pip install python-web3-cli

Usage

1. Configuration

Set your RPC provider (e.g., Infura, Alchemy, or public nodes):

web3-cli config WEB3_RPC_URL https://eth.llamarpc.com

Set your private key to enable sending ETH:

web3-cli config WEB3_PRIVATE_KEY your_private_key_here

2. Commands

Check Balance

# 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

web3-cli block latest
web3-cli block 17000000

Get Transaction Info

web3-cli tx 0x...

Send ETH

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)

# 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)

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:

web3-cli contract call [PROXY_ADDR] "someMethod()" --abi ./implementation.json

Multi-sig & Offline Signing

Sign a transaction (without sending)

web3-cli sign 0x... 0.1

This outputs a raw hex string that can be shared or saved.

Send a pre-signed transaction

web3-cli send-raw <RAW_HEX>

Advanced State & Event Queries

Get contract bytecode

web3-cli contract code 0x...

Read raw storage slot

web3-cli contract storage 0x... 0

Get transaction receipt (execution status)

web3-cli receipt 0x...

Query event logs

web3-cli logs --address 0x... --from-block 17000000

Account & Security

Create a new account

web3-cli account create

Sign a message (EIP-191)

web3-cli account sign-message "Hello Web3"

Verify a signature

web3-cli account verify-message "Hello Web3" <signature> <address>

License

MIT

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors