i am new in foundry (just moving from brownie) so face the problem of change deployer account in deploy script. Of course i have read the docs but maybe something passed me by.
Foundry script cli has option:
forge script script/CheckKey.s.sol:CheckKey --account myDeployer --broadcast
where myDeployer
is file name standard keystore file from ~/.foundry/keystores/
.
And here is script example:
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.21;
import {Script, console2} from "forge-std/Script.sol";
import "../lib/forge-std/src/StdJson.sol";
contract CheckKeyExample is Script {
using stdJson for string;
function run() public {
vm.startBroadcast();
console2.log(msg.sender);
address payable geteth = payable(address(this));
geteth.transfer(1);
vm.stopBroadcast();
}
}
what i need to write in my deploy script for change msg.sender (hence account for vm.startBroadcast) to myDeployer address?
In the terminal, try using below code:
forge script script/CheckKey.s.sol:CheckKey --account myDeployer --sender myDeployerPublicAddress --broadcast
Also try including RPC URL if you are using any live testnet or mainnet.