Mining Crypto and NFTs with Python

Please remain calm if you associate the words crypto and NFT with the word scam. This article will not contain any financial advice, advertising, only programming. In general, I like to automate any activity that generates income, and just yesterday, absolutely by accident, I came across a review of a certain gaming platform, which is an NFT game in the RPG genre (that is, all players want to increase their capital using game mechanics , mining tokens). One of the mechanics of the game simply did not allow me to pass by and not think about automating it, since it looks very simple, but boring and a long task. And this is what is needed.

Its essence is this: with the help of simple actions in the browser to confirm cryptocurrency transactions, with a 33% chance we are given some in-game crystals of ordinary quality, or with a 2% chance of legendary ones. These crystals can be used somehow in the game, but I didn't go deeper. The developers also promise that the mined crystals can be monetized in the following way: each regular crystal costs 10 points, and the legendary one costs 120. If you collect 10,000 points before the end of the season (I still don’t understand when it ends), then you will be given a reward -an NFT, and a minimum of 5,000 points are converted into SKL tokens. How much human money this is, I don’t know, and it doesn’t matter, our interest is to complete the task as quickly and simply as possible using programming skills.

Developer promises regarding monetization.

Developer promises regarding monetization.

And so, based on the conditions set, it follows that to achieve 10,000 points you need to get as many as 1000 ordinary crystals, which fall out with a 33% chance. You will need many times fewer legendary ones, but they almost never appear.

Let's try to get crystals by hand. To do this, we simply connect to the system using the Metamask wallet and perform the routine: press the button, after a while the Metamask window opens, in which we confirm the transaction by pressing another button.

We press the buttons

We press the buttons

Then the transaction is processed for some time and a window pops up that we have not received any crystals, but we will definitely be lucky next time.

Better luck next time...

Better luck next time…

We believe. We wait until the button becomes active again. We repeat the cycle. As a result, each iteration of the loop can take up to a minute of precious time. Spending so much time with the ephemeral hope of earning an incomprehensible amount of money is not our option, so we will attract a robot.

I would like to note that I went to the official discord of the project and saw there how thousands of English-speaking people complain about the hellish torment associated with crystal mining. Poor people are clicking on buttons day and night on all devices and losing hope. It’s a pity, of course, for these good-natured people.

But we have no time for their suffering. To operate the robot, I decided to use my laptop, which usually sits idle and is needed only on long trips, since the running program will not allow me to use the computer for other purposes while it is working. In addition, the laptop will perform work in an energy-efficient mode, which will avoid, albeit small, but still monetary losses. And right now the laptop is doing its thing, and I’m writing this article on the main computer. Well, sometimes I look at the “catch”, but more on that later.

The logic of our simple program will be written in Python using the PyAutoGUI library. Therefore, we create a new project, a virtual environment and install the library. Depending on your operating system, you need to use different commands for installation, see them in documentation.

Essentially, we only need to click on two areas of the screen at certain intervals, so let's define these areas. To do this, we will write a script that will show coordinates along the X and Y axes in real time, write down the coordinates of our buttons, and use it in the clicker script.

import pyautogui
import time

try:
    while True:
        x, y = pyautogui.position()
        print(f'X: {x}, Y: {y}', end='\r')  # Обновляем координаты в одной строке
except KeyboardInterrupt:
    print('\nВыход из программы')

PyAutoGUI allows you to click the mouse on the desired areas without moving the cursor, but to make everything look as human as possible, I decided to move the cursor and added a short delay before the click. In addition, as it turned out, on my laptop the Metamask confirmation window does not open completely and the button is simply not visible. Therefore, I added a small scrolling wheel down to the script. You may not even need this functionality.

And yet, some transactions are processed much longer than others and there is a possibility that, after the time delay set in the program has expired, it will try to click on the button while it is not yet active. After this, the cursor will move to the place where the Metamask window usually opens, but it will not be there either. As a result, the program will scroll the main screen with the mouse wheel and mess up all the coordinates, and therefore all subsequent iterations of the loop will not work. To prevent this from happening, a mandatory upward scrolling with the mouse wheel has been added to the program. Just in case.

Our simple clicker script is ready and looks like this:

import pyautogui
import time


def clicker():
    try:
        while True:
            # Клик левой кнопкой мыши по первой области экрана
            x = 460
            y = 650
            pyautogui.moveTo(x, y)
            time.sleep(1)
            pyautogui.click(button='left')
            #pyautogui.moveRel(50, 50)


            # Ждем 12 секунд
            time.sleep(12)

            # Клик левой кнопкой мыши по второй области экрана
            x = 1515
            y = 555
            pyautogui.moveTo(x, y)
            pyautogui.scroll(-70)
            time.sleep(1)
            pyautogui.click(button='left')
            time.sleep(25)
            pyautogui.scroll(100)
            
    except KeyboardInterrupt:
        print('\nВыход из программы')



if __name__ == '__main__':
    time.sleep(10) # пауза перед запуском функции
    clicker()

At the time of writing, this script has been running for over 10 hours and has achieved some success. Pay attention to the screenshot.

Crystals earned through honest robotic labor

Crystals earned through honest robotic labor

There were also a couple of legendary ones there.

These are rare animals.

These are rare animals.

Total 2430 points out of 10000 in 10 hours. Not too bad. There are other ideas on how to implement this functionality, but I’m not sure what will be more effective. And my name is Tema, most of my life I ran around with a pistol, and now I got into development. But I’m too lazy to write about any complex projects. If so, I will be glad to see you in my telegram or banogram.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *