Interact with blockchains and smart contracts using the command line
Project description
Interact with blockchains and smart contracts using the command line: no coding needed!
Features
- Interact with Ethereum and EVM-compatible chains via your terminal
- Bypass sluggish and potentially compromised frontends
- No configuration needed
- Label addresses, tokens and contracts for ease of use
- Use as many signers as you wish
- Concatenate commands to build powerful scripts
- Transfer tokens via their ticker
- Thoroughly tested using brownie's testing framework
Soon:
- Swap with Uniswap, TraderJoe, PancakeSwap, etc
- Claim and reinvest yield from DeFi protocols
- Set up scheduled buys and sells (DCA)
- Analys on-chain data for tax or sleuthing purposes
Install
pip3 install -U web3cli
Simple examples
-
Get the ETH balance of any address:
w3 balance 0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae -
Save addresses with easy-to-rember tags:
w3 db address add unicef 0xa59b29d7dbc9794d1e7f45123c48b2b8d0a34636then use the tag in any command:
w3 balance unicef -
Send native coins to any address and in any unit:
w3 send unicef 1 ETH # send 1 ETH, ask for confirmation w3 send unicef 1 ETH gwei # send 1 gwei, ask for confirmation w3 send unicef 1 ETH gwei --force # send 1 gwei straight away -
Send tokens as well:
w3 send unicef 1 USDC # send 1 USDC -
Fetch blocks from the blockchain, in easy-to-read JSON format:
w3 block latest w3 block finalized w3 block 6094305 w3 block 0x54c891931a2d1195e668e77391b14b9fa43a4d68bc2f60b14d90fef0c63e9c4c
-
Fetch transactions & receipts from the blockchain:
w3 tx get 0x3bbdcc2c7721521f7c767b7873ccb857f0816ac94e9f32c5601f4b15c87d1ef1 w3 tx rc 0x3bbdcc2c7721521f7c767b7873ccb857f0816ac94e9f32c5601f4b15c87d1ef1
-
Extract single fields from blocks or transactions, using
jq(more details in the Wiki):w3 block latest | jq -r '.baseFeePerGas'
-
Sign messages:
w3 sign "Hello world!"
Multichain support
web3cli comes with out-of-the-box support for many chains, including Binance Chain, Avalanche and Polygon.
Pass the chain name as an optional argument:
w3 --chain bnb balance 0x8894e0a0c962cb723c1976a4421c95949be2d4e3 # bnb chain
w3 --chain avax balance 0x8894e0a0c962cb723c1976a4421c95949be2d4e3 # avax chain
or use one of the provided aliases:
w3bnb balance 0x8894e0a0c962cb723c1976a4421c95949be2d4e3 # bnb chain
w3avax balance 0x8894e0a0c962cb723c1976a4421c95949be2d4e3 # avax chain
If you are focussing on a specific chain, set it as the default:
w3 config set default_chain bnb
w3 balance 0x8894e0a0c962cb723c1976a4421c95949be2d4e3 # bnb chain
w3 --chain eth balance 0x8894e0a0c962cb723c1976a4421c95949be2d4e3 # eth chain
Add custom RPCs
Add custom RPCs to any existing chain with w3 db rpc add:
w3 db rpc add eth https://eth-mainnet.g.alchemy.com/v2/{YOUR API KEY}
List existing RPCs with w3 db rpc list, and delete them with w3 db rpc delete.
Add custom chains
Add new chains with w3 db chain add:
w3 db chain add cronos 25 CRO --tx-type 2 --rpc https://evm.cronos.org
Use the custom chain with --chain:
w3 --chain cronos balance 0x7de9ab1e6a60ac7a70ce96d1d95a0dfcecf7bfb7
List existing chains with w3 db chain list, and delete them with w3 db chain delete.
Address book
w3 can store tags just like you would do on etherscan.io or bscscan.com:
w3 db address add ethereum_foundation 0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae
w3 db address add binance_hot_wallet 0x8894e0a0c962cb723c1976a4421c95949be2d4e3
You can use these tags instead of the actual addresses:
w3 balance ethereum_foundation
w3 --chain bnb balance binance_hot_wallet
To see the list of saved addresses, run w3 db address list, to delete an address use w3 db address delete.
Wallet management
Commands such as w3 send and w3 sign require that you add a signer first:
w3 db signer add my_signer
You will be prompted to insert a private key, which will be encrypted and stored in the database.
You can also create a brand new wallet on the go, without the need to provide a key:
w3 db signer add my-wallet --create
Multiple signers
Add more signers with w3 db signer add and select which one to use with the --signer flag:
w3 --signer my_signer <command>
If you plan to use the same signer for a while, make it the default signer with the command:
w3 config set default_signer my_signer
Documentation
Check the project's wiki on Github. In particular:
Acknowledgements
Thank you very much to the communities behind web3.py and brownie: web3cli would not exist without your efforts!
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file web3cli-0.13.0.tar.gz.
File metadata
- Download URL: web3cli-0.13.0.tar.gz
- Upload date:
- Size: 47.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.3.4 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fcf66f3fe338c89513e57152df9cf87ad10dd4f11a4d9ce5b57b5c500e3ecb3
|
|
| MD5 |
acdc26c518738bb4ad2a38fdef1e67bc
|
|
| BLAKE2b-256 |
f9e0a3e9246c67510cc5d0db63df18cc06be1e9cbd409ae40ec661dbf1f9de6a
|
File details
Details for the file web3cli-0.13.0-py3-none-any.whl.
File metadata
- Download URL: web3cli-0.13.0-py3-none-any.whl
- Upload date:
- Size: 50.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.3.4 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aad632f3ff91e3e0a4e3d9936035166abd893a31bcad5315d7583f5012ed7215
|
|
| MD5 |
c56641e8149eff29c6e978892ad09f49
|
|
| BLAKE2b-256 |
ac6e035b557bdfec0ac02b723a3d3cc14616488ddd145f726a2defee8e3b796a
|