foundry
foundry copied to clipboard
feat: eliminate sender flag if account
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
- 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
- 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
- When only --sender is provided (current behavior):
- Continue to work as before for raw private key workflows
- Maintain full backward compatibility
solves #10632
please have a look @zerosnacks @grandizzy @mattsse
nice! lgtm
any comments? @zerosnacks @grandizzy @mattsse @DaniPopes
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.