web3toolkit-base
A Python library for essential Web3 helper functions.
Features
- Wallet operations (creation, validation, balance query)
- Transaction creation, signing, and sending
- Smart contract deployment and function calls
- Token operations (ERC-20, ERC-721, ERC-1155)
- Network and block queries
- Utility functions (hex, int, string conversions, IPFS hash validation)
- Advanced features: ENS, gas, nonce, NFT, analytics, security, and more
Installation
pip install web3toolkit-base
Usage
from web3toolkit import create_wallet, validate_address
wallet = create_wallet()
print(wallet)
print(validate_address(wallet['address']))
Setting API Keys for Advanced Features
Some advanced features (e.g., Etherscan, BscScan, Covalent, OpenSea) require API keys. You can set them at the start of your project:
from web3toolkit import set_api_keys, is_contract_verified
set_api_keys(
etherscan="YOUR_ETHERSCAN_API_KEY",
bscscan="YOUR_BSCSCAN_API_KEY",
covalent="YOUR_COVALENT_API_KEY",
opensea="YOUR_OPENSEA_API_KEY"
)
result = is_contract_verified("0x1234...abcd", chain="bsc")
print(result)
Alternatively, you can set the following environment variables:
ETHERSCAN_API_KEY
BSCSCAN_API_KEY
COVALENT_API_KEY
OPENSEA_API_KEY
Requirements
- Python 3.7+
- web3
- eth-account
- requests
Contribution
Feel free to open pull requests and issues.