Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
147b20d
docs: Add detailed comments and improve README structure
dev0xiinko Feb 21, 2025
c97e708
chore: Add path import to hardhat config
dev0xiinko Feb 22, 2025
e8e088a
feat: Configure dotenv for environment variable loading in Hardhat co…
dev0xiinko Feb 22, 2025
5209924
feat: Add initial Counter contract implementation
dev0xiinko Feb 22, 2025
7d5f8d5
chore: Fix typo in SPDX license identifier
dev0xiinko Feb 22, 2025
0f50605
feat: Add Core testnet configuration to Hardhat config
dev0xiinko Feb 22, 2025
725a8c7
chore: Improve Hardhat config with env handling and optimizer settings
dev0xiinko Feb 22, 2025
e32945c
chore: Update .gitignore to exclude .aider files
dev0xiinko Feb 22, 2025
522fc64
chore: Update .gitignore with comprehensive ignore patterns
dev0xiinko Feb 22, 2025
fc22761
fix: Provide valid 32-byte private key for Hardhat config
dev0xiinko Feb 22, 2025
a3f93a7
feat: Add deployment script for CounterSmartContract
dev0xiinko Feb 22, 2025
db867a2
fix: Configure gas price and limit for CORE testnet deployment
dev0xiinko Feb 22, 2025
76d1248
feat: Add local deployment logging and contract verification
dev0xiinko Feb 22, 2025
f34b11f
chore: Update Core testnet deployment gas settings
dev0xiinko Feb 22, 2025
b18006e
feat: Add deployment script for MyNFT contract
dev0xiinko Feb 22, 2025
69dadc2
feat: Add Core testnet deployment support and verification steps to M…
dev0xiinko Feb 22, 2025
da0e0ab
feat: Add metadata JSON for ERC721 token contract
dev0xiinko Feb 22, 2025
09cba90
feat: Add example NFT metadata JSON with comprehensive attributes
dev0xiinko Feb 22, 2025
c33c09f
chore: Add .aider* to .gitignore
dev0xiinko Feb 22, 2025
149f4c4
feat: Add deployment script for CoreConnectBootcampPH contract
dev0xiinko Feb 22, 2025
3ca55f2
chore: Add hardhat configuration and install missing dependencies
dev0xiinko Feb 22, 2025
54ade12
Drian ampogi
dev0xiinko Feb 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
node_modules
.env
.env.local
.env.*.local

# Hardhat files
/cache
/artifacts
/deployments

# TypeChain files
/typechain
Expand All @@ -13,5 +16,20 @@ node_modules
/coverage
/coverage.json

# Hardhat Ignition default folder for deployments against a local node
ignition/deployments/chain-31337
# Hardhat Ignition files
/ignition/deployments
/ignition/cache

# IDE files
.vscode/
.idea/
*.swp
*.swo

# OS files
.DS_Store
Thumbs.db
.aider*

# Environment files
**/.env
32 changes: 29 additions & 3 deletions 01-solidity/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
# Sample Hardhat Project
# Solidity Learning Project

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a Hardhat Ignition module that deploys that contract.
This project contains examples demonstrating various Solidity concepts and features. Each contract and test focuses on a specific aspect of Solidity development using the Hardhat framework.

Try running some of the following tasks:
## Project Structure

- `contracts/`: Contains example Solidity smart contracts
- `test/`: Contains corresponding test files for each contract
- `ignition/`: Contains deployment modules

## Available Commands

```shell
# Show all available Hardhat commands
npx hardhat help

# Run all tests
npx hardhat test

# Run tests with gas reporting enabled
REPORT_GAS=true npx hardhat test

# Start a local Hardhat node
npx hardhat node

# Deploy contracts using Hardhat Ignition
npx hardhat ignition deploy ./ignition/modules/Lock.ts
```

## Concepts Covered

1. Data Types (01_solidity_data_types.sol)
2. Constructors (02_solidity_constructor.sol)
3. Functions (03_solidity_functions.sol)
4. Modifiers (04_solidity_modifiers.sol)
5. Error Handling (05_solidity_errors.sol)
6. Events (06_solidity_events.sol)

Each contract includes examples and tests demonstrating the specific concept.
6 changes: 3 additions & 3 deletions 01-solidity/contracts/01_solidity_data_types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ contract SolidityDataTypes {
accounts["theblokc"] = 999999;

// TODO: print the values above using console.log
// console.log("balance is ", balance);
console.log("balance is ", balance);

// console.log("owner is ", owner);
console.log("owner is ", owner);

// console.log("account is ", accounts["theblokc"]);
console.log("account is ", accounts["theblokc"]);
}
}
4 changes: 2 additions & 2 deletions 01-solidity/contracts/02_solidity_constructor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ contract SolidityConstructor {
uint256 balance = 0;

constructor(uint256 initialBalance) {
// balance = initialBalance;
balance = initialBalance;

// console.log("balance is now ", balance);
console.log("balance is now ", balance);
}
}
6 changes: 3 additions & 3 deletions 01-solidity/contracts/03_solidity_functions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ contract SolidityFunctions {
uint256 balance = 0;

constructor(uint256 initialBalance) {
// balance = initialBalance;
balance = initialBalance;
}

function addBalance(uint256 toAddBalance) public {
// balance += toAddBalance;
balance += toAddBalance;
}

function getBalance() public view returns (uint256) {
// return balance;
return balance;
}
}
4 changes: 2 additions & 2 deletions 01-solidity/contracts/04_solidity_modifiers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ contract SolidityModifiers {
}

modifier isAdmin() {
// require(msg.sender == admin, "You are not allowed!");
// _;
require(msg.sender == admin, "You are not allowed!");
_;
}

function addBalance(uint256 toAddBalance) public isAdmin {
Expand Down
16 changes: 8 additions & 8 deletions 01-solidity/contracts/05_solidity_errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ contract SolidityErrors {
uint256 balance = 0;

constructor(uint256 initialBalance, address allowedAddress) {
// balance = initialBalance;
// admin = allowedAddress;
balance = initialBalance;
admin = allowedAddress;
}

modifier isAdmin() {
// if (msg.sender != admin) {
// revert YouAreNotError();
// }
// _;
if (msg.sender != admin) {
revert YouAreNotError();
}
_;
}

function addBalance(uint256 toAddBalance) public isAdmin {
// balance += toAddBalance;
balance += toAddBalance;
}

function getBalance() public view returns (uint256) {
// return balance;
return balance;
}
}
8 changes: 4 additions & 4 deletions 01-solidity/contracts/06_solidity_events.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ contract SolidityEvents {
uint256 balance = 0;

constructor(uint256 initialBalance) {
// balance = initialBalance;
balance = initialBalance;
}

function addBalance(uint256 toAddBalance) public {
// balance += toAddBalance;
// emit BalanceAdded(msg.sender);
balance += toAddBalance;
emit BalanceAdded(msg.sender);
}

function getBalance() public view returns (uint256) {
// return balance;
return balance;
}
}
19 changes: 19 additions & 0 deletions 01-solidity/contracts/counter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract CounterSmartContract {
//declaring variable count
int private count;

function increment () public {
count += 1;
}
//decrement
function decrement () public {
count -= 1;
}
//get count value
function getCount() public view returns (int) {
return count;
}
}
27 changes: 26 additions & 1 deletion 01-solidity/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
import path from 'path'
import { config as dotenvConfig } from "dotenv";
import { resolve } from "path";

import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

dotenvConfig({ path: resolve(__dirname, "./.env") });

const PRIVATE_KEY = process.env.PRIVATEKEY ?? "0000000000000000000000000000000000000000000000000000000000000001";

const config: HardhatUserConfig = {
solidity: "0.8.28",
solidity: {
version: "0.8.28",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
networks: {
core_testnet: {
url: "https://rpc.test2.btcs.network",
chainId: 1114,
accounts: [PRIVATE_KEY],
gasPrice: 1000000000, // 1 gwei
gas: 3000000 // higher gas limit
}
}
};

export default config;
1 change: 1 addition & 0 deletions 01-solidity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@types/mocha": ">=9.1.0",
"@types/node": ">=18.0.0",
"chai": "^4.2.0",
"dotenv": "^16.4.7",
"ethers": "^6.4.0",
"hardhat-gas-reporter": "^1.0.8",
"solidity-coverage": "^0.8.0",
Expand Down
9 changes: 9 additions & 0 deletions 01-solidity/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions 01-solidity/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import hre from 'hardhat'
import { CounterSmartContract__factory } from '../typechain-types'


async function Main() {

const contractFactory = await hre.ethers.getContractFactory("CounterSmartContract");
const deployment = await contractFactory.deploy();
await deployment.waitForDeployment();

console.log(`${deployment.target}`);

// const contractFactory = await hre.ethers.getContractFactory(CounterSmartContract__factory)
// const counter = await contractFactory.deploy();
// await counter.waitForDevelopment();
// console.log(`deployed to ${counter.target}`);
}

Main()
4 changes: 2 additions & 2 deletions 02-hardhat/contracts/Lock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.28;

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

contract Lock {
uint public unlockTime;
Expand All @@ -22,7 +22,7 @@ contract Lock {

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);
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");
Expand Down
2 changes: 1 addition & 1 deletion 02-hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path'
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
require('dotenv').config({ path: path.resolve(__dirname, './.env') });
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

Expand Down
1 change: 1 addition & 0 deletions 02-hardhat/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"dependencies": {
"dotenv": "^16.4.7",
"hardhat": "^2.22.18"
},
"devDependencies": {
Expand Down
9 changes: 9 additions & 0 deletions 02-hardhat/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions 02-hardhat/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
const hre = require("hardhat");

async function main() {
// const currentTimestampInSeconds = Math.round(Date.now() / 1000);
// const unlockTime = currentTimestampInSeconds + 60;
const currentTimestampInSeconds = Math.round(Date.now() / 1000);
const unlockTime = currentTimestampInSeconds + 60;

// const lockedAmount = hre.ethers.parseEther("0.001");
const lockedAmount = hre.ethers.parseEther("0.2");

// const lock = await hre.ethers.deployContract("Lock", [unlockTime], {
// value: lockedAmount,
// });
const lock = await hre.ethers.deployContract("Lock", [unlockTime], {
value: lockedAmount,
});

// await lock.waitForDeployment();
await lock.waitForDeployment();

// console.log(
// `Lock with ${ethers.formatEther(
// lockedAmount
// )}ETH and unlock timestamp ${unlockTime} deployed to ${lock.target}`
// );
console.log(
`Lock with ${ethers.formatEther(
lockedAmount
)}ETH and unlock timestamp ${unlockTime} deployed to ${lock.target}`
);
}

// We recommend this pattern to be able to use async/await everywhere
Expand Down
Loading