-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
44,995 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALCHEMY_API_KEY= | ||
ROPSTEN_PRIVATE_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
node_modules | ||
.env | ||
|
||
#Hardhat files | ||
cache | ||
artifacts | ||
dist | ||
typechain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"printWidth": 120, | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"singleQuote": false, | ||
"bracketSpacing": false, | ||
"explicitTypes": "always", | ||
"semi": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
pragma solidity ^0.8.7; | ||
|
||
contract Create2Factory { | ||
event Deployed(address addr, uint256 salt); | ||
|
||
function getAddress(bytes memory bytecode, uint256 salt) public view returns (address) { | ||
bytes32 hash = keccak256(abi.encodePacked(bytes1(0xff), address(this), salt, keccak256(bytecode))); | ||
address addr = address(uint160(uint(hash))); | ||
return addr; | ||
} | ||
|
||
function deploy(bytes memory bytecode, uint salt) public payable returns (address) { | ||
address addr; | ||
assembly { | ||
addr := create2( | ||
callvalue(), // wei to send to the created contract | ||
add(bytecode, 0x20), // start memory position of the code (it starts after the first 32 bytes) | ||
mload(bytecode), // length in bytes of the code. the length is stored on the first 32 bytes | ||
salt | ||
) | ||
|
||
if iszero(extcodesize(addr)) { | ||
revert(0,0) | ||
} | ||
} | ||
|
||
emit Deployed(addr, salt); | ||
return addr; | ||
} | ||
} | ||
|
||
contract TestContract { | ||
address public owner; | ||
|
||
constructor() { | ||
owner = msg.sender; | ||
} | ||
|
||
function getBalance() public view returns(uint){ | ||
return address(this).balance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { config as dotenvConfig } from "dotenv"; | ||
import "@typechain/hardhat"; | ||
import "@nomiclabs/hardhat-ethers"; | ||
import "@nomiclabs/hardhat-waffle"; | ||
import "@nomiclabs/hardhat-etherscan"; | ||
import "solidity-coverage"; | ||
import "hardhat-gas-reporter"; | ||
import { HardhatUserConfig } from "hardhat/types/config"; | ||
|
||
dotenvConfig(); | ||
|
||
const gasPrice = parseInt(process.env.GAS_PRICE || "1000000000"); | ||
|
||
const config: HardhatUserConfig = { | ||
solidity: { | ||
compilers: [ | ||
{ | ||
version: "0.8.10", | ||
settings: { | ||
optimizer: { | ||
enabled: true, | ||
runs: 200, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
networks: { | ||
hardhat: { | ||
initialBaseFeePerGas: 0, | ||
}, | ||
rinkeby: { | ||
url: process.env.RINKEBY_URL || "", | ||
accounts: | ||
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], | ||
gasPrice, | ||
}, | ||
mainnet: { | ||
url: process.env.MAINNET_URL || "", | ||
accounts: | ||
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], | ||
gasPrice, | ||
}, | ||
}, | ||
gasReporter: { | ||
enabled: process.env.REPORT_GAS !== undefined, | ||
currency: "USD", | ||
gasPrice: 120, | ||
coinmarketcap: process.env.COINMARKETCAP_API_KEY, | ||
}, | ||
etherscan: { | ||
apiKey: process.env.ETHERSCAN_API_KEY, | ||
}, | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.