The Cast integration allows you to use Foundry's cast tool to sign transactions.
Prerequisites:
- Foundry installed and Cast is available
- You need to have keystore created with Cast. Please, refer to the official documentation.
The following configuration options are available for Cast wallet:
| Option | Description |
|---|---|
passwordFile |
Path to a file containing the keystore password |
keystore |
Path to a keystore file or directory |
account |
Account name when using the default keystore directory |
These options can be set either from CLI or hardhat config. If account is provided, keystore can be omitted.
In your Hardhat config:
module.exports = {
migrate: {
castWallet: {
account: "test-0",
passwordFile: "./password",
}
}
}Or via command line:
npx hardhat migrate --network sepolia --account test-0 --password-file ./passwordNote
If an account or keystore is provided, the plugin will try to use cast to sign transactions.
Note
If you don't specify password-file, the plugin will invoke prompt, and the user have to enter the password for each transaction, which requires signature.
You can store passwords in a .env file:
PASSWORD_TEST_0=password123Important
The plugin expects the environment variable name to contain the account name itself.
If your account is named test-0 or test_0, the plugin will look for an environment variable named PASSWORD_TEST_0.
When using .env files, you'll need to load these environment variables into your application using a package like dotenv:
import * as dotenv from "dotenv";
dotenv.config();Alternatively, you can export passwords directly in your CLI before deployment:
export PASSWORD_TEST_0=password123Note
For security reasons, avoid hardcoding passwords in files that are version-controlled. Consider using environment-specific configuration files that are excluded from your repository. Also do not forget to escape special characters in your password if needed.
The Trezor integration allows signing transactions with a Trezor hardware wallet for enhanced security.
| Option | Description |
|---|---|
enabled |
Flag to enable/disable Trezor wallet usage |
mnemonicIndex |
Index for the account derivation path (default: 0) |
- The integration uses the standard Ethereum derivation path:
m/44'/60'/0'/0/{index} - Initial connection requires user interaction with the device to confirm access
In your Hardhat config:
module.exports = {
migrate: {
trezorWallet: {
enabled: true,
mnemonicIndex: 0
}
}
}Or via command line:
npx hardhat migrate --network sepolia --trezor-enabled --trezor-mnemonic-index 5- Uses Node.js
child_processto execute cast commands - Provides wrapped functions to interact with cast's wallet functionality
- Automatically handles command construction with appropriate flags
- Uses the official
@trezor/connectlibrary - Provides initialization, address retrieval, and transaction signing