Virtual TestNets are live! ⚡️ Test and stage dapps on real-time production data.
Get started →

All Products

Tenderly Node
Client Libraries
Web3.py

Web3.py - Tenderly Node Integration

web3.py is a Python library for interacting with Ethereum.

It’s commonly found in decentralized apps (dapps) to help with sending transactions, interacting with smart contracts, reading block data, and a variety of other use cases.

connect.py
 
from web3 import Web3, AsyncWeb3
 
w3 = Web3(Web3.HTTPProvider('https:// mainnet.gateway.tenderly.co/<TENDERLY_NODE_ACCESS_KEY_MAINNET>'))
w3Async = AsyncWeb3(AsyncWeb3.AsyncHTTPProvider('https:// mainnet.gateway.tenderly.co/<TENDERLY_NODE_ACCESS_KEY_MAINNET>'))
w3Wss = Web3(Web3.WebsocketProvider('wss:// mainnet.gateway.tenderly.co/<TENDERLY_NODE_ACCESS_KEY_MAINNET>'))
 
print(w3.eth.get_block('latest'))
print(w3Async.eth.get_block('latest'))
print(w3Wss.is_connected())
print(w3Wss.eth.get_block('latest'))