celo-org / celo-org/celo-composer
Foundry template: root contracts:deploy:* scripts fail — no private key reaches forge script
- Dominant language
- TypeScript
- Stars
- 188
- Forks
- 189
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 4
Description
## What happens
In a Foundry scaffold, the root deploy scripts fail even with `apps/contracts/.env` filled in:
```bash
pnpm contracts:deploy:celo-sepolia
# → forge script ... --broadcast fails on the default-sender check (no key provided)
```
## Root cause
`templates/contracts/foundry/package.json.hbs` wraps `forge script script/Counter.s.sol:CounterScript --rpc-url celo-sepolia --broadcast` with no key forwarding, `Counter.s.sol` calls bare `vm.startBroadcast()` (no `vm.envUint("PRIVATE_KEY")`), and turbo doesn't source `.env` — so no signer ever reaches forge. The direct invocation documented in the README and `docs/integrations/contracts/foundry.mdx` (with explicit `--private-key $PRIVATE_KEY`) works; the wrapped `pnpm contracts:deploy:*` convenience scripts do not.
## Suggested fix
Either read the key in the script (`uint256 pk = vm.envUint("PRIVATE_KEY"); vm.startBroadcast(pk);` — forge auto-loads `.env` from the project root) or document the two `contracts:deploy:*` scripts as requiring the key inline. The hardhat template's deploy scripts read `PRIVATE_KEY` from env via the config, so the env-read approach would bring the two frameworks to parity.
Noted during the #459 docs review — the docs now faithfully describe the template, so this is the template-side half.
Contributor guide
Research direction
Start with templates/contracts/foundry/package.json.hbs and the Counter.s.sol deployment script, then compare the working direct command in README and docs/integrations/contracts/foundry.mdx. Run pnpm contracts:deploy:celo-sepolia with a configured apps/contracts/.env; done means the root convenience scripts pass a signer to forge consistently with the documented deployment flow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell, solidity
- Domain
- blockchain, build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100