A lightweight Python library for converting blockchain addresses between different formats, with initial support for EVM-compatible chains and other blockchain networks.
- Convert addresses between different blockchain formats
- Support multiple encoding formats (Base58Check, Hex)
- Comprehensive address validation
- Minimal dependencies (only
base58) - Type hints support
- Thoroughly tested
pip install address-converterfrom address_converter import evm_to_tron, tron_to_evm, get_address_type
# Convert EVM format to alternative format
evm_address = "0x123456789abcdef123456789abcdef123456789a"
alt_base58 = evm_to_tron(evm_address, output_format='base58')
alt_hex = evm_to_tron(evm_address, output_format='hex')
print(f"Base58 format: {alt_base58}")
print(f"Hex format: {alt_hex}")
# Convert from alternative format to EVM
alt_address = "TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW"
evm_result = tron_to_evm(alt_address, add_prefix=True)
print(f"EVM format: {evm_result}")
# Detect address type
address_type = get_address_type(evm_address)
print(f"Address type: {address_type}") # 'evm'Convert an EVM address to alternative blockchain format.
- Parameters:
evm_address: EVM address (with or without '0x' prefix)output_format: Output format, either 'base58' or 'hex'
- Returns: Address in specified format
- Raises: ValueError if address is invalid
Convert an address from alternative blockchain format to EVM format.
- Parameters:
tron_address: Address in Base58Check or Hex formatadd_prefix: Whether to add '0x' prefix
- Returns: EVM address
- Raises: ValueError if address is invalid
Detect address type.
- Parameters:
address: Address to detect
- Returns: Address type string ('evm', 'tron_base58', 'tron_hex') or None if invalid
- 40 hexadecimal characters (excluding '0x' prefix)
- Case-insensitive
- Optional '0x' prefix
- Base58Check format: Specific prefix character, fixed length
- Hex format: Specific byte prefix, fixed length
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- EVM Address Format
- Base58Check Encoding
- Various blockchain address format specifications
If you have any questions or need help, please:
- Check the issues page
- Create a new issue if you can't find an answer
This is an independent open-source project developed for educational and research purposes. It is not affiliated with, endorsed by, or connected to any organization or entity. The code is provided "as is" under the MIT License.