from web3 import Web3
from eth_utils import to_checksum_address
from rich.console import Console
from rich.table import Table
from rich.panel import Panel
import time
# Connect to Berachain Mainnet via Chainstack
RPC_URL = "YOUR_CHAINSTACK_ENDPOINT"
# Initialize
console = Console()
w3 = Web3(Web3.HTTPProvider(RPC_URL))
# Contract addresses
wbera = to_checksum_address("0x6969696969696969696969696969696969696969")
bgt = to_checksum_address("0x656b95E550C07a9ffe548bd4085c72418Ceb1dba")
honey = to_checksum_address("0xFCBD14DC51f0A4d49d5E53C2E0950e0bC26d0Dce")
def get_network_info():
"""Get basic network information"""
fee_history = w3.eth.fee_history(1, 'latest')
return {
'chain_id': w3.eth.chain_id,
'block_number': w3.eth.block_number,
'base_fee': w3.from_wei(fee_history['baseFeePerGas'][-1], 'gwei')
}
def get_token_supply(address):
"""Get total supply for a token"""
sig_total = w3.keccak(text="totalSupply()")[:4]
supply_raw = int.from_bytes(w3.eth.call({"to": address, "data": sig_total}), "big")
return supply_raw / 1e18
def main():
console.print("\n🐻 [bold cyan]Berachain Mainnet Dashboard[/bold cyan] 🚀", justify="center")
# Network Info Panel
network = get_network_info()
network_text = f"""
[green]✅ Connected to Berachain Mainnet[/green]
[blue]• Chain ID:[/blue] {network['chain_id']}
[blue]• Latest Block:[/blue] {network['block_number']:,}
[blue]• Base Fee:[/blue] {network['base_fee']:.3f} Gwei
"""
console.print(Panel(network_text.strip(), title="🔗 Network Status", border_style="green"))
# Token Supplies Table
table = Table(title="📊 Token Supplies")
table.add_column("Token", style="cyan", no_wrap=True)
table.add_column("Symbol", style="magenta")
table.add_column("Total Supply", style="green", justify="right")
table.add_column("Type", style="yellow")
# Get token supplies
bgt_supply = get_token_supply(bgt)
honey_supply = get_token_supply(honey)
table.add_row("BGT", "BGT", f"{bgt_supply:,.0f}", "Governance/PoL")
table.add_row("HONEY", "HONEY", f"{honey_supply:,.0f}", "Stablecoin")
console.print(table)
# Footer
console.print("\n[dim]🔄 Refresh this dashboard by running the script again![/dim]", justify="center")
if __name__ == "__main__":
main()