DEV Community

Steve Gerrad
Steve Gerrad

Posted on

Is ML powerful to predict lottery numbers on pancakeswap?

Image description

Can I see the strength of ML, is it possible to predict pancakeswap lottery numbers using ML?

As a full stack blockchain developer, I have more than 5 years experience. So it's a piece of cake to fetch the lottery data.
Here is the script I used for the fetching the history of pancakeswap lottery.

const ethers = require('ethers')
const reader = require('xlsx')
const abi = require('./abi.json') // Lottery
const mcAbi = require('./multicall.json')
const file = reader.readFile('./lottery.xlsx')

const address = "0x5aF6D33DE2ccEC94efb1bDF8f92Bd58085432d2c"
const mcAddress = "0xfF6FD90A470Aaa0c1B8A54681746b07AcdFedc9B"
const rpc = "https://bsc-dataseed.binance.org"
const provider = new ethers.providers.JsonRpcProvider(rpc)

const mcContract = new ethers.Contract(
    mcAddress,
    mcAbi,
    provider
)

const fetch = async () => {
    const itf = new ethers.utils.Interface(abi);
    const calldata = [];

    for (let index = 1; index < 593; index++) {
        calldata.push({
            target: address.toLowerCase(),
            callData: itf.encodeFunctionData('viewLottery', [index])
        })
    }

    const { returnData } = await mcContract.aggregate(calldata)

    const res = returnData.map((call, i) => {
        const result = itf.decodeFunctionResult('viewLottery', call)
        const finalNumber = result[0].finalNumber.toString();
        const date = new Date(Number(result[0].endTime.toString()) * 1000)

        return {
            timestamp: result[0].endTime.toString(),
            year: date.getFullYear(),
            month: date.getMonth() + 1,
            day: date.getDate(),
            hour: date.getHours(),
            minute: date.getMinutes(),
            second: date.getSeconds(),
            'number 1': finalNumber[6],
            'number 2': finalNumber[5],
            'number 3': finalNumber[4],
            'number 4': finalNumber[3],
            'number 5': finalNumber[2],
            'number 6': finalNumber[1]
        }
    })

    const ws = reader.utils.json_to_sheet(res);
    reader.utils.book_append_sheet(file, ws, "Sheet2")
    reader.writeFile(file, './lottery.xlsx')
}

fetch();
Enter fullscreen mode Exit fullscreen mode

I was wondered that pancakeswap start the lottery every 12 ~ 36 hours and every prize pots are more than 70k.
It means there are chances to earn 25k in every 2 days.
Oh, what a surprise!!!

I want to know the possibility of predict lottery numbers using ML.

Note that pancakeswap lottery uses Chainlink's implementation of VRF for secure randomness.

You can find more details about the pancakeswap lottery here.
https://docs.pancakeswap.finance/products/lottery

Top comments (0)