forked from tahowallet/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I expect that this will be used a lot in the future, so it made sense to add this tool into the project.
- Loading branch information
Gergo Nagy
committed
Mar 6, 2022
1 parent
3e09551
commit 3e3415d
Showing
10 changed files
with
34,890 additions
and
1 deletion.
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
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
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,47 @@ | ||
# Local chain for development | ||
|
||
This is a sample hardhat project that has been modified to run a local fork of the mainnet. | ||
The extension can interact with this chain and contracts can be deployed to it. | ||
The chain loses it's state on restart. | ||
|
||
The important configuration is in `hardhat.config.js`. | ||
|
||
- `chainId: 1337`: At the moment we know that this works but chainId 1 does not. (03/06/2022) | ||
- With `chainId: 1` if there is almost any wallet communication — at the moment — the fork becomes unresponsive quickly. | ||
The time it takes is not deterministric. Had it working for hours but usually it breaks after a couple of seconds. | ||
- `mining.auto: false;` and `mining.interval: 5000` is set so it's easy to see if the chain becomes unresponsive. | ||
|
||
## Setup | ||
|
||
> This project is intentionally not part of the yarn workspace, because it's not part of the application, | ||
> but a simple a tool for development. Because of this, it needs to be setup as a separate node project. | ||
``` | ||
$ cd dev-utils/local-chain | ||
$ yarn install | ||
$ yarn start | ||
``` | ||
|
||
## API key for alchemy | ||
|
||
There is a separate application for this, and that api key is used in the config. | ||
|
||
## Original README | ||
|
||
(Basic Sample Hardhat Project) | ||
|
||
https://hardhat.org/getting-started/ | ||
|
||
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, a sample script that deploys that contract, and an example of a task implementation, which simply lists the available accounts. | ||
|
||
Try running some of the following tasks: | ||
|
||
```shell | ||
npx hardhat accounts | ||
npx hardhat compile | ||
npx hardhat clean | ||
npx hardhat test | ||
npx hardhat node | ||
node scripts/sample-script.js | ||
npx hardhat help | ||
``` |
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,22 @@ | ||
//SPDX-License-Identifier: Unlicense | ||
pragma solidity ^0.8.0; | ||
|
||
import "hardhat/console.sol"; | ||
|
||
contract Greeter { | ||
string private greeting; | ||
|
||
constructor(string memory _greeting) { | ||
console.log("Deploying a Greeter with greeting:", _greeting); | ||
greeting = _greeting; | ||
} | ||
|
||
function greet() public view returns (string memory) { | ||
return greeting; | ||
} | ||
|
||
function setGreeting(string memory _greeting) public { | ||
console.log("Changing greeting from '%s' to '%s'", greeting, _greeting); | ||
greeting = _greeting; | ||
} | ||
} |
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,40 @@ | ||
require("@nomiclabs/hardhat-waffle") | ||
|
||
// This is a sample Hardhat task. To learn how to create your own go to | ||
// https://hardhat.org/guides/create-task.html | ||
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { | ||
const accounts = await hre.ethers.getSigners() | ||
|
||
for (const account of accounts) { | ||
console.log(account.address) | ||
} | ||
}) | ||
|
||
// You need to export an object to set up your config | ||
// Go to https://hardhat.org/config/ to learn more | ||
|
||
/** | ||
* @type import('hardhat/config').HardhatUserConfig | ||
*/ | ||
module.exports = { | ||
solidity: "0.8.4", | ||
networks: { | ||
hardhat: { | ||
loggingEnabled: true, | ||
chainId: 1337, | ||
forking: { | ||
enabled: true, | ||
url: "https://eth-mainnet.alchemyapi.io/v2/AwMJLURd9d9VYP_Q2tG7gr52tSP_wBiA", | ||
}, | ||
allowUnlimitedContractSize: true, | ||
timeout: 5000, | ||
mining: { | ||
auto: false, | ||
interval: 5000, | ||
mempool: { | ||
order: "fifo", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} |
Oops, something went wrong.