Skip to main content

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

Project description

PancakeSwap Lottery - Web3 client

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

Install

pip install pancakeswap-lottery

Usage

from pancakeswap_lottery import Lottery

lottery = Lottery()
Current Lottery queries (realtime)
Past Lottery queries (using issue index)
Past Lottery queries (using tokenid)
Misc.

Current Lottery queries (realtime)

Issue Index

Current lottery round

>>> lottery.get_issue_index()
435

Total Amount

Total pot (CAKE) of current lottery round

>>> lottery.get_total_amount()
34977.25

Allocation

Prize pool allocation (percent)

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

Total Addresses

>>> lottery.get_total_addresses()
200

Drawed

True if currenty lottery round is drawed

>>> lottery.get_drawed()
False

Drawing Phase

True if currenty lottery round is in drawing phase

>>> lottery.get_drawing_phase()
False

Last Timestamp

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

Past Lottery queries (using issue index)

Total rewards

Total pot (CAKE)

>>> lottery.get_total_rewards(432)
51384.125

History Numbers

Winning numbers of lottery round

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

History Amount

Numbers of tickets matched

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

Matching Reward Amount

Numers of tickets matched a specified number

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

Past Lottery queries (using tokenid)

Lottery Numbers

Lottery numbers for a given ticket

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

Reward View

Rewards for a given ticket

>>> lottery.get_reward_view(1328060)
0

Misc.

Max Number

>>> lottery.get_max_number()
14

Min Price

Price for one ticket (CAKE)

>>> lottery.get_min_price()
1

Cake

CAKE contract address

>>> lottery.get_cake()
0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82

LotteryNFT

PLT-token contract address

>>> lottery.get_lotteryNFT()
0x5e74094Cd416f55179DBd0E45b1a8ED030e396A1

Balance Of

Get total number of tickets bought by a given address

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

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-0.1.2.tar.gz (7.5 kB view hashes)

Uploaded Source

Built Distribution

pancakeswap_lottery-0.1.2-py3-none-any.whl (6.8 kB view hashes)

Uploaded Python 3

Supported by

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