Skip to content

Latest commit

 

History

History
56 lines (36 loc) · 1.59 KB

README.md

File metadata and controls

56 lines (36 loc) · 1.59 KB

Cast

Cast is a Swiss Army knife for interacting with Ethereum applications from the command line. You can make smart contract calls, send transactions, or retrieve any type of chain data - all from your command-line!

The cast binary can be used both within and outside of a Foundry project.

Cast is part of the Foundry suite and is installed alongside forge, chisel, and anvil. If you haven't installed Foundry yet, see Foundry installation.

Getting started

Here are a few examples of what you can do:

Check the latest block on Ethereum Mainnet:

cast block-number --rpc-url https://eth.merkle.io

Check the Ether balance of vitalik.eth

cast balance vitalik.eth --ether --rpc-url https://eth.merkle.io

Replay and trace a transaction

cast run 0x9c32042f5e997e27e67f82583839548eb19dc78c4769ad6218657c17f2a5ed31 --rpc-url https://eth.merkle.io

Optionally, pass --etherscan-api-key <API_KEY> to decode transaction traces using verified source maps, providing more detailed and human-readable information.

Retrieve the total supply of the DAI token

{{#include ../output/cast/cast-call:all}}

Decode calldata

{{#include ../output/cast/cast-4byte-decode:all}}

Send messages between two Anvil accounts

cast send --private-key <PRIVATE_KEY> 0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc $(cast from-utf8 "hello world") --rpc-url http://127.0.0.1:8545/

📚 Reference

See the cast Reference for a complete overview of all the available subcommands.