Skip to main content
TLDR:
  • Demonstrates connecting to Berachain Mainnet using Python and Web3.py via Chainstack endpoints
  • Shows how to query ERC-20 tokens, core Berachain tokens (BGT, HONEY), and monitor live transfers
  • Covers Proof-of-Liquidity concepts and real-time blockchain data monitoring
  • Provides practical scripts for read-only blockchain interactions without requiring private keys

Overview

Berachain is an innovative EVM-compatible blockchain that implements Proof-of-Liquidity (PoL) consensus. Unlike traditional Proof-of-Stake systems, Berachain’s PoL mechanism aligns network incentives through BGT (Berachain Governance Token) emissions and liquidity provision. This tutorial will walk you through building practical Python applications that interact with Berachain Mainnet using Chainstack’s reliable RPC infrastructure. We’ll explore everything from basic connectivity to advanced monitoring capabilities, all while maintaining a read-only approach that’s perfect for learning and experimentation.

Prerequisites

Understanding Berachain architecture

Before writing code, let’s understand key Berachain concepts:

Core tokens

  • BERA - Native gas token, similar to ETH on Ethereum
  • BGT - Governance token that powers Proof-of-Liquidity
  • HONEY - Algorithmic stablecoin native to Berachain

Key contracts

  • WBERA (0x6969696969696969696969696969696969696969) - Wrapped BERA token
  • BGT (0x656b95E550C07a9ffe548bd4085c72418Ceb1dba) - Governance token
  • HONEY (0xFCBD14DC51f0A4d49d5E53C2E0950e0bC26d0Dce) - Stablecoin
  • BeraChef (0xdf960E8F3F19C481dDE769edEDD439ea1a63426a) - Proof-of-Liquidity manager

Basic connection and network information

Let’s start with a simple connection script that verifies our setup and displays basic network information. Create connection.py:
Key concepts demonstrated:
  • Establishing Web3 connection to Berachain
  • Verifying connectivity with is_connected()
  • Querying basic network information (chain ID, latest block, gas fees)
  • Working with wei-to-gwei conversions

ERC-20 token interactions

Next, let’s interact with ERC-20 tokens through node calls, starting with WBERA (Wrapped BERA). Create wbera_query.py:
Key concepts demonstrated:
  • Using w3.keccak() to generate function selectors
  • Making contract calls with w3.eth.call()
  • Parsing contract responses and handling different data types
  • Working with ERC-20 standard functions

Core Berachain tokens

Let’s explore Berachain’s core tokens: BGT and HONEY.
Key concepts demonstrated:
  • Querying multiple token contracts efficiently
  • Understanding Berachain’s tokenomics
  • Creating reusable functions for common operations

Live transfer monitoring

One of the most powerful features is monitoring live blockchain activity. Let’s track WBERA transfers in real-time.
Key concepts demonstrated:
  • Event signature generation with w3.keccak()
  • Querying historical logs with w3.eth.get_logs()
  • Parsing event data from topics and data fields
  • Real-time blockchain monitoring techniques

Advanced dashboard with rich formatting

Finally, let’s create a beautiful, comprehensive dashboard using the Rich library.

Conclusion

This tutorial provided a comprehensive introduction to Berachain development using Python and Chainstack’s reliable infrastructure. You’ve learned how to:
  • Connect to Berachain Mainnet using web3.py
  • Query ERC-20 tokens and core Berachain assets
  • Monitor live blockchain activity and transfers
  • Build beautiful terminal dashboards with Rich
  • Understand Berachain’s unique Proof-of-Liquidity system
The read-only approach demonstrated here is perfect for learning, monitoring, and building analytics applications. As you continue your Berachain development journey, these foundational skills will serve as the building blocks for more complex applications.

See also

Berachain Documentation

Web3.py Documentation

About the author

Ake

Ake Director of Developer Experience @ Chainstack
Talk to me all things Web3
20 years in technology | 8+ years in Web3 full time years experience
Last modified on April 13, 2026