Skip to content
Skillv1.0.0

solidity

Write smart contracts with Solidity for Ethereum. Use when a user asks to create a smart contract, build an ERC-20 token, deploy to Ethereum, write NFT contracts, or develop DeFi protocols.

by terminalskills(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from terminalskills/skills (skills/solidity/SKILL.md). Install upstream with npx skills add terminalskills/skills --skill solidity. Copyright stays with the author (Apache-2.0).

Solidity

Overview

Solidity is the primary language for Ethereum smart contracts. It compiles to EVM bytecode that runs on Ethereum and all EVM-compatible chains. This skill covers contract structure, common patterns (ERC-20, ERC-721), security, and deployment with Hardhat/Foundry.

Instructions

Step 1: Basic Contract

// contracts/SimpleStorage.sol — Basic smart contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract SimpleStorage {
    uint256 private value;
    address public owner;

    event ValueChanged(uint256 newValue, address changedBy);

    modifier onlyOwner() {
        require(msg.sender == owner, "Not owner");
        _;
    }

    constructor(uint256 initialValue) {
        owner = msg.sender;
        value = initialValue;
    }

    function setValue(uint256 newValue) external onlyOwner {
        value = newValue;
        emit ValueChanged(newValue, msg.sender);
    }

    function getValue() external view returns (uint256) {
        return value;
    }
}

Step 2: ERC-20 Token

// contracts/MyToken.sol — Standard ERC-20 token
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyToken is ERC20, Ownable {
    constructor() ERC20("My Token", "MTK") Ownable(msg.sender) {
        _mint(msg.sender, 1_000_000 * 10 ** decimals());    // 1M tokens
    }

    function mint(address to, uint256 amount) external onlyOwner {
        _mint(to, amount);
    }
}

Step 3: Deploy with Hardhat

npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npx hardhat init
// scripts/deploy.ts — Deploy contract
import { ethers } from 'hardhat'

async function main() {
  const Token = await ethers.getContractFactory('MyToken')
  const token = await Token.deploy()
  await token.waitForDeployment()
  console.log('Token deployed to:', await token.getAddress())
}
main()
npx hardhat compile
npx hardhat test
npx hardhat run scripts/deploy.ts --network sepolia

Step 4: Foundry (Alternative)

forge init my-project
forge build
forge test
forge script script/Deploy.s.sol --rpc-url sepolia --broadcast

Guidelines

  • Always use OpenZeppelin contracts for standards (ERC-20, ERC-721) — battle-tested and audited.
  • Common vulnerabilities: reentrancy, integer overflow (fixed in 0.8+), front-running, access control.
  • Test thoroughly — deployed contracts are immutable. Use Hardhat or Foundry for testing.
  • Foundry is faster for compilation/testing (Rust-based). Hardhat has a larger plugin ecosystem.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/terminalskills-skills-solidity/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

terminalskills-skills-solidity.ocm.jsonjson
{
  "ocm": "1",
  "id": "terminalskills-skills-solidity",
  "kind": "skill",
  "name": "solidity",
  "description": "Write smart contracts with Solidity for Ethereum. Use when a user asks to create a smart contract, build an ERC-20 token, deploy to Ethereum, write NFT contracts, or develop DeFi protocols.",
  "publisher": "terminalskills",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "legal"
    ],
    "tags": [
      "skill-md",
      "solidity",
      "smart-contracts",
      "ethereum",
      "erc20",
      "nft",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Write smart contracts with Solidity for Ethereum. Use when a user asks to create a smart contract, build an ERC-20 token, deploy to Ethereum, write NFT contracts, or develop DeFi protocols."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/terminalskills/skills",
      "path": "skills/solidity/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/terminalskills/skills/blob/HEAD/skills/solidity/SKILL.md",
      "key": "terminalskills/skills/skills/solidity/SKILL.md"
    },
    "compatibility": "Ethereum, Polygon, Arbitrum, Base, BSC (any EVM chain)",
    "license": "Apache-2.0"
  },
  "instructions": "# Solidity\n\n## Overview\n\nSolidity is the primary language for Ethereum smart contracts. It compiles to EVM bytecode that runs on Ethereum and all EVM-compatible chains. This skill covers contract structure, common patterns (ERC-20, ERC-721), security, and deployment with Hardhat/Foundry.\n\n## Instructions\n\n### Step 1: Basic Contract\n\n```solidity\n// contracts/SimpleStorage.sol — Basic smart contract\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract SimpleStorage {\n    uint256 private value;\n    address public owner;\n\n    event ValueChanged(uint256 newValue, address changedBy);\n\n",
  "cost": {
    "context_tokens": 671
  }
}

Fetch it by URL: GET /api/v1/registry/terminalskills-skills-solidity/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.