solidity-deploy

Original🇺🇸 English
Translated

[AUTO-INVOKE] MUST be invoked BEFORE deploying contracts or writing deployment scripts (*.s.sol). Covers pre-flight checks, forge script commands, post-deployment validation, and verification. Trigger: any task involving forge script, contract deployment, or block explorer verification.

7installs
Added on

NPX Install

npx skill4agent add 0xlayerghost/solidity-agent-kit solidity-deploy

Deployment Workflow

Language Rule

  • Always respond in the same language the user is using. If the user asks in Chinese, respond in Chinese. If in English, respond in English.

Pre-deployment Checklist (all must pass)

StepCommand / Action
Format code
forge fmt
Run all tests
forge test
— zero failures required
Check gas report
forge test --gas-report
— review critical functions
Verify configManually check
config/*.json
parameters
Dry-run
forge script <Script> --fork-url <RPC_URL> -vvvv
(no
--broadcast
)
Check balance
cast balance <DEPLOYER> --rpc-url <RPC_URL>
— sufficient gas?
Gas limit setDeployment command must include
--gas-limit

Deployment Decision Rules

SituationRule
Default deploymentNo
--verify
— contracts are not verified on block explorers by default
User requests verificationAdd
--verify
and
--etherscan-api-key
to the command
Post-deploy verificationUse
forge verify-contract
as a separate step
Multi-chain deploySeparate scripts per chain, never batch multiple chains in one script
Proxy deploymentDeploy implementation first, then proxy — verify both separately

Post-deployment Operations (all required)

  1. Update addresses in
    config/*.json
    and
    deployments/latest.env
  2. Test critical functions:
    cast call
    to verify on-chain state is correct
  3. Record changes in
    docs/CHANGELOG.md
  4. Submit PR with deployment transaction hash link
  5. If verification needed, run
    forge verify-contract
    separately

Key Security Rule

  • Never pass private keys directly in commands. Use Foundry Keystore (
    cast wallet import
    ) to manage keys securely.
  • Never include
    --broadcast
    in templates.
    The user must explicitly add it when ready to deploy.

Command Templates

bash
# Dry-run (simulation only, no on-chain execution)
forge script script/Deploy.s.sol:DeployScript \
  --rpc-url <RPC_URL> \
  --gas-limit 5000000 \
  -vvvv

# When user is ready to deploy, instruct them to add:
#   --account <KEYSTORE_NAME> --broadcast

# Verify existing contract separately
forge verify-contract <ADDRESS> <CONTRACT> \
  --chain-id <CHAIN_ID> \
  --etherscan-api-key <API_KEY> \
  --constructor-args $(cast abi-encode "constructor(address)" <ARG>)

# Quick on-chain read test after deployment
cast call <CONTRACT_ADDRESS> "functionName()" --rpc-url <RPC_URL>