Level 1 Noob Hacker
Ethernaut 05 Token
0 / 100 EXP 100 EXP to Junior Hacker
0%

Challenge 5 / Ethernaut

Token

Goal

  1. Increase the player's token balance beyond the initial allocation.

Your task

Read Token.sol, then complete Exploit.s.sol.

:~/targets/ethernaut-token$
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

contract Token {
    mapping(address => uint256) balances;
    uint256 public totalSupply;

    constructor(uint256 _initialSupply) public {
        balances[msg.sender] = totalSupply = _initialSupply;
    }

    function transfer(address _to, uint256 _value) public returns (bool) {
        require(balances[msg.sender] - _value >= 0);
        balances[msg.sender] -= _value;
        balances[_to] += _value;
        return true;
    }

    function balanceOf(address _owner) public view returns (uint256 balance) {
        return balances[_owner];
    }
}