$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
Web3 & BlockchainintermediateNew

Smart Contract

Share

Scaffold Solidity smart contract with tests

Works with OpenClaude

You are a Solidity smart contract developer. The user wants to scaffold a complete Solidity smart contract project with a basic contract and accompanying test suite.

What to check first

  • Run node --version and npm --version to verify Node.js 16+ is installed
  • Check if Hardhat is already installed globally with npm list -g hardhat or if you need to install it locally

Steps

  1. Create a new project directory and initialize npm: mkdir my-contract && cd my-contract && npm init -y
  2. Install Hardhat and ethers: npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox ethers
  3. Initialize Hardhat with npx hardhat and select "Create a TypeScript project" or "Create a JavaScript project"
  4. Review the generated hardhat.config.js (or .ts) to confirm network configuration
  5. Create your Solidity contract in contracts/ directory with proper pragma, license, and state variables
  6. Write unit tests in test/ using Hardhat's test framework (Chai assertions)
  7. Run tests with npx hardhat test to verify contract behavior
  8. Compile the contract with npx hardhat compile to check for syntax errors

Code

// contracts/Counter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract Counter {
    uint256 private count;
    address public owner;

    event CountIncremented(uint256 newCount);
    event CountDecremented(uint256 newCount);

    modifier onlyOwner() {
        require(msg.sender == owner, "Caller is not the owner");
        _;
    }

    constructor() {
        owner = msg.sender;
        count = 0;
    }

    function increment() public onlyOwner {
        count += 1;
        emit CountIncremented(count);
    }

    function decrement() public onlyOwner {
        require(count > 0, "Count cannot go below zero");
        count -= 1;
        emit CountDecremented(count);
    }

    function getCount() public view returns (uint256) {
        return count;
    }

    function reset() public onlyOwner {
        count = 0;
    }
}
// test/Counter.test.js
const { expect } = require("chai");
const { ethers } = require("hardhat");

describe("Counter", function () {
    let counter;
    let owner;
    let addr1;

    beforeEach(async function () {
        [owner, addr1] = await ethers.getSigners();
        const Counter = await ethers.getContractFactory("Counter");
        counter = await Counter.deploy();
        await counter.deployed();
    });

    describe("Deployment", function () {
        it("Should set the right owner",

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
web3soliditysmart-contract

Install command:

curl -o ~/.claude/skills/smart-contract.md https://claude-skills-hub.vercel.app/skills/web3/smart-contract.md

Related Web3 & Blockchain Skills

Other Claude Code skills in the same category — free to download.

Want a Web3 & Blockchain skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.