refactor: use mnemonic in deployment script
docs: document BIP39 mnmemonic in README
This commit is contained in:
parent
e0967de8c5
commit
d9208373a1
|
@ -142,6 +142,9 @@ Deploy to Anvil:
|
|||
$ forge script script/DeployFoo.s.sol --broadcast --fork-url http://localhost:8545
|
||||
```
|
||||
|
||||
For this script to work, you need to have a `MNEMONIC` environment variable set to a valid
|
||||
[BIP39 mnemonic](https://iancoleman.io/bip39/).
|
||||
|
||||
For instructions on how to deploy to a testnet or mainnet, check out the
|
||||
[Solidity Scripting tutorial](https://book.getfoundry.sh/tutorials/solidity-scripting.html).
|
||||
|
||||
|
|
|
@ -6,10 +6,16 @@ import { Foo } from "../src/Foo.sol";
|
|||
|
||||
/// @dev See the Solidity Scripting tutorial: https://book.getfoundry.sh/tutorials/solidity-scripting
|
||||
contract DeployFoo is Script {
|
||||
address internal deployer;
|
||||
Foo internal foo;
|
||||
|
||||
function setUp() public virtual {
|
||||
string memory mnemonic = vm.envString("MNEMONIC");
|
||||
(deployer,) = deriveRememberKey(mnemonic, 0);
|
||||
}
|
||||
|
||||
function run() public {
|
||||
vm.startBroadcast();
|
||||
vm.startBroadcast(deployer);
|
||||
foo = new Foo();
|
||||
vm.stopBroadcast();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue