DEV Community

Cover image for Axie Infinity - Breaking the market with bots
mdichtler
mdichtler

Posted on

Axie Infinity - Breaking the market with bots

As many of us know, Axie Infinity has quickly risen to become the #1 NFT powered game in the world, with that, and ever growing market reaching $670M worth of transactions in the past month, it is also a great playground for developers to learn and practice new skills.

In this article, will go over one of my github repos, and learn how to setup a bot to scrape data from axie.zone (community website providing leaderboard information) and in combination with axie infinity's graphql API, find the Axies played by the top 100 players on the marketplace.

While we likely are not able to find the exact Axies (same ID), we can find Axies with the same class, as well as parts, that make them practically identical in combat, allowing us to recreate the best teams on budget.

If you would like to support development of this project and future tutorials, feel free to donate using Ko-Fi.
ko-fi

Video Tutorial

IMAGE ALT TEXT HERE

Instructions

  1. Clone the Github repo

  2. Create a Firebase account & Project

  3. Enable Firestore

  4. (optional) Enable Authentication using Google.

  5. (optional) Update security rules to enable any authenticated user to read data (this setup is assuming usage with the provided Web GUI, if used within your own project tailor your security rules to the given project).

Example:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read: if (request.auth.uid != null);
    }
  }
}
Enter fullscreen mode Exit fullscreen mode
  1. Within Firebase, navigate to Project Settings > Service Accounts, select Python and click on "Generate new private key"

  2. Rename the file to serviceAccountKey.json and import it into the project directory ./database/serviceAccountKey.json (this file is included in .gitignore)

  3. Create virtual environment

  4. Use the package manager pip to install dependencies from requirements.txt file.

pip3 install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode
  1. Run main.py, after script finishes, your data will be loaded into two collections, leaderboards (top 100 players at the runtime, multiple documents) and on_sale (all axies matching one of the most used axies by top 100 players, including their price, which top 100 player it matches, ID, class & parts, see example json below).

Example JSON:

{
    "player_rank": 44,
    "image": "https://storage.googleapis.com/assets.axieinfinity.com/axies/7751721/axie/axie-full-transparent.png",
    "time": {
        "seconds": 1635428026,
        "nanoseconds": 751095000
    },
    "axie": {
        "class": "Bird",
        "player_mmr": "3312",
        "player_rank": 44,
        "axie_zone_score": "Excellent",
        "title": "",
        "matching_player": "#44 youtube.com de-hi games 3312 0 0%",
        "id": "7751721",
        "__typename": "Axie",
        "name": "Axie #7751721",
        "breedCount": 3,
        "battleInfo": {
            "banned": false,
            "__typename": "AxieBattleInfo"
        },
        "parts": [
            {
                "name": "Mavis",
                "specialGenes": null,
                "id": "eyes-mavis",
                "class": "Bird",
                "__typename": "AxiePart",
                "type": "Eyes"
            },
            {
                "type": "Ears",
                "specialGenes": null,
                "class": "Bird",
                "id": "ears-peace-maker",
                "__typename": "AxiePart",
                "name": "Peace Maker"
            },
            {
                "name": "Pigeon Post",
                "__typename": "AxiePart",
                "specialGenes": null,
                "id": "back-pigeon-post",
                "class": "Bird",
                "type": "Back"
            },
            {
                "specialGenes": null,
                "type": "Mouth",
                "__typename": "AxiePart",
                "class": "Bug",
                "id": "mouth-cute-bunny",
                "name": "Cute Bunny"
            },
            {
                "type": "Horn",
                "specialGenes": null,
                "class": "Bird",
                "name": "Eggshell",
                "id": "horn-eggshell",
                "__typename": "AxiePart"
            },
            {
                "id": "tail-post-fight",
                "class": "Bird",
                "specialGenes": null,
                "type": "Tail",
                "name": "Post Fight",
                "__typename": "AxiePart"
            }
        ],
        "stage": 4,
        "image": "https://storage.googleapis.com/assets.axieinfinity.com/axies/7751721/axie/axie-full-transparent.png",
        "player_url": "https://axie.zone/profile?ron_addr=0x1b246e446336f55b4150294ccd39693fb4a8aa9b",
        "matching_axie_name": "obasan",
        "auction": {
            "currentPrice": "40000000000000000",
            "__typename": "Auction",
            "currentPriceUSD": "165.82"
        }
    },
    "currentPriceUSD": 165.82,
    "id": "7751721",
    "class": "Bird"
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)