Skip to main content

A Python client for accessing PancakeSwap Lottery smart contract information through Web3.py

Project description

PancakeSwap Lottery 🥞 - Web3 client

PyPI version PyPI downloads Licence Python version

A Python client for accessing PancakeSwap Lottery smart contract information through Web3.py.


Documentation: https://frefrik.github.io/pancakeswap-lottery

Examples: https://frefrik.github.io/pancakeswap-lottery/guide/examples

Source Code: https://github.com/frefrik/pancakeswap-lottery

PyPI: https://pypi.org/project/pancakeswap-lottery


Installation

Install from PyPI:

pip install pancakeswap-lottery

Usage

from pancakeswap_lottery import Lottery

lottery = Lottery()

# Current lottery round
issue_index = lottery.get_issue_index()

# Total pot (CAKE) of current lottery round
total_amount = lottery.get_total_amount()

# Prize pool allocation (percent)
allocation = lottery.get_allocation()

# Total addresses
total_addresses = lottery.get_total_addresses()

# Drawed 
drawed = lottery.get_drawed()

# Drawing phase
drawing_phase = lottery.get_drawing_phase()

# Last timestamp
timestamp = lottery.get_last_timestamp(epoch=False)

# Date and time of lottery round
lottery_date = lottery.get_lottery_date(432)

# Total rewards of lottery round
total_rewards = lottery.get_total_rewards(432)

# Winning numbers of lottery round
history_numbers = lottery.get_history_numbers(432)

# Numbers of tickets matched
history_amount = lottery.get_history_amount(432)

# Numers of tickets matched a specified number
matching_reward_amount = lottery.get_matching_reward_amount(432, 3)

# Lottery numbers for a given ticket
lottery_numbers = lottery.get_lottery_numbers(1328060)

# Rewards for a given ticket
reward_view = lottery.get_reward_view(1328060)

# Max number
max_number = lottery.get_max_number()

# CAKE contract address
cake_contract = lottery.get_cake()

# PLT-token contract address
lottery_contract = lottery.get_lotteryNFT()

# Total number of tickets bought by a given address
balance = lottery.get_balance_of("0xc13456A34305e9265E907F70f76B1BA6E2055c8B")

Response previews

>>> lottery.get_issue_index()
435

>>> lottery.get_total_amount()
34977.25

>>> lottery.get_allocation()
{'1': 50, '2': 20, '3': 10}

>>> lottery.get_total_addresses()
200

>>> lottery.get_drawed()
False

>>> lottery.get_drawing_phase()
False

>>> lottery.get_last_timestamp(epoch=False)
2021-03-27 11:38:49

>>> lottery.get_lottery_date(432)
2021-03-26 02:00:00+00:00

>>> lottery.get_total_rewards(432)
51384.125

>>> lottery.get_history_numbers(432)
[2, 13, 7, 3]

>>> lottery.get_history_amount(432)
{'4': 1, '3': 34, '2': 718}

>>> lottery.get_matching_reward_amount(432, 3)
34

>>> lottery.get_lottery_numbers(1328060)
[11, 5, 14, 6]

>>> lottery.get_reward_view(1328060)
0

>>> lottery.get_max_number()
14

>>> lottery.get_min_price()
1

>>> lottery.get_cake()
0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82

>>> lottery.get_lotteryNFT()
0x5e74094Cd416f55179DBd0E45b1a8ED030e396A1

>>> lottery.get_balance_of("0xc13456A34305e9265E907F70f76B1BA6E2055c8B")
2673

Donate

If you found this library useful and want to support my work feel free to donate a small amount 🙏🏻

  • 🥞 CAKE: 0xCFad66049e2C9Bc28647B2e2e3449B6B7C602d42
  • Ξ ETH: 0x7E916c46157f012Fb8dece4A042Dc603e8d627Df
  • ₿ BTC: bc1qgn2mdf5wsxft33s3ea8sh060y85mzntzs8cuu7

License

This project is licensed under the terms of the MIT license.

Disclaimer

This project is not affiliated with the PancakeSwap team.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pancakeswap-lottery-1.0.1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

pancakeswap_lottery-1.0.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file pancakeswap-lottery-1.0.1.tar.gz.

File metadata

  • Download URL: pancakeswap-lottery-1.0.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.5 Linux/5.4.0-65-generic

File hashes

Hashes for pancakeswap-lottery-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6f4eec5d44cc0137b74e850aa6a63a77d9d6186bda8156ee76bdd6ca8f63cf9d
MD5 f017c3abbf2eac13e9557cce2b77ade5
BLAKE2b-256 7475a1b9f013de89b872a39a6c8bcf8f2af1cd789255e1fef568df405c2f0c5d

See more details on using hashes here.

File details

Details for the file pancakeswap_lottery-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pancakeswap_lottery-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.5 Linux/5.4.0-65-generic

File hashes

Hashes for pancakeswap_lottery-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0b276d319f699f6b2b69c62c118d21d155f3adf970b1417ea75da8e4833b5cd4
MD5 fbd820733608095005459cf20705afd9
BLAKE2b-256 1fdb54946a381b5b2155c498861a7a310bc1e6a171c557a0aa4503ecb43f9566

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page