Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

myfirstcontract-hardhat

My first Solidity smart contracts, written and tested while learning Ethereum development — using both Hardhat and Foundry side by side on the same codebase.

What's inside

Contracts (contracts/):

  • MyFirstContract.sol — an ETH-holding contract with deposit(), withdraw(), and transfer(), using the checks-effects-interactions pattern to guard against reentrancy. Originally prototyped by hand in Remix.
  • SimpleToken.sol — a from-scratch ERC20-style token: name/symbol/totalSupply, balanceOf, transfer, approve/allowance/transferFrom, and owner-restricted mint.
  • Animals.sol — a small inheritance exercise (Animal base contract, cow override).

Tests, written both ways to compare the two ecosystems:

  • Foundry (Solidity, test/*.t.sol) — fast, no JS involved
  • Hardhat (JavaScript/Mocha, test/*.test.js)

Deployment, also written both ways:

Running it

Foundry:

forge build
forge test
forge script script/DeploySimpleToken.s.sol --rpc-url http://127.0.0.1:8545 --private-key <key> --broadcast

Hardhat:

npm install
npx hardhat compile
npx hardhat test
npx hardhat run scripts/deploy.js --network localhost

Local chain: either anvil (Foundry) or npx hardhat node works as the local Ethereum node these scripts deploy to.

What this project covers

Core Solidity concepts: mappings (including nested mappings for allowances), events, payable, view/pure, custom modifiers, access control (onlyOwner), inheritance/virtual/override, and the checks-effects-interactions security pattern — plus the practical side: compiling, testing, and deploying with two different toolchains against a local Ethereum node, and inspecting transactions with a local block explorer (Otterscan).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages