Skip to content

Commit 9d34382

Browse files
committed
init
0 parents  commit 9d34382

9 files changed

Lines changed: 15958 additions & 0 deletions

File tree

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node_modules
2+
.env
3+
coverage
4+
coverage.json
5+
typechain
6+
typechain-types
7+
8+
# Hardhat files
9+
cache
10+
artifacts
11+

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Sample Hardhat Project
2+
3+
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.
4+
5+
Try running some of the following tasks:
6+
7+
```shell
8+
npx hardhat help
9+
npx hardhat test
10+
REPORT_GAS=true npx hardhat test
11+
npx hardhat node
12+
npx hardhat run scripts/deploy.js
13+
```

contracts/MyGovernor.sol

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.9;
3+
4+
import "@openzeppelin/contracts/governance/Governor.sol";
5+
import "@openzeppelin/contracts/governance/extensions/GovernorSettings.sol";
6+
import "@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol";
7+
import "@openzeppelin/contracts/governance/extensions/GovernorVotes.sol";
8+
import "@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol";
9+
10+
contract MyGovernor is Governor, GovernorSettings, GovernorCountingSimple, GovernorVotes, GovernorVotesQuorumFraction {
11+
constructor(IVotes _token)
12+
Governor("MyGovernor")
13+
GovernorSettings(1, 1, 0)
14+
GovernorVotes(_token)
15+
GovernorVotesQuorumFraction(4)
16+
{}
17+
18+
// The following functions are overrides required by Solidity.
19+
20+
function votingDelay()
21+
public
22+
view
23+
override(IGovernor, GovernorSettings)
24+
returns (uint256)
25+
{
26+
return super.votingDelay();
27+
}
28+
29+
function votingPeriod()
30+
public
31+
view
32+
override(IGovernor, GovernorSettings)
33+
returns (uint256)
34+
{
35+
return super.votingPeriod();
36+
}
37+
38+
function quorum(uint256 blockNumber)
39+
public
40+
view
41+
override(IGovernor, GovernorVotesQuorumFraction)
42+
returns (uint256)
43+
{
44+
return super.quorum(blockNumber);
45+
}
46+
47+
function proposalThreshold()
48+
public
49+
view
50+
override(Governor, GovernorSettings)
51+
returns (uint256)
52+
{
53+
return super.proposalThreshold();
54+
}
55+
}

contracts/MyToken.sol

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.9;
3+
4+
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5+
import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";
6+
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";
7+
8+
contract MyToken is ERC20, ERC20Permit, ERC20Votes {
9+
address governor;
10+
11+
constructor(address _governor) ERC20("MyToken", "MTK") ERC20Permit("MyToken") {
12+
governor = _governor;
13+
_mint(msg.sender, 10000e18);
14+
}
15+
16+
function mint(address to, uint256 amount) external {
17+
require(governor == msg.sender);
18+
_mint(to, amount);
19+
}
20+
21+
// The functions below are overrides required by Solidity.
22+
23+
function _afterTokenTransfer(address from, address to, uint256 amount)
24+
internal
25+
override(ERC20, ERC20Votes)
26+
{
27+
super._afterTokenTransfer(from, to, amount);
28+
}
29+
30+
function _mint(address to, uint256 amount)
31+
internal
32+
override(ERC20, ERC20Votes)
33+
{
34+
super._mint(to, amount);
35+
}
36+
37+
function _burn(address account, uint256 amount)
38+
internal
39+
override(ERC20, ERC20Votes)
40+
{
41+
super._burn(account, amount);
42+
}
43+
}

hardhat.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require("@nomicfoundation/hardhat-toolbox");
2+
3+
/** @type import('hardhat/config').HardhatUserConfig */
4+
module.exports = {
5+
solidity: "0.8.17",
6+
};

0 commit comments

Comments
 (0)