pancakeswap-lottery


Namepancakeswap-lottery JSON
Version 2.1.0 PyPI version JSON
download
home_pagehttps://github.com/frefrik/pancakeswap-lottery
SummaryA Python client for accessing PancakeSwap Lottery smart contract information through Web3.py
upload_time2024-05-13 21:49:20
maintainerNone
docs_urlNone
authorFredrik Haarstad
requires_python<4.0,>=3.9
licenseMIT
keywords pancakeswap cake lottery bsc web3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PancakeSwap Lottery 🥞 - Web3 client

![PyPI version](https://img.shields.io/pypi/v/pancakeswap-lottery)
![PyPI downloads](https://img.shields.io/pypi/dm/pancakeswap-lottery)
![Licence](https://img.shields.io/github/license/frefrik/pancakeswap-lottery)
![Python version](https://img.shields.io/pypi/pyversions/pancakeswap-lottery)

A Python client for accessing [PancakeSwap Lottery](https://pancakeswap.finance/lottery) smart contract information through [Web3.py](https://github.com/ethereum/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](https://pypi.org/project/pancakeswap-lottery/):
```
pip install pancakeswap-lottery
```

## Usage
```python
from pancakeswap_lottery import LotteryV2

lottery = LotteryV2()

# Current lottery round number
current_round = lottery.current_round()

# Current ticket id
ticketid = lottery.current_ticket()

# Status of lottery round
status = lottery.status()

# Lottery draw date and time of lottery round
draw_date = lottery.draw_date()

# Ticket price in CAKE
ticket_price = lottery.ticket_price()

# Total prize pool of lottery round in CAKE
prize_pool = lottery.prize_pool()

# Prize pool allocation in CAKE
allocation = lottery.prize_pool_allocation()

# Total number of tickets in lottery round
total_tickets = lottery.total_tickets(lotteryround=23)

# Winning numbers for lottery round
winning_numbers = lottery.winning_numbers(lotteryround=16)

# Get lottery winnings (CAKE) for a given address and round
address_winnings = lottery.address_winnings(address="0x621D6ee5FA9634d86396C13fAaD6A7827606A6d7", lotteryround=16)

# Get lottery winnings (CAKE) for a given ticket and round
ticket_winnings = lottery.ticket_winnings(lotteryround=10, ticketid=158408)

# Number of winners per prize bracket
winners = lottery.winners_per_bracket(lotteryround=16)

# Amount of CAKE won per ticket in each prize bracket
cake_per_bracket = lottery.cake_per_bracket(lotteryround=16)

# Percentage probability of winning the lottery
winning_probability = lottery.winning_probability()

# Data from historic lottery rounds can also be pulled
status = lottery.status(lotteryround=10)
draw_date = lottery.draw_date(lotteryround=10)
ticket_price = lottery.ticket_price(lotteryround=10)
prize_pool = lottery.prize_pool(lotteryround=10)
allocation = lottery.prize_pool_allocation(lotteryround=10)
```

### Response previews
```python
>>> lottery.current_round()
20

>>> lottery.current_ticket()
1124981

>>> lottery.status()
Open

>>> lottery.draw_date()
2021-07-12 20:00:00

>>> lottery.ticket_price()
0.32

>>> lottery.prize_pool()
63024

>>> lottery.prize_pool_allocation()
{'match_1': 630, 'match_2': 1891, 'match_3': 3781, 'match_4': 6302, 'match_5': 12605, 'match_6': 25210, 'burn': 12605}

>>> lottery.total_tickets(lotteryround=23)
14253

>>> lottery.ticket_winnings(lotteryround=15, ticketid=567093)
865.536634168

>>> lottery.address_winnings("0x621D6ee5FA9634d86396C13fAaD6A7827606A6d7", lotteryround=16)
{'tickets': 8, 'ticketids': [634970, 634971, 634972, 634973, 634974, 634975, 634976, 634977], 'winning_tickets': [634970, 634971]}

 >>> lottery.winning_numbers(lotteryround=16)
743350

>>> lottery.winners_per_bracket(lotteryround=16)
{'match_1': 19133, 'match_2': 1921, 'match_3': 188, 'match_4': 21, 'match_5': 1, 'match_6': 1}

>>> lottery.cake_per_bracket(lotteryround=16)
{'match_1': 0, 'match_2': 3, 'match_3': 62, 'match_4': 925, 'match_5': 38843, 'match_6': 77687}

>>> lottery.winning_probability()
{'match_1': 10.0, 'match_2': 1.0, 'match_3': 0.1, 'match_4': 0.01, 'match_5': 0.001, 'match_6': 0.0001}
```

<details>
<summary>Lottery V1</summary>

## Usage (Lottery V1)
```python
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 V1)
```python
>>> 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
```
</details>

## 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.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/frefrik/pancakeswap-lottery",
    "name": "pancakeswap-lottery",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "pancakeswap, cake, lottery, bsc, web3",
    "author": "Fredrik Haarstad",
    "author_email": "codemonkey@zomg.no",
    "download_url": "https://files.pythonhosted.org/packages/6e/3a/d141663daa2beb715e39bb090fb1dfa847475fb5e74a9b599278e0720e5f/pancakeswap_lottery-2.1.0.tar.gz",
    "platform": null,
    "description": "# PancakeSwap Lottery \ud83e\udd5e - Web3 client\n\n![PyPI version](https://img.shields.io/pypi/v/pancakeswap-lottery)\n![PyPI downloads](https://img.shields.io/pypi/dm/pancakeswap-lottery)\n![Licence](https://img.shields.io/github/license/frefrik/pancakeswap-lottery)\n![Python version](https://img.shields.io/pypi/pyversions/pancakeswap-lottery)\n\nA Python client for accessing [PancakeSwap Lottery](https://pancakeswap.finance/lottery) smart contract information through [Web3.py](https://github.com/ethereum/web3.py).\n\n---\n\n**Documentation**: https://frefrik.github.io/pancakeswap-lottery\n\n**Examples**: https://frefrik.github.io/pancakeswap-lottery/guide/examples\n\n**Source Code**: https://github.com/frefrik/pancakeswap-lottery\n\n**PyPI**: https://pypi.org/project/pancakeswap-lottery\n\n---\n\n## Installation\nInstall from [PyPI](https://pypi.org/project/pancakeswap-lottery/):\n```\npip install pancakeswap-lottery\n```\n\n## Usage\n```python\nfrom pancakeswap_lottery import LotteryV2\n\nlottery = LotteryV2()\n\n# Current lottery round number\ncurrent_round = lottery.current_round()\n\n# Current ticket id\nticketid = lottery.current_ticket()\n\n# Status of lottery round\nstatus = lottery.status()\n\n# Lottery draw date and time of lottery round\ndraw_date = lottery.draw_date()\n\n# Ticket price in CAKE\nticket_price = lottery.ticket_price()\n\n# Total prize pool of lottery round in CAKE\nprize_pool = lottery.prize_pool()\n\n# Prize pool allocation in CAKE\nallocation = lottery.prize_pool_allocation()\n\n# Total number of tickets in lottery round\ntotal_tickets = lottery.total_tickets(lotteryround=23)\n\n# Winning numbers for lottery round\nwinning_numbers = lottery.winning_numbers(lotteryround=16)\n\n# Get lottery winnings (CAKE) for a given address and round\naddress_winnings = lottery.address_winnings(address=\"0x621D6ee5FA9634d86396C13fAaD6A7827606A6d7\", lotteryround=16)\n\n# Get lottery winnings (CAKE) for a given ticket and round\nticket_winnings = lottery.ticket_winnings(lotteryround=10, ticketid=158408)\n\n# Number of winners per prize bracket\nwinners = lottery.winners_per_bracket(lotteryround=16)\n\n# Amount of CAKE won per ticket in each prize bracket\ncake_per_bracket = lottery.cake_per_bracket(lotteryround=16)\n\n# Percentage probability of winning the lottery\nwinning_probability = lottery.winning_probability()\n\n# Data from historic lottery rounds can also be pulled\nstatus = lottery.status(lotteryround=10)\ndraw_date = lottery.draw_date(lotteryround=10)\nticket_price = lottery.ticket_price(lotteryround=10)\nprize_pool = lottery.prize_pool(lotteryround=10)\nallocation = lottery.prize_pool_allocation(lotteryround=10)\n```\n\n### Response previews\n```python\n>>> lottery.current_round()\n20\n\n>>> lottery.current_ticket()\n1124981\n\n>>> lottery.status()\nOpen\n\n>>> lottery.draw_date()\n2021-07-12 20:00:00\n\n>>> lottery.ticket_price()\n0.32\n\n>>> lottery.prize_pool()\n63024\n\n>>> lottery.prize_pool_allocation()\n{'match_1': 630, 'match_2': 1891, 'match_3': 3781, 'match_4': 6302, 'match_5': 12605, 'match_6': 25210, 'burn': 12605}\n\n>>> lottery.total_tickets(lotteryround=23)\n14253\n\n>>> lottery.ticket_winnings(lotteryround=15, ticketid=567093)\n865.536634168\n\n>>> lottery.address_winnings(\"0x621D6ee5FA9634d86396C13fAaD6A7827606A6d7\", lotteryround=16)\n{'tickets': 8, 'ticketids': [634970, 634971, 634972, 634973, 634974, 634975, 634976, 634977], 'winning_tickets': [634970, 634971]}\n\n >>> lottery.winning_numbers(lotteryround=16)\n743350\n\n>>> lottery.winners_per_bracket(lotteryround=16)\n{'match_1': 19133, 'match_2': 1921, 'match_3': 188, 'match_4': 21, 'match_5': 1, 'match_6': 1}\n\n>>> lottery.cake_per_bracket(lotteryround=16)\n{'match_1': 0, 'match_2': 3, 'match_3': 62, 'match_4': 925, 'match_5': 38843, 'match_6': 77687}\n\n>>> lottery.winning_probability()\n{'match_1': 10.0, 'match_2': 1.0, 'match_3': 0.1, 'match_4': 0.01, 'match_5': 0.001, 'match_6': 0.0001}\n```\n\n<details>\n<summary>Lottery V1</summary>\n\n## Usage (Lottery V1)\n```python\nfrom pancakeswap_lottery import Lottery\n\nlottery = Lottery()\n\n# Current lottery round\nissue_index = lottery.get_issue_index()\n\n# Total pot (CAKE) of current lottery round\ntotal_amount = lottery.get_total_amount()\n\n# Prize pool allocation (percent)\nallocation = lottery.get_allocation()\n\n# Total addresses\ntotal_addresses = lottery.get_total_addresses()\n\n# Drawed \ndrawed = lottery.get_drawed()\n\n# Drawing phase\ndrawing_phase = lottery.get_drawing_phase()\n\n# Last timestamp\ntimestamp = lottery.get_last_timestamp(epoch=False)\n\n# Date and time of lottery round\nlottery_date = lottery.get_lottery_date(432)\n\n# Total rewards of lottery round\ntotal_rewards = lottery.get_total_rewards(432)\n\n# Winning numbers of lottery round\nhistory_numbers = lottery.get_history_numbers(432)\n\n# Numbers of tickets matched\nhistory_amount = lottery.get_history_amount(432)\n\n# Numers of tickets matched a specified number\nmatching_reward_amount = lottery.get_matching_reward_amount(432, 3)\n\n# Lottery numbers for a given ticket\nlottery_numbers = lottery.get_lottery_numbers(1328060)\n\n# Rewards for a given ticket\nreward_view = lottery.get_reward_view(1328060)\n\n# Max number\nmax_number = lottery.get_max_number()\n\n# CAKE contract address\ncake_contract = lottery.get_cake()\n\n# PLT-token contract address\nlottery_contract = lottery.get_lotteryNFT()\n\n# Total number of tickets bought by a given address\nbalance = lottery.get_balance_of(\"0xc13456A34305e9265E907F70f76B1BA6E2055c8B\")\n```\n\n### Response previews (Lottery V1)\n```python\n>>> lottery.get_issue_index()\n435\n\n>>> lottery.get_total_amount()\n34977.25\n\n>>> lottery.get_allocation()\n{'1': 50, '2': 20, '3': 10}\n\n>>> lottery.get_total_addresses()\n200\n\n>>> lottery.get_drawed()\nFalse\n\n>>> lottery.get_drawing_phase()\nFalse\n\n>>> lottery.get_last_timestamp(epoch=False)\n2021-03-27 11:38:49\n\n>>> lottery.get_lottery_date(432)\n2021-03-26 02:00:00+00:00\n\n>>> lottery.get_total_rewards(432)\n51384.125\n\n>>> lottery.get_history_numbers(432)\n[2, 13, 7, 3]\n\n>>> lottery.get_history_amount(432)\n{'4': 1, '3': 34, '2': 718}\n\n>>> lottery.get_matching_reward_amount(432, 3)\n34\n\n>>> lottery.get_lottery_numbers(1328060)\n[11, 5, 14, 6]\n\n>>> lottery.get_reward_view(1328060)\n0\n\n>>> lottery.get_max_number()\n14\n\n>>> lottery.get_min_price()\n1\n\n>>> lottery.get_cake()\n0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82\n\n>>> lottery.get_lotteryNFT()\n0x5e74094Cd416f55179DBd0E45b1a8ED030e396A1\n\n>>> lottery.get_balance_of(\"0xc13456A34305e9265E907F70f76B1BA6E2055c8B\")\n2673\n```\n</details>\n\n## Donate\nIf you found this library useful and want to support my work feel free to donate a small amount \ud83d\ude4f\ud83c\udffb\n\n- \ud83e\udd5e CAKE: 0xCFad66049e2C9Bc28647B2e2e3449B6B7C602d42\n- \u039e ETH: 0x7E916c46157f012Fb8dece4A042Dc603e8d627Df\n- \u20bf BTC: bc1qgn2mdf5wsxft33s3ea8sh060y85mzntzs8cuu7\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n\n## Disclaimer\n\nThis project is not affiliated with the PancakeSwap team.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python client for accessing PancakeSwap Lottery smart contract information through Web3.py",
    "version": "2.1.0",
    "project_urls": {
        "Homepage": "https://github.com/frefrik/pancakeswap-lottery",
        "Repository": "https://github.com/frefrik/pancakeswap-lottery"
    },
    "split_keywords": [
        "pancakeswap",
        " cake",
        " lottery",
        " bsc",
        " web3"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7bd3d31358fe55dda6621e70d3aa0752d78b4841d784619a3b7e3d31224823eb",
                "md5": "227882df879cf24af6f39470d215792c",
                "sha256": "d3f026f5f9af0574406294fa8781f725e2f0f882fc00bab95fd2853a0dce99b6"
            },
            "downloads": -1,
            "filename": "pancakeswap_lottery-2.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "227882df879cf24af6f39470d215792c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 14534,
            "upload_time": "2024-05-13T21:49:18",
            "upload_time_iso_8601": "2024-05-13T21:49:18.744628Z",
            "url": "https://files.pythonhosted.org/packages/7b/d3/d31358fe55dda6621e70d3aa0752d78b4841d784619a3b7e3d31224823eb/pancakeswap_lottery-2.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6e3ad141663daa2beb715e39bb090fb1dfa847475fb5e74a9b599278e0720e5f",
                "md5": "a5a98b7756be3e94be934675eecc26d3",
                "sha256": "dc33148cabdce1ccd09993a7b34fdd85e0a9d3c6e32e68549f482798e61a98d2"
            },
            "downloads": -1,
            "filename": "pancakeswap_lottery-2.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a5a98b7756be3e94be934675eecc26d3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 13070,
            "upload_time": "2024-05-13T21:49:20",
            "upload_time_iso_8601": "2024-05-13T21:49:20.547765Z",
            "url": "https://files.pythonhosted.org/packages/6e/3a/d141663daa2beb715e39bb090fb1dfa847475fb5e74a9b599278e0720e5f/pancakeswap_lottery-2.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-13 21:49:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "frefrik",
    "github_project": "pancakeswap-lottery",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pancakeswap-lottery"
}
        
Elapsed time: 8.60374s