Cover photo

Automation of EGLD hunting in Guarda!

Literally a few hours ago I came across a very nice action organized by Guarda.

On their platform, they added support for a new blockchain, which is Elrond, and decided to give away 3 ELGDs for simply finding boxes and solving puzzles.

So I took action of course. I have a problem solving puzzles so I started to wonder how I can automate the process so that everything is done for me.

Many people will think that this is quite a complication and exaggerated. However, I saw an opportunity to learn and find a solution that is unique.

If you want, you can look directly at the repository. However, I recommend reading my adventure!

https://github.com/0ri2N/egldHunter

A small plan was created:

  • Finding all the puzzles on the website.

  • Checking all possible combinations of a given mnemonic.

  • Generate a private key for each combination.

  • Generating a private address from the key.

  • Checking the address on the blockchain.

Riddles

From that which comes within itself, it builds its table on my shelf

know family culture begin bring human foam enter $xxx switch change mirror
know family culture begin bring human foam enter $xxx switch change mirror

https://guarda.com/coins/elrond-wallet/?utm_medium=social&utm_source=twitter&utm_campaign=egld-hunt

_ _ _ _ _ for the Dwarf-lords in their halls of stone

purity wire please better mixture antenna betray $xxx dutch hen traffic glow
purity wire please better mixture antenna betray $xxx dutch hen traffic glow

https://guarda.com/buy-elrond/?utm_medium=social&utm_source=twitter&utm_campaign=egld-hunt

She's a 10 but needs a crypto top up first

battle brave come phone bachelor subway unknown media claw venture check $xxx
battle brave come phone bachelor subway unknown media claw venture check $xxx

https://guarda.com/coins/?utm_medium=social&utm_source=twitter&utm_campaign=egld-hunt

Coding

The time has come for coding and automation. It's 1am but that's okay. I feel like I have to finish this.

Permutations

I did some research on GitHub and decided that the bip39 library from bitcoinjs was perfect for checking all combinations.

https://github.com/bitcoinjs/bip39

import bip from 'bip39';

const riddleSolver = (mnemonic) => {
  bip.wordlists.english.forEach(async (word) => {
    const mnemonicTest = mnemonic.replace('$word', word)
    const mnemonicValid = bip.validateMnemonic(mnemonicTest);
    
    if (mnemonicValid) { 
      ...
    }
  })
}

So I created the prototype for the code.

Keys

Typically, each blockchain has an SDK in various forms. So I searched the Elrond documentation and found some snippets and a library that I need.

https://github.com/ElrondNetwork/elrond-core-js

And then I updated the code to create private keys.

import bip from 'bip39';
import core from "@elrondnetwork/elrond-core-js";

const riddleSolver = (mnemonic) => {
  bip.wordlists.english.forEach(async (word) => {
    const mnemonicTest = mnemonic.replace('$word', word)
    const mnemonicValid = bip.validateMnemonic(mnemonicTest);
    
    if (mnemonicValid) { 
      let account = new core.account();

      await account.loadFromMnemonic(mnemonicTest)

      console.log(word, account.address())
    }
  })
}

Balance

The last thing left to do is check if any transactions were made on the given private key. I searched the documentation again and used the available explorer API.

Of course, I also installed the required library for requests

import bip from 'bip39';
import core from "@elrondnetwork/elrond-core-js";

const riddleSolver = (mnemonic) => {
  bip.wordlists.english.forEach(async (word) => {
    const mnemonicTest = mnemonic.replace('$word', word)
    const mnemonicValid = bip.validateMnemonic(mnemonicTest);
    
    if (mnemonicValid) { 
      let account = new core.account();

      await account.loadFromMnemonic(mnemonicTest)

      const { data } = await $fetch(`https://gateway.elrond.com/address/${account.address()}/transactions`);
  
      console.log(word, account.address(), data.transactions)

      if (data.transactions.length > 0) {
        console.log(`${word} is the answer!`)

        return;
      }
    }
  })
}

And calling functions

riddleSolver('know family culture begin bring human foam enter $word switch change mirror') // From that which comes within itself, it builds its table on my shelf
riddleSolver('purity wire please better mixture antenna betray $word dutch hen traffic glow') // _ _ _ _ _ for the Dwarf-lords in their halls of stone
riddleSolver('battle brave come phone bachelor subway unknown media claw venture check $word') // She's a 10 but needs a crypto top up first

Final

The script works beautifully. Everything is as it should be. All the riddles were answered in seconds.

Unfortunately, someone beat me, and although I solved the puzzles in a quite unique way, at the time of getting the answer the balances on each account were zero.

Nevertheless, I had a lot of fun doing it and learned some new things.

Final code looks like this:

post image

And of course it's also available on GitHub:

https://github.com/0ri2N/egldHunter

Thanks for reading!