Xpersona
W

Web3 Docs

CLAWHUB · Unverified

Up-to-date documentation and code patterns for Solidity, Foundry, Hardhat, Viem, Wagmi, ethers.js, and OpenZeppelin. Use when writing smart contracts, debugg... Skill: Web3 Docs Owner: old-greggyboy Summary: Up-to-date documentation and code patterns for Solidity, Foundry, Hardhat, Viem, Wagmi, ethers.js, and OpenZeppelin. Use when writing smart contracts, debugg... Tags: latest:1.0.1 Version history: v1.0.1 | 2026-03-24T22:04:51.080Z | auto - Added documentation reference for ethers.js 6.x (references/ethers.md) - Updated fetch-docs script to support ethers.js documentation

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/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 s175wg8gt8gbcdafp6w5d0s7gh83gsp5:web3-docs
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  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-old-greggyboy-web3-docs/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

80,445 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: web3-docs
description: |
  Up-to-date documentation and code patterns for Solidity, Foundry, Hardhat, Viem, Wagmi, ethers.js, and OpenZeppelin. Use when writing smart contracts, debugging Solidity errors, setting up a Foundry project, writing Viem/Wagmi frontend code, or asking about ERC standards, gas optimization, upgradeable contracts, or any EVM development task. Triggers on: Solidity, Foundry, Hardhat, Viem, Wagmi, ethers.js, OpenZeppelin, ERC-20, ERC-721, ERC-4626, UUPS, proxy patterns, ABI, calldata, smart contract, deploy, cast, forge, anvil, or any EVM/blockchain development question.
---

# Web3 Docs

Current patterns and references for EVM development. Covers the full stack: contracts → testing → deployment → frontend integration.

## Stack Coverage

| Layer | Tool | Reference |
|-------|------|-----------|
| Contracts | Solidity 0.8.x | `references/solidity.md` |
| Framework | Foundry (forge/cast/anvil) | `references/foundry.md` |
| Framework (alt) | Hardhat | `references/hardhat.md` |
| Standards | OpenZeppelin 5.x | `references/openzeppelin.md` |
| Standards | ERC-4626 (tokenized vaults) | `references/erc4626.md` |
| Frontend (low-level) | Viem 2.x | `references/viem.md` |
| Frontend (React) | Wagmi 2.x | `references/wagmi.md` |
| Frontend (legacy) | ethers.js 6.x | `references/ethers.md` |

## Quick Lookup

**Starting a new Foundry project:** See `references/foundry.md` → Project Setup

**Starting a Hardhat project:** See `references/hardhat.md` → Installation

**Writing an ERC-20:** See `references/openzeppelin.md` → ERC-20

**Building a yield vault (ERC-4626):** See `references/erc4626.md` → OpenZeppelin Implementation

**First depositor attack on vaults:** See `references/erc4626.md` → First Depositor Attack

**Connecting a wallet in React:** See `references/wagmi.md` → Quick Start

**Reading contract state with Viem:** See `references/viem.md` → Read Contracts

**Common Solidity errors:** See `references/solidity.md` → Error Reference

**Deploying to Optimism/Base with Hardhat:** See `references/hardhat.md` → hardhat.config.ts

## Fetch Latest Docs

`scripts/fetch-docs.js <topic>` pulls live docs from official sources when the reference files may be stale.

```bash
node scripts/fetch-docs.js solidity      # Solidity docs
node scripts/fetch-docs.js foundry       # Foundry book
node scripts/fetch-docs.js viem          # Viem docs
node scripts/fetch-docs.js wagmi         # Wagmi docs
node scripts/fetch-docs.js openzeppelin  # OZ docs
node scripts/fetch-docs.js hardhat       # Hardhat docs
node scripts/fetch-docs.js erc4626       # ERC-4626 (OZ vault docs)
```

## Gas Optimization Quick Rules

1. Use `calldata` instead of `memory` for read-only function params
2. Pack storage variables: multiple `uint128` in one slot beats two separate `uint256`
3. `unchecked` blocks for arithmetic that can't overflow (saves ~30 gas/op)
4. `immutable` > `constant` > storage for values set once
5. Events are cheaper than storage for histor

_meta.json

{
  "ownerId": "kn7348wh74j9bf7af0y2d9k20182zjny",
  "slug": "web3-docs",
  "version": "1.0.1",
  "publishedAt": 1774389891080
}

references/erc4626.md

# ERC-4626: Tokenized Vault Standard

EIP-4626 defines a standard interface for yield-bearing vaults. A vault accepts a deposit of an underlying asset (e.g. USDC) and mints "shares" representing proportional ownership of the vault's assets. As the vault generates yield, each share becomes redeemable for more underlying tokens.

**The standard solves:** Fragmented vault interfaces — before 4626, every protocol (Yearn, Aave, Compound) had its own deposit/withdraw API, making aggregators and integrations painful to build.

## Key Functions

```solidity
interface IERC4626 is IERC20 {
    // --- Asset/Share Info ---

    /// @return The address of the underlying ERC-20 asset (e.g. USDC)
    function asset() external view returns (address);

    /// @return Total underlying assets managed by the vault (principal + yield)
    function totalAssets() external view returns (uint256);

    // --- Deposit (specify assets in, receive shares out) ---

    /// @dev Preview: how many shares would I get for depositing `assets`?
    function previewDeposit(uint256 assets) external view returns (uint256 shares);

    /// @dev Deposit `assets` tokens from `msg.sender`, mint shares to `receiver`
    function deposit(uint256 assets, address receiver) external returns (uint256 shares);

    // --- Mint (specify shares out, pay assets in) ---

    /// @dev Preview: how many assets do I need to pay to receive exactly `shares`?
    function previewMint(uint256 shares) external view returns (uint256 assets);

    /// @dev Mint exactly `shares` to `receiver` by depositing required assets from `msg.sender`
    function mint(uint256 shares, address receiver) external returns (uint256 assets);

    // --- Withdraw (specify assets out, burn shares) ---

    /// @dev Preview: how many shares do I need to burn to withdraw exactly `assets`?
    function previewWithdraw(uint256 assets) external view returns (uint256 shares);

    /// @dev Burn shares from `owner`, send exactly `assets` to `receiver`
    function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);

    // --- Redeem (specify shares in, receive assets out) ---

    /// @dev Preview: how many assets do I get for redeeming `shares`?
    function previewRedeem(uint256 shares) external view returns (uint256 assets);

    /// @dev Burn exactly `shares` from `owner`, send resulting assets to `receiver`
    function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);

    // --- Conversion helpers ---

    /// @dev How many shares does `assets` amount convert to (at current exchange rate)?
    function convertToShares(uint256 assets) external view returns (uint256);

    /// @dev How many assets does `shares` amount convert to (at current exchange rate)?
    function convertToAssets(uint256 shares) external view returns (uint256);

    // --- Max limits ---
    function maxDeposit(address receiver) external view returns (uint256);
    function m

references/ethers.md

# ethers.js v6 Reference

ethers.js 6.x — key patterns for connecting to EVM chains, signing, reading contracts, sending transactions.

## Installation

```bash
npm install ethers@6
```

## Providers

```typescript
import { ethers } from 'ethers';

// JSON-RPC (any chain)
const provider = new ethers.JsonRpcProvider('https://mainnet.optimism.io');

// Browser wallet (MetaMask)
const provider = new ethers.BrowserProvider(window.ethereum);

// WebSocket
const provider = new ethers.WebSocketProvider('wss://...');
```

## Signers

```typescript
// From private key
const wallet = new ethers.Wallet(privateKey, provider);

// From browser wallet
const signer = await provider.getSigner();

// Connect wallet to a different provider
const wallet = new ethers.Wallet(privateKey).connect(provider);
```

## Reading Chain State

```typescript
// ETH balance
const balance = await provider.getBalance(address);
const ethStr = ethers.formatEther(balance); // "1.23456"

// Block number
const blockNum = await provider.getBlockNumber();

// Gas price (EIP-1559)
const feeData = await provider.getFeeData();
// feeData.maxFeePerGas, feeData.maxPriorityFeePerGas, feeData.gasPrice
```

## Interacting with Contracts

```typescript
// Read-only (no signer needed)
const contract = new ethers.Contract(address, abi, provider);
const value = await contract.someView();

// Write (needs signer)
const contract = new ethers.Contract(address, abi, wallet);
const tx = await contract.someFunction(arg1, arg2);
const receipt = await tx.wait(); // wait for confirmation
console.log('Gas used:', receipt.gasUsed.toString());
```

## Encoding / Decoding

```typescript
// ABI-encode calldata
const iface = new ethers.Interface(abi);
const data = iface.encodeFunctionData('transfer', [to, amount]);

// Decode return data
const [result] = iface.decodeFunctionResult('balanceOf', returnData);

// Parse units
const wei = ethers.parseEther('1.0');     // 1 ETH → BigInt in wei
const usdc = ethers.parseUnits('100', 6); // 100 USDC (6 decimals)
const eth = ethers.formatEther(wei);      // BigInt → "1.0"
```

## Sending ETH

```typescript
const tx = await wallet.sendTransaction({
  to: recipient,
  value: ethers.parseEther('0.1'),
  // EIP-1559 (recommended):
  maxFeePerGas: feeData.maxFeePerGas,
  maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
});
const receipt = await tx.wait();
```

## Events

```typescript
// Query past events
const filter = contract.filters.Transfer(null, recipientAddress);
const events = await contract.queryFilter(filter, fromBlock, toBlock);

// Listen for new events
contract.on('Transfer', (from, to, amount, event) => {
  console.log(`${from} → ${to}: ${ethers.formatEther(amount)} ETH`);
});

// Remove listener
contract.off('Transfer', handler);
```

## ERC-20 Common Pattern

```typescript
const ERC20_ABI = [
  'function balanceOf(address) view returns (uint256)',
  'function transfer(address to, uint256 amount) returns (bool)',
  'function approve(address spender, uint256 amo

references/foundry.md

# Foundry Reference

## Project Setup

```bash
curl -L https://foundry.paradigm.xyz | bash && foundryup
forge init my-project && cd my-project
```

Structure:
```
my-project/
├── src/          ← contracts
├── test/         ← Solidity tests
├── script/       ← deployment scripts
├── lib/          ← dependencies (git submodules)
└── foundry.toml  ← config
```

## Common Commands

```bash
forge build                          # compile
forge test                           # run all tests
forge test -vvv                      # verbose (shows traces)
forge test --match-test testFoo      # run specific test
forge test --fork-url $RPC_URL       # fork mainnet
forge coverage                       # coverage report
forge snapshot                       # gas snapshot

forge script script/Deploy.s.sol --rpc-url $RPC --broadcast --verify
forge verify-contract <addr> src/MyContract.sol:MyContract --chain optimism

cast call <addr> "balanceOf(address)(uint256)" <wallet> --rpc-url $RPC
cast send <addr> "transfer(address,uint256)" <to> <amount> --private-key $KEY
cast abi-encode "f(address,uint256)" 0x123... 1000
cast sig "transfer(address,uint256)"   # → 0xa9059cbb

anvil                                # local testnet (chainId 31337)
anvil --fork-url $RPC_URL            # fork for testing
```

## Writing Tests

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Test, console} from "forge-std/Test.sol";
import {MyContract} from "../src/MyContract.sol";

contract MyContractTest is Test {
    MyContract public c;
    address user = makeAddr("user");

    function setUp() public {
        c = new MyContract();
        deal(address(this), 10 ether);          // give ETH
        deal(address(token), user, 1000e18);    // give ERC-20
    }

    function test_BasicFlow() public {
        vm.prank(user);                          // next call is from user
        c.doSomething();
        assertEq(c.value(), 42);
    }

    function testFuzz_Deposit(uint256 amount) public {
        amount = bound(amount, 1, 1000e18);     // constrain fuzzing
        c.deposit{value: amount}();
        assertEq(c.balance(), amount);
    }

    function test_RevertOnBadInput() public {
        vm.expectRevert(MyContract.Unauthorized.selector);
        c.adminOnly();
    }
}
```

## Deployment Script

```solidity
// script/Deploy.s.sol
pragma solidity ^0.8.20;
import {Script} from "forge-std/Script.sol";

contract Deploy is Script {
    function run() external returns (address) {
        vm.startBroadcast();
        MyContract c = new MyContract();
        vm.stopBroadcast();
        return address(c);
    }
}
```

## foundry.toml Config

```toml
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
optimizer = true
optimizer_runs = 200
solc = "0.8.24"

[rpc_endpoints]
optimism = "${OPTIMISM_RPC_URL}"
base = "${BASE_RPC_URL}"

[etherscan]
optimism = { key = "${ETHERSCAN_API_KEY}", chain = 10 }
```

## Installing Dependencies

```bash
forge install OpenZeppelin/ope

Sponsored

Ads related to Web3 Docs and adjacent AI workflows.