Skip to content

Instantly share code, notes, and snippets.

@alexvandesande
Last active October 12, 2017 05:42
Show Gist options
  • Save alexvandesande/1c48dfbb330d67aeb79bc5b1103c6abe to your computer and use it in GitHub Desktop.
Save alexvandesande/1c48dfbb330d67aeb79bc5b1103c6abe to your computer and use it in GitHub Desktop.
How to recover a bid on ENS if you still have the master salt

How to recover a lost a ENS bid if you still have the secret

  1. Download your bid backup and open it in a text editor. You can paste the code on a service like this to make it more readable: https://jsonformatter.curiousconcept.com

  2. Search for the name of your bid to check it's not there. If it's not then at the top of your file you'll find something like this:

{
   "About":{
      "backupDate":"2017-06-17T15:34:23.014Z",
      "mastersalt":"Oompa Loompa Doo"
   },
   "MyBids":[
      {
         "_id":"W43yyoydBPLW7w2Lx",
         "date":1497625514274,
         "mastersalt":"Oompa Loompa Doo",
         "depositAmount":"1000000000000000000",
         "name":"name-that-i-want",
         "hash":"0xxxxxxx",
         "value":"1000000000000000000",
         "owner":"0xxxxxxxx",
         "secret":"b6ccb98688436465ab149bcf2efa794669c81195b9eda34dcfe4447a384d06f8",
         "hexSecret":"0x5b2815e400e3c8c99354cc337daf9acbc83612077fd36fbc7b1e9e5462055fc6",
         "shaBid":"0x204585248a2501796682aafdaa9903b9f27b63ebd61d72002cdf7f4894eb73f1"
      },
  1. Search for all instances of "mastersalt" and see if they are all the same. If they are not, you need to repeat this step with all of them. If you have no "mastersalt" set, then you probably won't be able to recover

  2. Duplicate the last item between the last { and }, and modify it to your details:

  • _id can be any random string
  • date and mastersalt leave it untouched
  • value the amount you bid, ignoring any extra amount set, in wei.To convert ether to wei, use this handy tool. You must remember this.
  • depositAmount the total amount you deposited, ignoring any extra amount set, in wei. To convert ether to wei, use this handy tool. If you don't remember this, use the same as value
  • owner the public address you used to send the transaction. You must know this.
  • hash use this keccak-256 tool and use the name you want (lowercase, no .eth) as input. Add 0x to the beginning of the value it outputs if it doesn't start with one.
  • secret take your mastersalt, plus the name you want and put it through keccak-256 tool. In the above example it would be "Oompa Loompa Dooname-that-i-want"
  • hexSecret take the secret, put it through keccak-256 again and add a "0x" at the beginning.
  • shaBid open ENS registar on etherscan tab, "read contract" and find the "shaBid" function. Add the values of hash, owner, and value. Use the "hexSecret" you obtained as the salt.
  1. On the same page as etherscan, use the "sealedBids" function and use the "owner" and the "shaBid" you just got from the step above. If the result is an address then bingo, you found the combination. If it's 0x000.. then you either have the wrong details, or that bid has been revealed already

  2. Once you found it (use the other bids on your json file to check you did everything correctly!) then add that bid to your list, save it and import on your registrar dapp. The reveal button should appear. If that doesn't work, you can also use https://www.myetherwallet.com/ens tool and use hexSecret as the secret.

Good luck!

@nrhirsch
Copy link

nrhirsch commented Jul 6, 2017

Importing a bid created in MEW into ENS and vice versa
The fields of MEW and ENS appear to be different but in fact they have different names and styles for the same thing.
Here is a comparison of the two JSON files and how they compare to each other:

BELOW IS A MEW JSON FILE (push enter, ie. add a line after each “,” to get it to look like this) :

“name”:same as name in ENS,
“nameSHA3”:”0x + keccak-256 of name”, same as “hash” in ENS=identical bud different labels
“owner”:same as owner in ENS, identical
“value”:same as name in ENS, identical
“secret”: same as secret in ENS, identical
“secretSHA3”: 0x + keccak-256 of “secret above”, same as hexSecret in ENS, identical but different label

BELOW IS AN ENS JSON FILE (push enter, ie. add a line after each “,” to get it to look like this) :

“_id”: unique to ENS, pick one from an existing ENS JSON file and modify it a bit
“date”: unique to ENS, pick one from and existing ENS JSON file and modify it a bit.
“mastersalt”: unique to ENS, remove this line.
“depositAmount”: unique to ENS, use same as value below,
“name”: same as name in MEW,
“hash”: “0x + keccak-256 of name”, identical label in MEW
“value”: same as value in MEW, identical label in MEW
“owner”: same as owner in MEW, identical label in MEW
“secret”: same as 3 word secret in MEW, 0x + keccak-256 of mastersalt+name
“hexSecret”: same as secretSHA3 in MEW, 0x + keccak-256 of secret above
“shaBid”: unique to ENS, calculate using Method Response of Line 2 in ReadContract: https://etherscan.io/address/0x6090a6e47849629b7245dfa1ca21d94cd15878ef#readContract
“revealed”: unique to ENS,
“revealing”: unique to ENS

note: spaces after : in ENS, no space after “ in MEW

The only thing you need to “calculate” is the shaBid field which is calculated and checked as being valid by using Alex Vandesande’s explanation above.

@meta27
Copy link

meta27 commented Jul 6, 2017

Thank you so mucho for your great help

@nrhirsch
Copy link

imToken:
with imToken, the app for smartphones by ConsenLabs co, ltd, it’s also easy to create bids there and import bids created there into ENS. First you must import your wallet which I did using the Metamask mnemonic (can also use private key or keystore). You can import your existing bids by copy and pasting the JSON file into the import window.
Bid creation: In the case of imToken, you create your own secret by typing it in the imToken app. so your inputs are simply, name.eth, the secret you create and the Bid amount in ETH (haven’t tried disguise amount also available). If you do a keccak-256 of the secret, and then add 0x in front, you’ll have your hexsecret. You can convert your ETH to wei in order and keccak-256 the name to hash to transfer the bid to registrar.ens.domains but you don’t need to do that if you have registrar.ens.domains do it for you by starting, downloading but rejecting the bid. Start the same bid in registrar.ens.domains with same amount and name and download the bids. Download the bid BEFORE you then REJECT the bid in Metamask. You will have the information in a pending are of the JSON file that you will modify and move up to the bid section. You won’t lose any gwei and no ETH will be subtraced from your wallet if you REJECT. Looking at the JSON file you’ll have almost all the information necessary to finish replicating/creating your bid. You can use the id (move it to the top for consistency), date, name, hash, value, and owner found in the bottom pending bids area of the JSON file, substitute the secret (from imToken), hexsecret (keccak-256 of secret). You don’t need to include revealed, or revealing or shabid lines. They will all be automagically added after you move the lines from the pending area up to the bid area in the JSON file and import that file. The shabid can be calculated and added if you wish by using Alex’s method on the read contract link. It will match what registrar.ens.domains calculates and adds to the JSON file for that bid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment