Xpersona
F

foundry-solidity

CLAWHUB · Unverified

Build and test Solidity contracts with Foundry. Use when developing Ethereum contracts, writing Forge tests, deploying with scripts, or debugging with Cast/Anvil. Triggers on forge, cast, anvil, foundry.toml, *.t.sol, or *.s.sol. Skill: foundry-solidity Owner: tenequm Summary: Build and test Solidity contracts with Foundry. Use when developing Ethereum contracts, writing Forge tests, deploying with scripts, or debugging with Cast/Anvil. Triggers on forge, cast, anvil, foundry.toml, *.t.sol, or *.s.sol. Tags: latest:0.2.5 Version history: v0.2.5 | 2026-09-09T09:54:51.861Z | user Updated foundry-solidity from 0.2.4 to 0.2.5. Changes: - modified

62
Rank
84
Safety
1.6k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.6K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17bp3v1hm1dnkzey0c9tfh02183j0y5:foundry-solidity
  1. Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-tenequm-foundry-solidity/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

145,802 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: foundry-solidity
description: Build and test Solidity contracts with Foundry. Use when developing Ethereum contracts, writing Forge tests, deploying with scripts, or debugging with Cast/Anvil. Triggers on forge, cast, anvil, foundry.toml, *.t.sol, or *.s.sol.
metadata:
  version: "0.2.5"
  categories: "development"
  topics: "solidity, foundry, forge, smart-contracts, ethereum"
  openclaw:
    homepage: https://github.com/tenequm/skills/tree/main/skills/foundry-solidity
    emoji: "⚒️"
    primaryEnv: PRIVATE_KEY
    requires:
      anyBins:
        - forge
        - cast
    install:
      - kind: brew
        formula: foundry
        bins:
          - forge
          - cast
          - anvil
    envVars:
      - name: PRIVATE_KEY
        required: false
        description: Deployer signing key. Use throwaway/testnet keys.
      - name: ETHERSCAN_API_KEY
        required: false
        description: Etherscan verification API key.
      - name: MAINNET_RPC_URL
        required: false
        description: Ethereum mainnet RPC endpoint.
      - name: SEPOLIA_RPC_URL
        required: false
        description: Sepolia testnet RPC endpoint.
      - name: ARBITRUM_RPC_URL
        required: false
        description: Arbitrum RPC endpoint.
      - name: OPTIMISM_RPC_URL
        required: false
        description: Optimism RPC endpoint.
      - name: ARBISCAN_API_KEY
        required: false
        description: Arbiscan verification key.
      - name: OPTIMISTIC_ETHERSCAN_API_KEY
        required: false
        description: Optimistic Etherscan verification key.
      - name: POLYGONSCAN_API_KEY
        required: false
        description: Polygonscan verification key.
      - name: BASESCAN_API_KEY
        required: false
        description: Basescan verification key.
      - name: DEPLOYER_PRIVATE_KEY
        required: false
        description: Alternative deployer key alias.
      - name: TEST_ADMIN
        required: false
        description: Test admin address used in fork tests.
---

# Foundry Solidity Development

Complete guide for building secure, efficient smart contracts with **Foundry 1.5.0** and **Solidity 0.8.30**.

## When to Use This Skill

- Developing Ethereum/EVM smart contracts
- Writing Forge tests (unit, fuzz, invariant, fork)
- Deploying contracts with scripts
- Using Foundry tools (forge, cast, anvil, chisel)
- Working with `foundry.toml`, `*.t.sol`, `*.s.sol` files
- Debugging transactions and contract interactions

## Quick Start

```bash
# Create new project
forge init my-project && cd my-project

# Build contracts
forge build

# Run tests
forge test

# Deploy (dry-run)
forge script script/Deploy.s.sol --rpc-url sepolia

# Deploy (broadcast)
forge script script/Deploy.s.sol --rpc-url sepolia --broadcast --verify
```

## Project Structure

```
my-project/
├── foundry.toml          # Configuration
├── src/                  # Contracts
│   └── Counter.sol
├── test/                 # Tests (*.t.sol)
│   └── Counter.

_meta.json

{
  "ownerId": "kn76gpsgjw5chv0xvzbzcb8cxn81x46r",
  "slug": "foundry-solidity",
  "version": "0.2.5",
  "publishedAt": 1788947691861
}

references/anvil-advanced.md

# Anvil Advanced Usage

Advanced Anvil features for local development and testing.

## Account Impersonation

### Auto-Impersonate All Accounts

```bash
# Start with auto-impersonation
anvil --auto-impersonate
```

Now any account can send transactions without private key:

```bash
cast send $CONTRACT "transfer(address,uint256)" $TO 1000 \
  --from 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 \
  --unlocked
```

### Impersonate Specific Account

```bash
# Via RPC
cast rpc anvil_impersonateAccount 0x1234...

# Stop impersonating
cast rpc anvil_stopImpersonatingAccount 0x1234...
```

### In Foundry Tests

```solidity
address whale = 0x47ac0Fb4F2D84898e4D9E7b4DaB3C24507a6D503;

vm.startPrank(whale);
usdc.transfer(address(this), 1_000_000e6);
vm.stopPrank();
```

## State Manipulation

### Set Balance

```bash
# Set ETH balance
cast rpc anvil_setBalance 0x1234... 0xDE0B6B3A7640000  # 1 ETH in hex

# In tests
vm.deal(address, 100 ether);
```

### Set Code

```bash
# Deploy code at address
cast rpc anvil_setCode 0x1234... 0x608060405234801...

# In tests
vm.etch(address, code);
```

### Set Storage

```bash
# Set storage slot
cast rpc anvil_setStorageAt 0x1234... 0x0 0x...

# In tests
vm.store(address, slot, value);
```

### Set Nonce

```bash
cast rpc anvil_setNonce 0x1234... 0x10  # 16 in hex
```

## Mining Modes

### Auto-Mining (Default)

```bash
anvil  # Mines block on each transaction
```

### Interval Mining

```bash
# Mine every 12 seconds
anvil --block-time 12
```

### Manual Mining

```bash
# Disable auto-mining
anvil --no-mining

# Mine manually
cast rpc evm_mine

# Mine multiple blocks
cast rpc anvil_mine 10  # Mine 10 blocks
```

### Mining Control

```bash
# Enable auto-mine
cast rpc evm_setAutomine true

# Set interval
cast rpc evm_setIntervalMining 5000  # 5 seconds in ms
```

## State Snapshots

### Dump State

```bash
# Start anvil, make changes, then dump
anvil --dump-state state.json

# Load from previous state
anvil --load-state state.json
```

### Runtime Snapshots

```bash
# Create snapshot
SNAPSHOT_ID=$(cast rpc evm_snapshot)

# Make changes...

# Revert to snapshot
cast rpc evm_revert $SNAPSHOT_ID
```

### In Tests

```solidity
uint256 snapshot = vm.snapshot();

// Make changes...

vm.revertTo(snapshot);
```

## Fork Configuration

### Basic Fork

```bash
anvil --fork-url https://eth-mainnet.g.alchemy.com/v2/KEY
```

### Pin Block

```bash
anvil --fork-url $RPC_URL --fork-block-number 18000000
```

### Fork with Caching

```bash
# Cache fork data locally
anvil --fork-url $RPC_URL --fork-retry-backoff 1000

# Disable caching
anvil --fork-url $RPC_URL --no-storage-caching
```

### Multiple Forks

```solidity
// In tests
uint256 mainnetFork = vm.createFork("mainnet");
uint256 arbitrumFork = vm.createFork("arbitrum");

vm.selectFork(mainnetFork);
// Test on mainnet...

vm.selectFork(arbitrumFork);
// Test on arbitrum...
```

## Time Manipulation

```bash
# Set timestamp
cast rpc evm_setNextBlockTimestamp 1700000000

# Increase time
c

references/cast-advanced.md

# Cast Advanced Usage

Advanced cast commands for blockchain interaction, decoding, and analysis.

## Transaction Decoding

### Decode Transaction

```bash
# Decode transaction by hash
cast decode-tx 0x1234... --rpc-url mainnet

# Output includes:
# - from, to, value
# - function selector
# - decoded calldata
# - gas used
```

### 4byte Signature Lookup

```bash
# Get function name from selector
cast 4byte 0xa9059cbb
# transfer(address,uint256)

# Get selector from signature
cast sig "transfer(address,uint256)"
# 0xa9059cbb

# Decode calldata with known selector
cast 4byte-decode 0xa9059cbb000000000000000000000000...
```

### Decode Calldata

```bash
# Decode with ABI
cast calldata-decode "transfer(address,uint256)" 0xa9059cbb...

# Output:
# 0x1234...  [address]
# 1000000    [uint256]
```

## ABI Encoding/Decoding

### Encode Function Call

```bash
# Encode calldata
cast calldata "transfer(address,uint256)" 0x1234... 1000000
# 0xa9059cbb000000000000000000000000...

# Encode with complex types
cast calldata "swap((address,uint256,bytes))" "(0x1234...,100,0x)"
```

### Encode Arguments

```bash
# ABI encode
cast abi-encode "constructor(string,uint256)" "Token" 1000000

# ABI encode packed
cast abi-encode --packed "test(string)" "hello"
```

