Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lacasian committed Jan 16, 2023
0 parents commit bb574df
Show file tree
Hide file tree
Showing 14 changed files with 24,475 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false
[{Makefile,**.mk}]
# Use tabs for indentation (Makefiles require tabs)
indent_style = tab
6 changes: 6 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TESTNET_PRIVATE_KEY=0x1234
MAINNET_PRIVATE_KEY=0x1234
ETHERSCAN_API_KEY=""
INFURA_API_KEY=abcdef
REPORT_GAS=true
CMC_API_KEY=""
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts

.idea/
**/.openzeppelin/unknown-*.json
yarn-error.log
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
3 changes: 3 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
skipFiles: ["mocks", "interfaces"],
};
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Sample Hardhat Project

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.

Try running some of the following tasks:

```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.ts
```
65 changes: 65 additions & 0 deletions abi/Lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[
{
"inputs": [
{
"internalType": "uint256",
"name": "_unlockTime",
"type": "uint256"
}
],
"stateMutability": "payable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "when",
"type": "uint256"
}
],
"name": "Withdrawal",
"type": "event"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address payable",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "unlockTime",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
34 changes: 34 additions & 0 deletions contracts/Lock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

// Uncomment this line to use console.log
// import "hardhat/console.sol";

contract Lock {
uint public unlockTime;
address payable public owner;

event Withdrawal(uint amount, uint when);

constructor(uint _unlockTime) payable {
require(
block.timestamp < _unlockTime,
"Unlock time should be in the future"
);

unlockTime = _unlockTime;
owner = payable(msg.sender);
}

function withdraw() public {
// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal
// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);

require(block.timestamp >= unlockTime, "You can't withdraw yet");
require(msg.sender == owner, "You aren't the owner");

emit Withdrawal(address(this).balance, block.timestamp);

owner.transfer(address(this).balance);
}
}
73 changes: 73 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("dotenv").config({ path: "./.env" });

import {HardhatUserConfig} from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "hardhat-contract-sizer";
import "hardhat-abi-exporter";
import "@dmob/hardhat-test-helpers";
import "@openzeppelin/hardhat-upgrades";

const config: HardhatUserConfig = {
solidity: {
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
runs: 2,
}
}
},

networks: {
hardhat: {
accounts: {
mnemonic:
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
},
},
goerli: {
chainId: 5,
url: `${process.env.RPC_URL || `https://goerli.infura.io/v3/${process.env.INFURA_API_KEY}`}`,
accounts: [process.env.TESTNET_PRIVATE_KEY || ""],
gas: "auto",
gasPrice: "auto",
gasMultiplier: 1.2,
},
mainnet: {
chainId: 1,
url: `${process.env.RPC_URL || `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`}`,
accounts: [process.env.MAINNET_PRIVATE_KEY || ""],
gas: "auto",
gasPrice: "auto",
gasMultiplier: 1.2,
},
},

etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},

contractSizer: {
alphaSort: true,
runOnCompile: false,
disambiguatePaths: false,
},

gasReporter: {
currency: "USD",
gasPrice: 51,
enabled: process.env.REPORT_GAS === "true",
coinmarketcap: process.env.CMC_API_KEY,
},

abiExporter: {
runOnCompile: true,
only: [":Lock$"],
clear: true,
flat: true,
spacing: 4,
},
};

export default config;
Loading

0 comments on commit bb574df

Please sign in to comment.