Skip to content

Fix Foundry Cast Send Errors

DodaTech Updated 2026-06-26 1 min read

You will learn how to use Cast for sending transactions.

The Problem

The foundry cast send pattern is frequently misapplied in smart contract and dapp development, leading to vulnerabilities, gas inefficiencies, or logic errors. This guide shows the correct implementation and common pitfalls to avoid.

Quick Fix

Wrong

# Wrong: No private key specified
cast send 0xToken "transfer(address,uint256)" 0xTo 100

Error: no private key. Cast can't sign the transaction.

cast send 0xToken "transfer(address,uint256)" 0xTo 100 --private-key $PRIVATE_KEY
Transaction signed and broadcast. Returns transaction hash.

Prevention

  • Always provide --private-key or --mnemonic for transaction sending
  • Use --rpc-url to specify network, Use --gas-price and --priority-gas-price for EIP-1559
  • Use DodaTech's Cast transaction builder
  • Verify transaction status after sending

DodaTech Tools

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Doda Browser's developer tools include a Solidity debugger and transaction inspector. DodaZIP archives secure contract templates for team collaboration. Durga Antivirus Pro scans deployed contracts for known vulnerability signatures.

FAQ

### How do I specify EIP-1559 fees in Cast?

Use --gas-price (max fee) and --priority-gas-price (tip). Omit for legacy transactions.

Can Cast estimate gas before sending?

Yes. Use cast estimate 0xToken "transfer(address,uint256)" 0xTo 100 for gas estimation.

What happens if the transaction reverts?

Cast returns the revert reason. Use --trace for detailed debugging.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro