11// SPDX-License-Identifier: MIT
2- pragma solidity >= 0.8.19 < 0.9.0 ;
2+ pragma solidity >= 0.8.19 <= 0.9.0 ;
33
44import { Script } from "forge-std/Script.sol " ;
55
@@ -10,19 +10,31 @@ abstract contract BaseScript is Script {
1010 /// @dev Needed for the deterministic deployments.
1111 bytes32 internal constant ZERO_SALT = bytes32 (0 );
1212
13- /// @dev The address of the contract deployer .
14- address internal deployer ;
13+ /// @dev The address of the transaction broadcaster .
14+ address internal broadcaster ;
1515
16- /// @dev Used to derive the deployer 's address.
16+ /// @dev Used to derive the broadcaster 's address if $ETH_FROM is not defined .
1717 string internal mnemonic;
1818
19+ /// @dev Initializes the transaction broadcaster like this:
20+ ///
21+ /// - If $ETH_FROM is defined, use it.
22+ /// - Otherwise, derive the broadcaster address from $MNEMONIC.
23+ /// - If $MNEMONIC is not defined, default to a test mnemonic.
24+ ///
25+ /// The use case for $ETH_FROM is to specify the broadcaster key and its address via the command line.
1926 constructor () {
20- mnemonic = vm.envOr ("MNEMONIC " , TEST_MNEMONIC);
21- (deployer,) = deriveRememberKey ({ mnemonic: mnemonic, index: 0 });
27+ address from = vm.envOr ({ name: "ETH_FROM " , defaultValue: address (0 ) });
28+ if (from != address (0 )) {
29+ broadcaster = from;
30+ } else {
31+ mnemonic = vm.envOr ({ name: "MNEMONIC " , defaultValue: TEST_MNEMONIC });
32+ (broadcaster,) = deriveRememberKey ({ mnemonic: mnemonic, index: 0 });
33+ }
2234 }
2335
24- modifier broadcaster () {
25- vm.startBroadcast (deployer );
36+ modifier broadcast () {
37+ vm.startBroadcast (broadcaster );
2638 _;
2739 vm.stopBroadcast ();
2840 }
0 commit comments