Privacy preferences

Choose separately whether we may use analytics and advertising measurement. Both stay off unless you turn them on. You can change these choices any time.

All challenges

Challenge 15

tx.origin Misuse

HighUpgradeable contracts

Challenge

This wallet is intended to work behind a proxy. Review how its admin is initialized and protected.

Starter code

// Intended to be upgradeable via proxy
pragma solidity ^0.8.0;

contract AdminWallet {
  address public admin;

  constructor() {
    admin = msg.sender;
  }

  function withdraw(address payable to, uint256 amount) public {
    require(msg.sender == admin, "Not authorized");
    to.transfer(amount);
  }

  receive() external payable {}
}
Show hint

Proxy storage is not initialized by the implementation contract's constructor. Use a protected initializer.