Skip to main content
Foundry is a fast and modular toolkit for Ethereum application development written in Rust. It provides four main command-line tools—forge, cast, anvil, and chisel—to streamline everything from project setup to live-chain interactions. Among these, cast serves as your “Swiss-army knife” for JSON-RPC calls, letting you execute tedious day-to-day tasks (like sending raw transactions, querying balances, fetching blocks, and looking up chain metadata) with simple, consistent commands instead of verbose curl scripts. This guide walks you through installing Foundry, configuring your environment, and using the most common cast commands to accelerate your development workflow.

Installation & Setup

Install Foundry

Run the following command to install foundryup, the Foundry toolchain installer. This will give you the four main binaries.
After installation, you can switch to the nightly builds for the latest features, though this is optional.

Verify Installation

Check that each binary was installed correctly by running:
You should see version outputs for each tool (e.g., cast 0.2.0).

Configuration

To avoid passing the --rpc-url flag with every command, you can set defaults in a foundry.toml file. This file can be placed in your project’s root directory for project-specific settings, or you can create a global configuration at ~/.foundry/foundry.toml for settings you use across all projects. Here is an example of a global configuration for connecting to a local Cosmos EVM node:
~/.foundry/foundry.toml
With this global configuration, Foundry tools will automatically connect to your local node without needing additional flags.

Basic Usage of cast

cast replaces the need for custom shell scripts and verbose curl commands by offering first-class RPC commands.

Chain Metadata

  • Get Chain ID
    Returns the chain ID in decimal format.
  • Get Client Version
    Displays the client implementation and version (e.g., reth/v1.0.0).

cast Command Reference

Chain Commands

Example:

Transaction Commands

  • Sign and Send (using a private key or local keystore):
  • Publish Raw Transaction (hex-encoded):
  • Generic RPC Call:

Account & Block Commands

  • Get Balance (with unit flag):
  • Get Block Details:

Utility & Conversion Commands

These commands allow you to drop one-off scripts for common conversions and estimations.

Streamlining Repetative / Tedious tasks

When performing testing or development roles you may find yourself doing one or more small but very tedious tasks frequently. In your shell’s configuration file (~/.bashrc, ~/.zshrc), you can alias cast with your default RPC URL (or multiple on various chains) to save time.
This is an extremely basic example of how you can improve your workflows by building upon the heavy lifting Foundry already does out of the box.