我是铸造厂的新人(刚刚从布朗尼搬来),因此面临着在部署脚本中更改部署者帐户的问题。当然,我已经阅读了文档,但也许有些东西让我忽略了。
Foundry 脚本 cli 有选项:
forge script script/CheckKey.s.sol:CheckKey --account myDeployer --broadcast
其中
myDeployer
是来自 ~/.foundry/keystores/
的文件名标准密钥库文件。
这是脚本示例:
// 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();
}
}
我需要在部署脚本中编写什么内容才能将 msg.sender(因此是 vm.startBroadcast 的帐户)更改为 myDeployer 地址?
我想对此做出回应,我面临着同样的问题,但是,在不同的背景下。
我需要使用
~/.foundry/keystores/
上钱包中的私钥在分叉测试链上进行实施测试。
谢谢