Polygon
Bereit, das in der Produktion aufzurufen?
Das Free-Tier deckt persönliche Projekte ab. Pay-as-you-go skaliert ohne Karte.
Polygon
Das Free-Tier deckt persönliche Projekte ab. Pay-as-you-go skaliert ohne Karte.
Python has a mature toolset for building on Polygon. For general scripting and application code, web3.py is the standard library — and because Polygon PoS is EVM-equivalent, the same web3.py API you would use against Ethereum works directly against https://polygon.therpc.io/YOUR_API_KEY. For contract-heavy workflows — compiling, testing, and deploying Solidity — eth-brownie wraps web3.py in a development framework. Together they cover everything from a throwaway balance-checking script to a complex production service running on chain ID 137.
web3.py 6+ ships both synchronous and asynchronous interfaces, so you can choose whichever fits your Polygon workload. The async path requires AsyncWeb3 together with an async-compatible provider, which lets you fan out many concurrent calls to chain 137 without blocking a thread per request.
Install with pip install web3, then connect by wrapping the Polygon endpoint in an HTTP provider: Web3(Web3.HTTPProvider('https://polygon.therpc.io/YOUR_API_KEY')). web3.py is the de facto standard Python library for EVM chains and exposes the full Polygon API surface — balances, transactions, contracts, logs, and more — so anything available over JSON-RPC on chain 137 is reachable from Python.
eth-brownie is a Python framework built for smart-contract development on EVM chains like Polygon — it handles compiling Solidity, running test suites, and managing deployments to chain 137, with an interactive console for poking at contracts live. Install it with pip install eth-brownie.
For concurrent workloads against Polygon — say, fetching many blocks or balances at once — web3.py's async interface built on AsyncWeb3 is far more efficient than firing sequential blocking calls. It needs an async-compatible provider and runs inside an asyncio event loop (via asyncio.run(...)), so multiple requests to chain 137 can be in flight at the same time instead of waiting on each other.
web3.py ships comprehensive type stubs, so you can annotate your Polygon code with TxParams, Wei, and Address imported from web3.types. These annotations give you IDE autocompletion and let mypy statically verify that, for example, you are passing a proper Wei amount to a transaction on chain 137 rather than a bare integer that silently means the wrong thing.