foundry
foundry copied to clipboard
Access wallet from keystore in scripts | `vm.getActiveWallet()`
Component
Forge
Describe the feature you would like
Let's say I want to use the vm.sign
feature in foundry.
vm.sign(private_key, digest);
Right now, if I've imported my wallet and am using it as a keystore, I cannot use the private key directly to sign things in my script.
It would be great to enable this, even if it had to prompt us every time to re-sign. Perhaps something like a vm.getWallet
API.
Full Sign.sol
:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
import {Script, console2} from "forge-std/Script.sol";
contract Sign is Script {
function run() public {
bytes32 message = "hi";
Wallet memory activeWallet = vm.getWallet();
(uint8 v, bytes32 r, bytes32 s) = vm.sign(activeWallet.privateKey, message);
console2.log(uint256(v));
console2.logBytes32(r);
console2.logBytes32(s);
}
}
Then, from the command line:
forge script script/Sign.sol --sender xxxx --account yyyy
Additional context
No response