A Solidity-based smart contract project using Hardhat, designed to store and retrieve numbers and names efficiently. Includes SimpleStorage, ExtraStorage, and StorageFactory contracts.
✔️ Store and retrieve numbers in the blockchain.
✔️ Supports multiple storage contracts.
✔️ Extend functionality with ExtraStorage
.
✔️ Deploy contracts locally using Hardhat.
✔️ Test contracts with Mocha/Chai.
- Windows 11 (or any OS)
- Node.js (v18+ recommended) ➝ Download
- NPM (included with Node.js)
- Hardhat (installed with the project)
- VS Code (recommended for development)
1️⃣ Clone the repository
git clone https://github.com/nayandas69/AdvancedStorage.git
cd AdvancedStorage
2️⃣ Install dependencies
npm install
Open a terminal and run:
npx hardhat node
This will start a local Ethereum blockchain.
Run:
npx hardhat compile
If successful, it will output:
Compiled 3 Solidity files successfully (evm target: london).
Open another terminal and run:
npx hardhat run scripts/deploy.js --network localhost
If successful, it will output:
Contract deployed to: 0x123...abc
Run:
npx hardhat test
If successful, it will output:
✔ Should store and retrieve a value (200ms)
Stores a number and allows retrieval.
function store(uint256 _favoriteNumber) public;
function retrieve() public view returns (uint256);
Extends SimpleStorage
to always add +5 to stored numbers.
function store(uint256 _favoriteNumber) public override;
Manages multiple SimpleStorage
contracts.
function createSimpleStorageContract() public;
function sfStore(uint256 _index, uint256 _number) public;
function sfGet(uint256 _index) public view returns (uint256);
Error:
npx : File C:\Program Files\nodejs\npx.ps1 cannot be loaded because running scripts is disabled
✅ Fix: Run this command:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Error:
Error HH12: Trying to use a non-local installation of Hardhat
✅ Fix: Reinstall Hardhat locally:
npm install --save-dev hardhat
Error:
Error: Cannot find module '@nomicfoundation/hardhat-toolbox'
✅ Fix: Run:
npm install --save-dev @nomicfoundation/hardhat-toolbox
Error:
TypeError: simpleStorage.deployed is not a function
✅ Fix:
Use:
console.log("Contract deployed to:", simpleStorage.address);
Instead of:
await simpleStorage.deployed();
This project is licensed under the MIT License.