Created
July 9, 2021 22:35
-
-
Save juanpabloaj/5683311fc9ab0c6a6880f6ba6c2a6fd4 to your computer and use it in GitHub Desktop.
get pool length
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from web3 import Web3 | |
# https://web3py.readthedocs.io/en/stable/quickstart.html | |
# https://docs.matic.network/docs/develop/network-details/network/ | |
w3 = Web3(Web3.HTTPProvider("https://rpc-mainnet.matic.network")) | |
print(w3.isConnected()) | |
print(w3.eth.block_number) | |
# https://polygonscan.com/address/0x0d17C30aFBD4d29EEF3639c7B1F009Fd6C9f1F72 | |
masterchef_address = "0x0d17C30aFBD4d29EEF3639c7B1F009Fd6C9f1F72" | |
# copy from Contract ABI section in | |
# https://polygonscan.com/address/0x0d17C30aFBD4d29EEF3639c7B1F009Fd6C9f1F72 | |
masterchef_abi = open("masterchef_abi.json").read() | |
# https://web3py.readthedocs.io/en/stable/examples.html#interacting-with-existing-contracts | |
chef = w3.eth.contract(masterchef_address, abi=masterchef_abi) | |
n_pools = chef.functions.poolLength().call() | |
print("pool length", n_pools) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment