Skip to content

Commit 34f3e80

Browse files
committed
Implement Chip ERC20 token and Roulette game base
Replaces AccessControl with Ownable, Pausable, and ERC20 in Chip.sol, adding mint, burn, blacklist, and pause functionality. Introduces a new Roulette.sol contract with Chainlink VRF integration, round management, and initial configuration for a roulette game.
1 parent aca0d31 commit 34f3e80

File tree

2 files changed

+96
-3
lines changed

2 files changed

+96
-3
lines changed

src/Chip.sol

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,64 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.24;
33

4-
import "@openzeppelin/contracts/access/AccessControl.sol";
4+
import "@openzeppelin/contracts/access/Ownable.sol";
5+
import "@openzeppelin/contracts/utils/Pausable.sol";
6+
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
57

6-
contract Chip{
7-
constructor(){
8+
contract Chip is ERC20, Ownable, Pausable {
9+
mapping(address => bool) blacklist;
810

11+
event Blacklisted(address indexed account, bool isBlacklisted);
12+
event Minted(address indexed to, uint256 amount);
13+
event Burned(address indexed from, uint256 amount);
14+
15+
modifier notBlacklisted(address account) {
16+
require(!blacklist[account], "CHIP: address is blacklisted");
17+
_;
18+
}
19+
20+
constructor(
21+
string memory _name,
22+
string memory _symbol,
23+
address initialOwner
24+
) ERC20(_name, _symbol) Ownable(initialOwner) {}
25+
26+
function mint(address to, uint256 amount) external onlyOwner {
27+
_mint(to, amount);
28+
emit Minted(to, amount);
29+
}
30+
31+
function burn(address from, uint256 amount) external onlyOwner {
32+
_burn(from, amount);
33+
emit Burned(from, amount);
34+
}
35+
36+
function _update(
37+
address to,
38+
address from,
39+
uint256 value
40+
) internal override whenNotPaused notBlacklisted(from) notBlacklisted(to) {
41+
super._update(from, to, value);
42+
}
43+
44+
function setBlacklist(address account, bool value) external onlyOwner {
45+
blacklist[account] = value;
46+
emit Blacklisted(account, value);
47+
}
48+
49+
function unpause() external onlyOwner {
50+
_unpause();
51+
}
52+
53+
function pause() external onlyOwner {
54+
_pause();
55+
}
56+
57+
receive() external payable {
58+
revert("No ether accepted");
59+
}
60+
61+
fallback() external payable {
62+
revert("No ether accepted");
963
}
1064
}

src/games/Roulette.sol

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.30;
3+
4+
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
5+
import "@openzeppelin/contracts/access/Ownable.sol";
6+
import "@chainlink/contracts/src/v0.8/vrf/VRFConsumerBaseV2.sol";
7+
import "@chainlink/contracts/src/v0.8/vrf/interfaces/VRFCoordinatorV2Interface.sol";
8+
9+
contract Roulette is Ownable, ReentrancyGuard, VRFConsumerBaseV2 {
10+
VRFCoordinatorV2Interface public coordinator;
11+
bytes32 public keyHash;
12+
uint64 public subId;
13+
uint32 public callbackGasLimit = 250_000;
14+
uint16 public reqConfirmations = 3;
15+
16+
uint256 public ticketPrice;
17+
uint256 public creatorFeeBase;
18+
uint256 public currentRoundId;
19+
20+
constructor(
21+
uint256 _ticketPrice,
22+
uint256 _creatorFeeBase,
23+
address _vrfCoordinator,
24+
bytes32 _keyHash,
25+
uint64 _subscriptionId
26+
) Ownable(msg.sender) VRFConsumerBaseV2(_vrfCoordinator) {
27+
require(_creatorFeeBase <= 2000, "creator fee too high");
28+
ticketPrice = _ticketPrice;
29+
creatorFeeBase = _creatorFeeBase;
30+
31+
coordinator = VRFCoordinatorV2Interface(_vrfCoordinator);
32+
keyHash = _keyHash;
33+
subId = _subscriptionId;
34+
35+
_startNewRound();
36+
}
37+
38+
function _startNewRound() internal {}
39+
}

0 commit comments

Comments
 (0)