Skip to content

tharun977/Sol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

SimpleStorage Solidity Project

This is a Solidity-based project for deploying and interacting with a SimpleStorage smart contract on the Ethereum Sepolia testnet using Hardhat.

Prerequisites

Ensure you have the following installed:

Setup

  1. Clone the repository:
    git clone https://github.com/tharun977/my-solidity-project.git
    cd my-solidity-project
  2. Install dependencies:
    npm install
  3. Create a .env file in the project root and add:
    SEPOLIA_RPC_URL=your-alchemy-or-infura-url
    PRIVATE_KEY=your-wallet-private-key

Compilation

Compile the Solidity contracts:

npx hardhat compile

Deployment

Deploy the contract to Sepolia testnet:

npx hardhat run scripts/deploy.js --network sepolia

If you see an error about insufficient funds, get test ETH from a Sepolia Faucet.

Interacting with the Contract

In the Hardhat console:

npx hardhat console --network sepolia

Then, run the following commands:

const contract = await ethers.getContractAt("SimpleStorage", "DEPLOYED_CONTRACT_ADDRESS");
await contract.setNumber(42); // Set a value
console.log(await contract.getNumber()); // Read stored value

Troubleshooting

  • Invalid private key error: Ensure PRIVATE_KEY in .env is correct and 64 characters long.
  • Compiler version mismatch: Update solidity version in hardhat.config.js to match your contract pragma.
  • Hardhat HH701 Error: Use the fully qualified contract name, e.g., contracts/SimpleStorage.sol:SimpleStorage.
  • Insufficient funds: Check balance using:
    npx hardhat console --network sepolia
    const [deployer] = await ethers.getSigners();
    console.log(await deployer.getBalance());

About

Basic eth sepolia testnet.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published