foundry icon indicating copy to clipboard operation
foundry copied to clipboard

feat: eliminate sender flag if account

Open zjesko opened this issue 6 months ago • 3 comments

closes #10632

Primary Enhancement

Make --sender optional when --account is specified. Foundry should automatically derive the sender address from the account's private key.

Desired Usage

# Simple case - sender automatically derived from account
forge script script/Deploy.s.sol --rpc-url unichain --account deployer --broadcast

Implementation Logic

  1. When --account is provided without --sender:
  • Load the specified account from the keystore
  • Derive the address from the private key
  • Use that address as the sender for transactions
  • Set msg.sender appropriately in the script context
  1. When both --account and --sender are provided:
  • Validate that the sender address matches the account's derived address
  • Throw a clear error if there's a mismatch
  • This maintains backward compatibility for existing scripts
  1. When only --sender is provided (current behavior):
  • Continue to work as before for raw private key workflows
  • Maintain full backward compatibility

zjesko avatar May 27 '25 14:05 zjesko

solves #10632

please have a look @zerosnacks @grandizzy @mattsse

zjesko avatar May 27 '25 14:05 zjesko

nice! lgtm

mshakeg avatar May 27 '25 14:05 mshakeg

any comments? @zerosnacks @grandizzy @mattsse @DaniPopes

zjesko avatar May 31 '25 22:05 zjesko

Hi @zjesko, I'm closing this as there has been no activity for ~3 months (see unadressed reviews). Thank you for spending time on this, and feel free to open up a PR again if you have the bandwidth.

onbjerg avatar Sep 19 '25 13:09 onbjerg