<jupyter_start><jupyter_text><jupyter_code>!pip install -force-reinstall jupyter-client>=6.1.5
pip install Web3
!pip install --force-reinstall jsonschema==3.2.0
#!pip install -force-reinstall six~=1.15.0
#!pip install -force-reinstall folium==0.2.1
#!pip install -force-reinstall imgaug<0.2.7,>=0.2.5
from web3 import Web3;
import json;
from datetime import date;
infura_url ="https://polygon-mainnet.infura.io/v3/xxxxx"
pt_draw_adress_contract = "0x8141BcFBcEE654c5dE17C4e2B2AF26B67f9B9056"
myAdress = "0x1234xxxx"
web3 = Web3(Web3.HTTPProvider(infura_url))
web3.isConnected()
#web3.eth.blockNumber
#balance = web3.eth.get_balance(myAdress)
# check rewards
abi = json.loads('[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IDrawCalculator","name":"_drawCalculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint32","name":"drawId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"ClaimedDraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IDrawCalculator","name":"calculator","type":"address"}],"name":"DrawCalculatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Withdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipOffered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"TokenSet","type":"event"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_drawIds","type":"uint32[]"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32","name":"_drawId","type":"uint32"}],"name":"getDrawPayoutBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDrawCalculator","name":"_newCalculator","type":"address"}],"name":"setDrawCalculator","outputs":[{"internalType":"contract IDrawCalculator","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_erc20Token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawERC20","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]')
contract = web3.eth.contract(address=pt_draw_adress_contract, abi=abi)

d0 = date(2021,10,16)
today = date.today();
delta=today - d0;
drawNumber = delta.days;
rewards = contract.functions.getDrawPayoutBalanceOf(myAdress, drawNumber).call()

print(drawNumber)

if rewards > 0:
  print(rewards)
  print("you won!")
  subject = "You're a winner!";
else:
  print(rewards)
  print("you lost")
  subjet = "You're a loser";
# send email (not safe: use an idle address)
#import smtplib, ssl

#port = 465  # For SSL
#smtp_server = "smtp.gmail.com"
#sender_email = "<EMAIL>"  # Enter your address
#receiver_email = "<EMAIL>"  # Enter receiver address
#password = input("Type your password and press enter: ")
#message = """\
#Subject: Hi there

#This message is sent from Python."""

#context = ssl.create_default_context()
#with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
 #   server.login(sender_email, password)
  #  server.sendmail(sender_email, receiver_email, message)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2619047619047619, 'fraction_numerical': 0.02399409376153562, 'mean_word_length': 19.842307692307692, 'pattern_counts': {'":': 189, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '374674', 'license': 'MIT', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1650, 'n_words': 149, 'path': 'Check_PT_rewards.ipynb', 'repo_name': 'lamarock61/pooltogether_check_draw', 'size': '5430'}