Skip to content

Commit 43fdcff

Browse files
chore: add exercise solidity files
1 parent 6b28067 commit 43fdcff

File tree

5 files changed

+613
-0
lines changed

5 files changed

+613
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import {ERC20} from "./level-utils/ERC20.sol";
5+
6+
contract NaughtCoin is ERC20 {
7+
// string public constant name = 'NaughtCoin';
8+
// string public constant symbol = '0x0' -> 'NTC';
9+
// uint public constant decimals = 18;
10+
uint256 public timeLock = block.timestamp + 10 * 365 days;
11+
uint256 public INITIAL_SUPPLY;
12+
address public player;
13+
14+
// Note that the original symbol is changed from 0x0 to NTC
15+
// This is caused by https://github.com/crytic/echidna/issues/909
16+
constructor(address _player) ERC20("NaughtCoin", "NTC") {
17+
player = _player;
18+
INITIAL_SUPPLY = 1000000 * (10**uint256(decimals()));
19+
// _totalSupply = INITIAL_SUPPLY;
20+
// _balances[player] = INITIAL_SUPPLY;
21+
_mint(player, INITIAL_SUPPLY);
22+
emit Transfer(address(0), player, INITIAL_SUPPLY);
23+
}
24+
25+
function transfer(address _to, uint256 _value)
26+
public
27+
override
28+
lockTokens
29+
returns (bool)
30+
{
31+
super.transfer(_to, _value);
32+
}
33+
34+
// Prevent the initial owner from transferring tokens until the timelock has passed
35+
modifier lockTokens() {
36+
if (msg.sender == player) {
37+
require(block.timestamp > timeLock);
38+
_;
39+
} else {
40+
_;
41+
}
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: MIT
2+
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
3+
4+
pragma solidity ^0.8.0;
5+
6+
/**
7+
* @dev Provides information about the current execution context, including the
8+
* sender of the transaction and its data. While these are generally available
9+
* via msg.sender and msg.data, they should not be accessed in such a direct
10+
* manner, since when dealing with meta-transactions the account sending and
11+
* paying for execution may not be the actual sender (as far as an application
12+
* is concerned).
13+
*
14+
* This contract is only required for intermediate, library-like contracts.
15+
*/
16+
abstract contract Context {
17+
function _msgSender() internal view virtual returns (address) {
18+
return msg.sender;
19+
}
20+
21+
function _msgData() internal view virtual returns (bytes calldata) {
22+
return msg.data;
23+
}
24+
}

0 commit comments

Comments
 (0)