0

Hello Solidity Expert,

I am working on Ethernaut challenge 8 called Vault: Ethernaut See the contract code at the end of this post.

I feel I solved the challenge but for some reason I cannot open the vault.

Here are the steps I have taken.

  1. I found the contract on Rinkeby and extracted the Bytes32 component from the constructor. Contract 0x5F694fcf2767ff28c0907eEAF6b705E8456a3665

enter image description here

  1. I entered the Bytes32 component into the parameter of the unlock function but the vault does not unlock?

enter image description here

I am not certain what I did wrong here. In my mind the Vault should open. Any hints or insights are welcome.

Thank you.

pragma solidity ^0.6.0;

contract Vault {
  bool public locked;
  bytes32 private password;

  constructor(bytes32 _password) public {
    locked = true;
    password = _password;
  }

  function unlock(bytes32 _password) public {
    if (password == _password) {
      locked = false;
    }
  }
}
1
  • I used web3.eth.getStorageAt("0x5F694fcf2767ff28c0907eEAF6b705E8456a3665", 1, console.log) to get access to password and the result was 0x412076657279207374726f6e67207365637265742070617373776f7264203a29 which unlocked the Vault but I am not sure why this differs from the data in the constructor as noted on Rinkeby. – Picard78 Dec 9 '20 at 11:47
1

The issue is that the transaction highlighted is to a 'factory' contract that deploys the vault. It isn't a direct call to the constructor.

To determine the constructor parameter you can to examine the internal transaction that creates the contract.

At CREATE's input end the same parameter you found appears

412076657279207374726f6e67207365637265742070617373776f7264203a29

1
  • Once again thank you Ismael. – Picard78 Dec 10 '20 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.