Description:
The PRIVATE_KEY environment variable is documented in the server instructions (index.ts line 38) as a supported config option, but forge script doesn't actually use it. This causes forge script --broadcast to fail with:
Error: You seem to be using Foundry's default sender. Be sure to set your own --sender.
Root cause:
In src/tools/cast/send.ts (line 31-32), PRIVATE_KEY is correctly read and appended:
typescriptconst privateKey = process.env.PRIVATE_KEY;
let command = ${FOUNDRY_PATHS.castPath} send ${contractAddress} "${functionSignature}" --private-key ${privateKey};
But in src/tools/forge/script.ts, the command is built without it — there's no reference to PRIVATE_KEY anywhere in that file.
Suggested fix:
Add the following before the command is executed in src/tools/forge/script.ts:
typescriptconst privateKey = process.env.PRIVATE_KEY;
if (privateKey) {
command += --private-key ${privateKey};
}
Workaround:
Use vm.envUint("PRIVATE_KEY") inside the Solidity script:
solidityuint256 deployerKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerKey);
Description:
The PRIVATE_KEY environment variable is documented in the server instructions (index.ts line 38) as a supported config option, but forge script doesn't actually use it. This causes forge script --broadcast to fail with:
Error: You seem to be using Foundry's default sender. Be sure to set your own --sender.
Root cause:
In src/tools/cast/send.ts (line 31-32), PRIVATE_KEY is correctly read and appended:
typescriptconst privateKey = process.env.PRIVATE_KEY;
let command =
${FOUNDRY_PATHS.castPath} send ${contractAddress} "${functionSignature}" --private-key ${privateKey};But in src/tools/forge/script.ts, the command is built without it — there's no reference to PRIVATE_KEY anywhere in that file.
Suggested fix:
Add the following before the command is executed in src/tools/forge/script.ts:
typescriptconst privateKey = process.env.PRIVATE_KEY;
if (privateKey) {
command +=
--private-key ${privateKey};}
Workaround:
Use vm.envUint("PRIVATE_KEY") inside the Solidity script:
solidityuint256 deployerKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerKey);