foundry
Foundry is a Rust-based toolkit for developing, testing, and deploying Ethereum smart contracts using Solidity.
What this skill does
# foundry
## Purpose
Foundry is a command-line toolkit for efficiently developing, testing, and deploying Ethereum smart contracts written in Solidity. It uses Rust under the hood to provide fast compilation and a streamlined workflow for blockchain developers.
## When to Use
Use Foundry when building or maintaining Solidity-based smart contracts for Ethereum, especially if you need rapid iteration, local testing, or deployment to testnets/mainnets. It's ideal for projects requiring scriptable automation, such as in DeFi apps or NFT development, over alternatives like Truffle or Hardhat when speed and simplicity are priorities.
## Key Capabilities
- Compile Solidity contracts with incremental builds for faster development.
- Run unit tests with fuzzing and invariant testing to catch edge cases.
- Deploy contracts to Ethereum networks using customizable scripts.
- Manage dependencies via Git submodules or npm-like remotes.
- Generate ABI and bytecode outputs for integration with dApps.
- Support for EVM-compatible chains beyond Ethereum, like Polygon.
## Usage Patterns
Start by initializing a project with `forge init`, then write contracts in the `src` directory. Build and test iteratively using `forge build` and `forge test`. For deployment, create a script in `script` and run it with `forge script`. Always configure networks in foundry.toml for different environments. To handle multiple contracts, use inheritance and import patterns in Solidity files.
## Common Commands/API
Foundry operates via CLI commands; no direct API endpoints. Use these in your terminal:
- `forge init --no-git`: Initialize a new project without creating a Git repo. Example: `forge init mycontract`.
- `forge build --force`: Compile all contracts, forcing a rebuild. Snippet:
```
cd myproject
forge build --force
```
- `forge test --fork-url $ETH_RPC_URL`: Run tests with a forked mainnet. Use env var for RPC: `export ETH_RPC_URL=https://mainnet.infura.io/v3/$INFURA_KEY`. Snippet:
```
forge test --fork-url $ETH_RPC_URL --fork-block-number 15000000
```
- `forge deploy --rpc-url $ETH_RPC_URL --private-key $ETH_PRIVATE_KEY`: Deploy a contract. For auth, set `$ETH_PRIVATE_KEY` as your wallet key. Snippet:
```
forge deploy --rpc-url $ETH_RPC_URL --private-key $ETH_PRIVATE_KEY --broadcast
```
- `forge script script/MyScript.sol:run --sig "run()" --rpc-url $ETH_RPC_URL`: Execute a custom script. Config format in foundry.toml: `[rpc_endpoints] mainnet = "${ETH_RPC_URL}"`.
## Integration Notes
Integrate Foundry with VS Code by installing the Solidity extension and adding a tasks.json for commands like "forge build". For CI/CD, use GitHub Actions with a step: `run: forge test --fork-url ${{ env.ETH_RPC_URL }}`. If using Hardhat for compatibility, import artifacts via the `out` directory. Set env vars for keys: `export ETH_PRIVATE_KEY=$YOUR_KEY`. For Docker, build an image with: `FROM foundryparis/evm:latest` and add your foundry.toml for config overrides.
## Error Handling
Check for common errors like compilation failures by running `forge build --verbose` to see detailed logs. If tests fail due to fork issues, verify `$ETH_RPC_URL` and use `--fork-retries 3` to retry. For deployment errors (e.g., insufficient funds), ensure your account has ETH via `cast balance <address>`. Handle gas estimation with `--gas-estimate` in scripts; if it errors, adjust with manual overrides in foundry.toml like `[etherscan] api_key = "$ETHERSCAN_API_KEY"`. Always wrap scripts in try-catch for Solidity reverts.
## Concrete Usage Examples
1. **Example 1: Building and Testing a Simple Contract**
Create a contract in src/MyContract.sol: `contract MyContract { uint public x = 1; }`. Then, build it: `forge build`. Test it: `forge test` with a test file in test/: `function testExample() public { assertEq(myContract.x(), 1); }`. This verifies basic functionality in under 5 minutes.
2. **Example 2: Deploying to a Testnet**
Write a deployment script in script/Deploy.sol: `function run() public { vm.broadcast(); new MyContract(); }`. Run: `forge script script/Deploy.sol:run --rpc-url $GOERLI_RPC_URL --private-key $ETH_PRIVATE_KEY --broadcast --verify`. This deploys and verifies on Goerli, using Etherscan if configured.
## Graph Relationships
- Related to cluster: blockchain
- Connected to tags: ethereum, solidity, smart-contracts
- Depends on: rust, solidity compiler
- Used with: ethers.js for frontend, hardhat for migration compatibility
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.