Axie Infinity Auto-Battles

Sean Schulte
4 min readMay 7, 2019

--

Axie Infinity is a blockchain game “about collecting and raising fantasy creatures called Axie”. The basic premise is that you collect these cute little monsters and breed them together to make more, hopefully better, cute little monsters.

This is Axie #29263

After breeding, each Axie has a cooldown time before they can breed again. Just like CryptoKitties! Except, unlike in that game, the cooldown isn’t based on time, but rather on “experience points”. And you get those points by sending your Axies off to battle someone else’s in the arena. (That’s another major difference between this game and CryptoKitties. There’s actually something to do in Axie Infinity, which makes it quite a bit more compelling.)

Each Axie can battle once every four hours, and can stack up to three ready battles. What that means is that if you wait longer than 12 hours to come back and battle your Axies, you’re wasting opportunities to gain experience points.

I don’t know about you, but I don’t have time to log on twice a day to do that (especially since I just had a baby), but I do want to play this game and breed the Axies together. Whatever am I to do?

Enter axie, the program I wrote to send my teams to battle automatically as soon as they’re ready. Now I can gain experience points all day long, whether I log in and play or not.

It has a bunch of features:

axie commands

But only a few of those really matter for its primary purpose: auto-battling.

Let’s see a list of my teams:

axie teams

What we see in that list is all seven of my teams, whether they’re ready to battle, and how long many minutes it’ll be until they’re ready. As we can see here, none of them are currently ready (because they’ve been auto-battling!), but “farm system” will be ready in 18 minutes.

We can take a look at the Axies on a single team:

axie team

We can send all the teams that are ready for it off to battle:

axie start

It prints the number of teams that were sent to battle. So it was 0 this time, because nothing happened. But if I run this in 18 minutes, it’ll say 1 instead.

The program needs a config file, axie.conf, that contains your Ethereum address (get that from MetaMask), and your Axie Infinity bearer token (get that from the Axie Infinity website: open the JS console, navigate to Application, then Local Storage … it’ll be stored in a key that looks like axieinfinity.<your-eth-addr>.auth). That bearer token lets you work with the axieinfinity.com API, but it does not let you spend money on the blockchain; so keep it safe from prying eyes, but it’s not the single most secret thing in your life.

With this script, if you run start periodically, your Axies will always do their maximally allotted six battles per day and you’ll never waste any activity points. You might do it with a cron job … but I only own a Chromebook that isn’t on 24/7, so that isn’t going to cut it.

So in addition to the CLI interface, it also runs in AWS Lambda via the handler function in the axie.aws namespace. That’s where I run mine. I just need to set the two environment variables in Lambda, ETH_ADDR and TOKEN, upload the JAR, and then set up a CloudWatch Event to trigger it every hour. (You could go more often than that, but I didn’t want to use up too much Lambda time.)

And that’s it! With that up and running, your Axies will battle on their own, freeing up all the time you’d otherwise have to spend managing their experience point progress. And don’t worry, you can still watch all the results of your matches in the arena, so you still end up with all the fun of doing battle, just without the time investment.

If that’s valuable to you, and you have the ETH to spare, I wouldn’t mind if you dropped some into 0x560EBafD8dB62cbdB44B50539d65b48072b98277 … it’d help me buy some more of these Axies.

--

--

Sean Schulte
Sean Schulte

Responses (2)