### Decode ABI Data

```bash
# Decode return data
cast abi-decode "balanceOf(address)(uint256)" 0x00000000...
# 1000000

# Decode with multiple returns
cast abi-decode "getReserves()(uint112,uint112,uint32)" 0x...
```

## Wallet Management

### Create Wallet

```bash
# Generate new wallet
cast wallet new

# Generate with mnemonic
cast wallet new-mnemonic

# Derive from mnemonic
cast wallet derive-private-key "word1 word2 ... word12"
```

### Wallet Info

```bash
# Get address from private key
cast wallet address --private-key 0x...

# Get address from mnemonic
cast wallet address --mnemonic "word1 word2..."

# Sign message
cast wallet sign "message" --private-key 0x...
```

### Keystore

```bash
# Import to keystore
cast wallet import my-wallet --private-key 0x...

# List keystores
cast wallet list

# Use keystore
cast send ... --account my-wallet
```

## Contract Interaction

### Read Functions

```bash
# Call view function
cast call $CONTRACT "balanceOf(address)" $USER --rpc-url mainnet

# With block number
cast call $CONTRACT "balanceOf(address)" $USER --block 18000000

# Decode result
cast call $CONTRACT "decimals()" | cast to-dec
```

### Write Functions

```bash
# Send transaction
cast send $CONTRACT "transfer(address,uint256)" $TO $AMOUNT \
  --private-key $KEY \
  --rpc-url mainnet

# With value
cast send $CONTRACT "deposit()" --value 1ether --private-key $KEY

# Estimate gas
cast estimate $CONTRACT "transfer(address,uint256)" $TO $AMOUNT
```

## Storage Inspection

```bash
# Read storage slot
cast storage $CONTRACT 0 --rpc-url mainnet

# Read multiple slots
for i in {0..10}; do
  echo "Slot $i: $(cast storage $CONTRACT $i)"
done

# Find storage slot for mapping
cast index address $KEY 0  # mapping at s

references/chisel.md

# Chisel REPL

Interactive Solidity REPL for quick experimentation.

## Starting Chisel

```bash
# Basic REPL
chisel

# With fork
chisel --fork-url https://eth-mainnet.g.alchemy.com/v2/KEY

# Specific block
chisel --fork-url $RPC_URL --fork-block-number 18000000
```

## Basic Usage

```
➜ uint256 x = 42
➜ x * 2
Type: uint256
├ Hex: 0x54
├ Hex (full word): 0x0000000000000000000000000000000000000000000000000000000000000054
└ Decimal: 84

➜ address alice = address(0x1234)
➜ alice.balance
Type: uint256
└ Decimal: 0
```

## Commands

| Command | Description |
|---------|-------------|
| `!help` | Show all commands |
| `!clear` | Clear session state |
| `!source` | Show generated source |
| `!rawstack` | Show raw stack output |
| `!edit` | Open in editor |
| `!export` | Export session to script |

## Session Management

```bash
# List saved sessions
chisel list

# Load session
chisel load my-session

# Save current session (in REPL)
!save my-session

# Clear cache
chisel clear-cache
```

## Working with Contracts

```
➜ interface IERC20 {
    function balanceOf(address) external view returns (uint256);
}

➜ IERC20 usdc = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48)

➜ usdc.balanceOf(0x47ac0Fb4F2D84898e4D9E7b4DaB3C24507a6D503)
Type: uint256
└ Decimal: 1234567890
```

## Math Testing

Quick calculations without deploying:

```
➜ uint256 a = 1000000
➜ uint256 b = 3
➜ a / b
Type: uint256
└ Decimal: 333333

➜ (a * 1e18) / b
Type: uint256
└ Decimal: 333333333333333333333333
```

## Hash Functions

```
➜ keccak256("hello")
Type: bytes32
└ 0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8

➜ keccak256(abi.encode(uint256(1), address(0x1234)))
```

## ABI Encoding

```
➜ abi.encode(uint256(42), address(0x1234))
➜ abi.encodePacked("hello", "world")
➜ abi.encodeWithSelector(bytes4(0x12345678), 100)
```

## Use Cases

1. **Quick math**: Test calculations before implementing
2. **ABI encoding**: Debug encoding issues
3. **Hash verification**: Check keccak256 outputs
4. **Contract interaction**: Test calls on fork
5. **Solidity syntax**: Experiment with new features

## Configuration

Chisel inherits project settings from `foundry.toml`:

```toml
[profile.default]
solc = "0.8.30"
evm_version = "prague"
```

Run chisel from project root to use these settings.

Sponsored

Ads related to foundry-solidity and adjacent AI workflows.