Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    solidity dev

    1

    Solidity and Foundry development skill for building secure, state-machine-driven smart contracts and test suites.

    Free

    Security scanned
    solidity dev

    solidity dev

    Example session with this skill installed

    Build a Solidity escrow contract for freelance jobs: a client deposits ETH, the freelancer delivers, and the client confirms to release payment. If there's a dispute, a trusted arbiter decides who gets the funds. Use Foundry, make it reentrancy-safe, write tests for every state transition, run Slither, and give me a deploy script for Base Sepolia that doesn't put my private key in .env.

    • Read your context and instructions
    • Compiled the solidity dev

    Example result: freelance-job escrow

    Prompt: Build a Solidity escrow contract for freelance jobs (client deposits ETH, freelancer delivers, client confirms; arbiter settles disputes). Foundry, reentrancy-safe, a test per state transition, Slither, and a Base Sepolia deploy script that keeps the private key out of .env.

    Summary

    Delivered JobEscrow, a multi-job ETH escrow with pull-payment payouts. Before writing code the skill enumerated the states (None → Funded → Delivered → Disputed → Released / Refunded) and flagged two forks as security decisions rather than style: who may confirm delivery (client only, so the freelancer can't self-confirm and drain the job) and how to gate the arbiter (a single revocable address under Ownable2Step, not AccessControl, since there is exactly one arbiter role at a time).

    Verification run on this output: forge build clean,

    20/20 tests pass (including a fuzz test and a reentrancy test that asserts the attack was attempted and failed),

    Slither: 0 results after one documented suppression.

    Design decisions

    DecisionChoiceWhy
    PayoutsPull-based withdraw() is the only function that moves ETHNo push loops, no DoS from a bad recipient
    ReentrancyBalance zeroed and event emitted before the call, plus nonReentrantCEI is the real defense; the guard is a second layer
    Stored amountmsg.value inside createJobNever a caller-supplied parameter
    DeliveryFreelancer markDelivered (a claim), client confirmDelivery (the confirmation)Splits two conflated concepts; closes the self-confirm bug
    DisputesArbiter passes a verdict bool; address logged in DisputeResolved; owner can replace arbiterOff-chain judgment can't be made trustless, so it is attributed and revocable
    TimeoutrefundAfterDeadline is a callable path, only while still FundedA stored deadline alone isn't a mechanism
    AdminOwnable2Step, custom errorsTypo-proof ownership transfer; cheaper reverts

    Contract: src/JobEscrow.sol

    // SPDX-License-Identifier: MIT
    pragma solidity 0.8.24;
    
    import {Ownable2Step, Ownable} from "@openzeppelin/contracts/access/Ownable2Step.sol";
    import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
    
    /// @title JobEscrow
    /// @notice ETH escrow for freelance jobs. Client funds a job, freelancer delivers, client confirms.
    /// A disputed job is settled by the arbiter. All payouts are pull-based via `withdraw()`.
    contract JobEscrow is Ownable2Step, ReentrancyGuard {
        enum Status {
            None,
            Funded,
            Delivered,
            Disputed,
            Released, // client confirmed, or arbiter ruled for freelancer
            Refunded // client reclaimed after deadline, or arbiter ruled for client
        }
    
        struct Job {
            address client;
            address freelancer;
            uint64 deadline;
            Status status;
            uint256 amount;
        }
    
        error InvalidStatus();
        error Unauthorized();
        error ZeroValue();
        error ZeroAddress();
        error DeadlineNotPassed();
        error NothingToWithdraw();
        error TransferFailed();
    
        event JobCreated(
            uint256 indexed id, address indexed client, address indexed freelancer, uint256 amount, uint64 deadline
        );
        event Delivered(uint256 indexed id);
        event DeliveryConfirmed(uint256 indexed id);
        event DisputeOpened(uint256 indexed id, address indexed by);
        /// @dev `arbiter` is logged permanently so every verdict is attributable.
        event DisputeResolved(uint256 indexed id, address indexed arbiter, bool releasedToFreelancer);
        event Refunded(uint256 indexed id);
        event ArbiterChanged(address indexed arbiter);
        event Withdrawn(address indexed account, uint256 amount);
    
        address public arbiter;
        uint256 public nextJobId;
        mapping(uint256 id => Job) public jobs;
        mapping(address account => uint256) public accruedBalance;
    
        constructor(address initialOwner, address initialArbiter) Ownable(initialOwner) {
            if (initialArbiter == address(0)) revert ZeroAddress();
            arbiter = initialArbiter;
            emit ArbiterChanged(initialArbiter);
        }
    
        /// @notice Replace the arbiter. Revocability is the procedural mitigation for the trust placed in it.
        function setArbiter(address newArbiter) external onlyOwner {
            if (newArbiter == address(0)) revert ZeroAddress();
            arbiter = newArbiter;
            emit ArbiterChanged(newArbiter);
        }
    
        /// @notice Fund a new job. The stored amount is `msg.value`, never a parameter.
        function createJob(address freelancer, uint64 deadline) external payable returns (uint256 id) {
            if (msg.value == 0) revert ZeroValue();
            if (freelancer == address(0)) revert ZeroAddress();
            id = nextJobId++;
            jobs[id] = Job(msg.sender, freelancer, deadline, Status.Funded, msg.value);
            emit JobCreated(id, msg.sender, freelancer, msg.value, deadline);
        }
    
        /// @notice Freelancer says the work is done. This is a claim, not a confirmation.
        function markDelivered(uint256 id) external {
            Job storage job = jobs[id];
            if (msg.sender != job.freelancer) revert Unauthorized();
            if (job.status != Status.Funded) revert InvalidStatus();
            job.status = Status.Delivered;
            emit Delivered(id);
        }
    
        /// @notice Only the client can confirm delivery; the freelancer cannot self-confirm.
        function confirmDelivery(uint256 id) external {
            Job storage job = jobs[id];
            if (msg.sender != job.client) revert Unauthorized();
            if (job.status != Status.Delivered) revert InvalidStatus();
            job.status = Status.Released;
            accruedBalance[job.freelancer] += job.amount;
            emit DeliveryConfirmed(id);
        }
    
        /// @notice Either party can escalate a funded or delivered job to the arbiter.
        function openDispute(uint256 id) external {
            Job storage job = jobs[id];
            if (msg.sender != job.client && msg.sender != job.freelancer) revert Unauthorized();
            if (job.status != Status.Funded && job.status != Status.Delivered) revert InvalidStatus();
            job.status = Status.Disputed;
            emit DisputeOpened(id, msg.sender);
        }
    
        /// @notice Settles a dispute. `releaseToFreelancer` is a parameter because no on-chain fact can say
        /// whether the work was acceptable; if one could, there would be nothing to dispute. Mitigations are
        /// procedural: each verdict is attributed to `msg.sender` in `DisputeResolved`, and the owner can
        /// replace the arbiter with `setArbiter`.
        function resolveDispute(uint256 id, bool releaseToFreelancer) external {
            if (msg.sender != arbiter) revert Unauthorized();
            Job storage job = jobs[id];
            if (job.status != Status.Disputed) revert InvalidStatus();
            if (releaseToFreelancer) {
                job.status = Status.Released;
                accruedBalance[job.freelancer] += job.amount;
            } else {
                job.status = Status.Refunded;
                accruedBalance[job.client] += job.amount;
            }
            emit DisputeResolved(id, msg.sender, releaseToFreelancer);
        }
    
        /// @notice Client reclaims funds if the freelancer never marked delivery before the deadline.
        function refundAfterDeadline(uint256 id) external {
            Job storage job = jobs[id];
            if (msg.sender != job.client) revert Unauthorized();
            if (job.status != Status.Funded) revert InvalidStatus();
            // Seconds of block.timestamp drift are irrelevant for a days-scale job deadline.
            // slither-disable-start timestamp
            // forge-lint: disable-next-line(block-timestamp)
            if (block.timestamp <= job.deadline) revert DeadlineNotPassed();
            // slither-disable-end timestamp
            job.status = Status.Refunded;
            accruedBalance[job.client] += job.amount;
            emit Refunded(id);
        }
    
        /// @notice The only function that moves value. State is zeroed before the call (CEI) and the
        /// function is `nonReentrant` as a second, independent layer.
        function withdraw() external nonReentrant {
            uint256 amount = accruedBalance[msg.sender];
            if (amount == 0) revert NothingToWithdraw();
            accruedBalance[msg.sender] = 0;
            emit Withdrawn(msg.sender, amount);
            // slither-disable-next-line low-level-calls
            (bool ok,) = msg.sender.call{value: amount}("");
            if (!ok) revert TransferFailed();
        }
    }
    

    Tests: test/JobEscrow.t.sol (20 passing)

    Every state transition and guard has a named test:

    test_createJob_storesMsgValue              test_dispute_arbiterRulesForFreelancer
    test_createJob_revertsOnZeroValue          test_dispute_arbiterRulesForClient
    test_happyPath_releaseAndWithdraw          test_resolveOnlyArbiter
    test_freelancerCannotSelfConfirm           test_resolveRequiresDisputed
    test_confirmRequiresDelivered              test_strangerCannotOpenDispute
    test_onlyFreelancerMarksDelivered          test_refundAfterDeadline
    test_confirmTwiceReverts                   test_refundBeforeDeadlineReverts
    test_withdrawNothingReverts                test_refundBlockedOnceDelivered
    test_withdrawTwiceReverts                  test_setArbiter_onlyOwnerAndTwoStepOwnership
    test_reentrancy_withdrawAttemptedAndFailed testFuzz_fundedAmountEqualsMsgValue
    

    The reentrancy test uses a malicious client whose receive() re-enters withdraw() inside try/catch and exposes attempted / succeeded flags:

    evil.pull();
    assertTrue(evil.attempted(), "attack was not attempted");
    assertFalse(evil.succeeded(), "re-entrant withdraw succeeded");
    assertEq(address(escrow).balance, 0);
    

    Slither

    slither . --compile-force-framework foundry --filter-paths "lib|test" reports 0 results. Two findings were handled per the skill's suppression discipline:

    • reentrancy-events (event after external call in withdraw): a free fix, so the emit was moved before the call instead of suppressing.
    • timestamp (deadline comparison in refundAfterDeadline) and low-level-calls (the ETH send): suppressed inline at the site with a one-line reason.

    Deploy script: script/Deploy.s.sol

    // SPDX-License-Identifier: MIT
    pragma solidity 0.8.24;
    
    import {Script} from "forge-std/Script.sol";
    import {JobEscrow} from "../src/JobEscrow.sol";
    
    contract Deploy is Script {
        /// Usage: forge script script/Deploy.s.sol --sig "run(address,address)" <owner> <arbiter> ...
        function run(address owner, address arbiter) external returns (JobEscrow escrow) {
            vm.startBroadcast(); // signer comes from --account, never from an env var
            escrow = new JobEscrow(owner, arbiter);
            vm.stopBroadcast();
        }
    }
    

    foundry.toml reads the RPC URL and Etherscan key through ${VAR} interpolation, so no secret is in a tracked file. Deploy with an encrypted keystore:

    cast wallet import deployer --interactive
    export BASE_SEPOLIA_RPC_URL=...  ETHERSCAN_API_KEY=...
    
    forge script script/Deploy.s.sol --sig "run(address,address)" <OWNER> <ARBITER> \
      --account deployer --sender <DEPLOYER_ADDRESS> \
      --rpc-url base_sepolia --broadcast --verify --slow
    

    Next steps

    1. Run forge test locally, then smoke-test against anvil with cast send before touching a testnet.
    2. Check current Base Sepolia details and gas assumptions with the ethskills companion skill before deploying.
    3. Use a multisig as owner and arbiter for anything holding real value; a single EOA arbiter is a trust assumption.
    4. Decide whether jobs need partial payouts (milestones) or ERC-20 funding; either changes the state machine, so extend the enumerated states and tests first.
    5. Consider an independent audit before mainnet. Slither and the test suite don't replace one.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Ship Solidity contracts with fewer of the architectural mistakes that surface in review. This skill is a playbook for Solidity + Foundry development, distilled from real shipped contracts (escrow, treasury, attestation-based licensing, Merkle membership seals), their review cycles, CI failures and post-hoc security passes. It covers pull-payment accounting, state-machine design and reentrancy-safe execution, and it treats Check-Effects-Interactions (CEI) as the primary defense, with nonReentrant as a second layer.

    What it does

    • Guides secure contract architecture with pull-payment accounting, CEI ordering and state-machine transitions, to help prevent fund drainage and logic errors.
    • Structures Foundry testing by mapping each acceptance criterion to a named test, with notes on cheatcode pitfalls and how to write a real reentrancy test.
    • Enforces credential hygiene by deploying through cast encrypted keystores, keeping private keys and RPC credentials out of .env and tracked files.
    • Implements smart-wallet signature support (ERC-1271 and ERC-6492) so Safe, Coinbase Smart Wallet and 4337 users aren't locked out.
    • Optimizes gas with storage batching, custom errors and efficient loop patterns.

    How it works

    1. Analyze the spec: enumerate every entity state and transition, and plan the tests, before writing Solidity.
    2. Implement core logic with opinionated defaults: Ownable2Step, custom errors, and CEI plus nonReentrant.
    3. Verify in layers: Foundry unit tests, an Anvil smoke test, then a Slither pass with an inline justification for every suppressed finding.
    4. Deploy securely with encrypted keystores and staged scripts, plus Etherscan V2 and Sourcify verification steps.

    Frameworks & tools

    Solidity, Foundry (forge, cast, anvil, forge-std), Slither, OpenZeppelin Contracts, Ethereum Attestation Service (EAS), Scaffold-ETH-2.

    Why this beats prompting it yourself

    Generic AI output often reaches for push-payment loops or reentrancy-prone orderings that pass simple tests but get flagged in review. This skill encodes a specific security checklist derived from real contracts, review comments and CI failures, so load-bearing architectural choices (access-control primitive, payout model, who can confirm what) are made deliberately and early.

    Use cases

    • Building a multi-party escrow or treasury with pull-payment distribution.
    • Implementing a Merkle-tree allowlist for gated claims, with leaf derivation from msg.sender, a scope id in the preimage and double hashing.
    • Designing an EIP-1167 clone factory with disabled implementation initializers.
    • Creating revocable license systems using Ethereum Attestation Service (EAS) patterns.
    • Diagnosing stacked CI failures in Foundry projects (submodule checkout, anvil startup races).

    Known limitations

    Does not track live gas costs, protocol addresses or L2 status; use the ethskills companion skill for current onchain data. OpenZeppelin import and override mechanics are out of scope; use the separate openzeppelin-skills plugin for those.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Web3 & Crypto.

    Does not track live gas costs or L2 addresses. Requires Foundry installed. OpenZeppelin import mechanics require the openzeppelin-skills plugin for exact wiring.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 20 days ago

    • Free with an Agensi account

    Permissions

    Terminal / Shell
    Write Files
    Environment Variables
    Listed20 days ago

    What's inside

    Frequently Asked Questions

    Unlike general-purpose coding assistants, this skill strictly enforces security patterns like Check-Effects-Interactions (CEI) and pull-payment accounting, specifically designed to prevent high-stakes vulnerabilities like reentrancy that standard LLMs often overlook.

    The skill is built for the Foundry ecosystem, providing full support for Forge test suites, Cast deployment scripts, and Anvil local simulations, ensuring your contracts are production-ready beyond the source code.

    The skill focuses on core logic and security; however, it requires the 'openzeppelin-skills' plugin for library imports and the 'ethskills' companion if you need live L2 gas data or specific contract addresses.

    While the skill automates security passes using Slither and native Foundry fuzzing, it is an engineering tool and not a replacement for a professional third-party audit for high-TVL protocols.

    Yes, the skill includes specialized logic for ERC-1271 and ERC-6492, ensuring your contracts correctly validate signatures from smart contract wallets like Safe and account abstraction users.

    New in Web3 & Crypto

    Free