Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Decode constructor arguments in solidity

I playing Ethernaut Level 8. The goal is to get access to the private password state variable and unlock the contract.

I know one could use await contract.unlock(await web3.eth.getStorageAt(contract.address, 1));, but I want to find the password decoding the input data of the contract creation. Here is the contract.

I tried await contract.unlock("f94b476063b6379a3c8b6c836efb8b3e10ede188") but that didn't work.

// SPDX-License-Identifier: MIT
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;
    }
  }
}
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If the contract is verified, it is possible to go to the contract section, scroll down to Contract Creation Code and read the last 32 bytes (64 characters of the bytecode) which in this case is 0x412076657279207374726f6e67207365637265742070617373776f7264203a29.

it is 32 bytes because the password state variable is declared like this:

bytes32 private password;

To solve the challenge type:

await contract.unlock("0x412076657279207374726f6e67207365637265742070617373776f7264203a29")
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!