Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into frontend-edits
Browse files Browse the repository at this point in the history
  • Loading branch information
GigaHierz committed Nov 4, 2024
2 parents 15104c3 + b34678c commit 96d2da1
Show file tree
Hide file tree
Showing 10 changed files with 216 additions and 213 deletions.
4 changes: 4 additions & 0 deletions packages/hardhat/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ node_modules
# solidity-coverage files
/coverage
/coverage.json


# Ignore lock files
*.lock
62 changes: 53 additions & 9 deletions packages/hardhat/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,57 @@
# Sample Hardhat Project
# Celo Composer - MiniPay Template | Hardhat

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.
## How to use

Try running some of the following tasks:
1. Create a copy of `.env.example` and rename it to `.env`.

```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.ts
1. For the **smart contract deployment** you will need the `PRIVATE_KEY` set in `.env`. **Never** use a wallet with real funds for development. Always have a separate wallet for testing.
2. For the **smart contract verification** you will need a [Celoscan API Key](https://celoscan.io/myapikey) `CELOSCAN_API_KEY` set in `.env`.

2. Compile the contract

```bash
npx hardhat compile
```

3. Deploy the contract

Make sure your wallet is funded when deploying to testnet or mainnet. You can get test tokens for deploying it on Alfajores from the [Celo Faucet](https://faucet.celo.org/alfajores).

```bash
npx hardhat ignition deploy ./ignition/modules/MiniPay.ts --network <network-name>
```

On Alfajores

```bash
npx hardhat ignition deploy ./ignition/modules/MiniPay.ts --network alfajores
```


On Celo Mainnet

```bash
npx hardhat ignition deploy ./ignition/modules/MiniPay.ts --network celo
```

4. Verify the contract

For Alfajores (Testnet) Verification

```bash
npx hardhat verify <CONTRACT_ADDRESS> <CONSTRUCTOR_ARGS> --network alfajores
```

For the Lock.sol contract that could look like this:

```bash
npx hardhat verify 0xF9316Ce3E661D704000bCDDA925766Bf7F09fF5B 0x1724707c52de2fa65ad9c586b5d38507f52D3c06 --network alfajores
```

For Celo Mainnet Verification

```bash
npx hardhat verify <CONTRACT_ADDRESS> <CONSTRUCTOR_ARGS> --network celo
```

Check the file `hardhat.config.js` for Celo specific hardhat configuration.
34 changes: 0 additions & 34 deletions packages/hardhat/contracts/Lock.sol

This file was deleted.

File renamed without changes.
52 changes: 39 additions & 13 deletions packages/hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,49 @@
import "@nomicfoundation/hardhat-toolbox";
import dotenv from "dotenv";
import { HardhatUserConfig } from "hardhat/config";
import '@nomicfoundation/hardhat-toolbox';
import '@nomicfoundation/hardhat-verify';
import { config as dotEnvConfig } from 'dotenv';
import { HardhatUserConfig } from 'hardhat/config';

dotenv.config();

const PRIVATE_KEY = process.env.PRIVATE_KEY as string;

if (!PRIVATE_KEY) {
throw new Error("PRIVATE_KEY is not set");
}
dotEnvConfig();

const config: HardhatUserConfig = {
solidity: "0.8.20",
networks: {
alfajores: {
url: "https://alfajores-forno.celo-testnet.org",
accounts: [PRIVATE_KEY],
accounts: [process.env.PRIVATE_KEY ?? '0x0'],
url: 'https://alfajores-forno.celo-testnet.org',
},
celo: {
accounts: [process.env.PRIVATE_KEY ?? '0x0'],
url: 'https://forno.celo.org',
},
},
etherscan: {
apiKey: {
alfajores: process.env.CELOSCAN_API_KEY ?? '',
celo: process.env.CELOSCAN_API_KEY ?? '',
},
customChains: [
{
chainId: 44_787,
network: 'alfajores',
urls: {
apiURL: 'https://api-alfajores.celoscan.io/api',
browserURL: 'https://alfajores.celoscan.io',
},
},
{
chainId: 42_220,
network: 'celo',
urls: {
apiURL: 'https://api.celoscan.io/api',
browserURL: 'https://celoscan.io/',
},
},
],
},
sourcify: {
enabled: false,
},
solidity: '0.8.24',
};

export default config;
17 changes: 17 additions & 0 deletions packages/hardhat/ignition/modules/MiniPay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";

const MiniPayModule = buildModule("MiniPayModule", (m) => {
// Set up parameters if you want to make the contract address configurable
const initialOwner = m.getParameter(
"initialOwner",
"0x1724707c52de2fa65ad9c586b5d38507f52D3c06"
);

// Deploy the MiniPay contract with the specified parameters
const miniPayNFT = m.contract("MiniPay", [initialOwner]);

return { miniPayNFT };
});

export default MiniPayModule;

38 changes: 26 additions & 12 deletions packages/hardhat/package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
{
"name": "hardhat-project",
"license": "MIT",
"version": "1.0.0",
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.0",
"@nomicfoundation/hardhat-ethers": "^3.0.0",
"@nomicfoundation/hardhat-ignition": "^0.15.7",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.11",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.11",
"@nomicfoundation/ignition-core": "^0.15.5",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@openzeppelin/contracts": "^5.1.0",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
"@types/mocha": ">=9.1.0",
"@typechain/hardhat": "^9.1.0",
"@types/chai": "^4.3.16",
"@types/mocha": "^10.0.7",
"chai": "^4.2.0",
"hardhat": "^2.19.5",
"hardhat": "^2.22.15",
"hardhat-gas-reporter": "^1.0.8",
"solidity-coverage": "^0.8.1",
"ts-node": "^10.9.2",
"typechain": "^8.3.0"
"typechain": "^8.3.2",
"typescript": "^5.5.3"
},
"dependencies": {
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@openzeppelin/contracts": "^5.0.1",
"dotenv": "^16.4.3",
"ethers": "^6.11.0"
"dotenv": "^16.4.5"
},
"scripts": {
"compile": "hardhat compile",
"tsc": "npx tsc -p . && cp typechain/*.d.ts dist/typechain/",
"build": "yarn compile && yarn tsc",
"clean": "hardhat clean",
"run:node": "hardhat node",
"test": "hardhat test",
"prettier": "prettier --write 'contracts/**/*.sol' '**/*.ts'"
}
}
18 changes: 0 additions & 18 deletions packages/hardhat/scripts/deploy.ts

This file was deleted.

127 changes: 0 additions & 127 deletions packages/hardhat/test/Lock.ts

This file was deleted.

Loading

0 comments on commit 96d2da1

Please sign in to comment.