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.