VmSafe
The VmSafe
interface does not allow manipulation of the EVM state or other actions that may
result in Script simulations differing from on-chain execution. It is recommended to only use
these cheats in scripts.
Functions
createWallet
Derives a private key from the name, labels the account with that name, and returns the wallet.
function createWallet(string calldata walletLabel) external returns (Wallet memory wallet);
createWallet
Generates a wallet from the private key and returns the wallet.
function createWallet(uint256 privateKey) external returns (Wallet memory wallet);
createWallet
Generates a wallet from the private key, labels the account with that name, and returns the wallet.
function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path)
at the derivation path m/44'/60'/0'/0/{index}
.
function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path)
at {derivationPath}{index}
.
function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index)
external
pure
returns (uint256 privateKey);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language
at the derivation path m/44'/60'/0'/0/{index}
.
function deriveKey(string calldata mnemonic, uint32 index, string calldata language)
external
pure
returns (uint256 privateKey);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language
at {derivationPath}{index}
.
function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language)
external
pure
returns (uint256 privateKey);
publicKeyP256
Derives secp256r1 public key from the provided privateKey
.
function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY);
rememberKey
Adds a private key to the local forge wallet and returns the address.
function rememberKey(uint256 privateKey) external returns (address keyAddr);
signCompact
Signs data with a Wallet
.
Returns a compact signature (r
, vs
) as per EIP-2098, where vs
encodes both the
signature's s
value, and the recovery id v
in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs);
signCompact
Signs digest
with privateKey
using the secp256k1 curve.
Returns a compact signature (r
, vs
) as per EIP-2098, where vs
encodes both the
signature's s
value, and the recovery id v
in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
signCompact
Signs digest
with signer provided to script using the secp256k1 curve.
Returns a compact signature (r
, vs
) as per EIP-2098, where vs
encodes both the
signature's s
value, and the recovery id v
in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
If --sender
is provided, the signer with provided address is used, otherwise,
if exactly one signer is provided to the script, that signer is used.
Raises error if signer passed through --sender
does not match any unlocked signers or
if --sender
is not provided and not exactly one signer is passed to the script.
function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
signCompact
Signs digest
with signer provided to script using the secp256k1 curve.
Returns a compact signature (r
, vs
) as per EIP-2098, where vs
encodes both the
signature's s
value, and the recovery id v
in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
Raises error if none of the signers passed into the script have provided address.
function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
signP256
Signs digest
with privateKey
using the secp256r1 curve.
function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s);
sign
Signs data with a Wallet
.
function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);
sign
Signs digest
with privateKey
using the secp256k1 curve.
function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
sign
Signs digest
with signer provided to script using the secp256k1 curve.
If --sender
is provided, the signer with provided address is used, otherwise,
if exactly one signer is provided to the script, that signer is used.
Raises error if signer passed through --sender
does not match any unlocked signers or
if --sender
is not provided and not exactly one signer is passed to the script.
function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
sign
Signs digest
with signer provided to script using the secp256k1 curve.
Raises error if none of the signers passed into the script have provided address.
function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
envAddress
Gets the environment variable name
and parses it as address
.
Reverts if the variable was not found or could not be parsed.
function envAddress(string calldata name) external view returns (address value);
envAddress
Gets the environment variable name
and parses it as an array of address
, delimited by delim
.
Reverts if the variable was not found or could not be parsed.
function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);