Crabada is a fully decentralized play-and-earn idle game. Looting is a mission in the game, and it is more profitable than others. But there was an intense competition between player and bots to loot open Mines, So manuel looting was almost impossible. Therefore, we developed this bot to loot open mines very quickly. It interacts directly with Crabada Smart Contract.
It worked very successfully until anti bot patch. Now there is recaptcha to block bots, and it seems working well. We decided to share this repo with public. We hope that it can be useful someone who curious.
There are two different looting mode.
Init phase:
- It gets your available team's info from CrabadaApi or smart contract(both of can be used).
Subscribing phase:
- Listen StartGame(opened mine) events from smart contract.
- Look Mine's team info from cache if cache is enabled(older versions gets team's info from smart contract, but it caused extra i/o and slowness)
- If looting is possible(it means your team is stronger than miner's team), it call attack function of crabada smart contract.
- Continue this process until team is locked with looting mission.After context is cancelled all goroutines exits and stop script.
We realized GameId(or mineId) is incremental number. When a player opens a mine, newGameId is always one more of last gameId. To get ahead of other bots, we decided to loot directly game Id without waiting StartGame Event(It is like a brute force attack).
Init phase:
- It gets your available team info from CrabadaApi or smart contract(both of can be used).
- Get last gameId from CrabadaApi.
Iteration phase:
- Increase gameId by one.
- Get GameInfo(gameId) from contract, if game is available, continue next step.
- Look Mine's(Game) team info from cache if cache is enabled.
- If it is looting possible, it calls attack function of smart contract.
- Continue this process until team is locked with looting mission. After context is cancelled all goroutines exits and stop script.
It was a very excitement process for us. We have tried many things to beat others bots. A few of them :
- Using custom Avalance node to speed up Transactions.
- To loot only players who usually doesn't reinforce.
- Tuning gasPrice, gasTip and GasFeeCap(LegacyTx or eip-1559) to speed up Transactions.
- Changing server geolocation to decrease network latency.
- Subscribing multiple node at same time to listen StarGame event.
- Management transactions' nonce by bot.
- There is a load balancer in front of api.avax.network. It blocks us when we request too many. To bypass it, we splited contract three diffrent instance: CallerContract, TransactorContract and FiltererContract. Each of them are using diffrent node client so that way we reduced request traffic which is going to one node.
- To limit cost of transactions' fee, we added different thresholds to stop script.
Not: We found Crabada contract abi inside of javascript files(crabada.com)
go install
crabada-bot -h
crabada-bot reload -h
crabada-bot reload -c 1
crabada-bot loot -h
crabada-bot loot --key <privateKey> --gasTip <GasTip> --cache
crabada-bot loot-iterate -h
crabada-bot loot-iterate --key <privateKey> --gasTip <GasTip> --cache