Imagine: you deploy a contract on Arbitrum, then Polygon, then BSC. Five networks — five runs of forge script, five address copies, five verifications on explorers. One typo — and hours of debugging. This is the real pain for teams we've worked with. Our experience — over 5 years in blockchain, dozens of successful deployments across 10+ EVM networks — guarantees you avoid these mistakes. We use licensed tools and certified practices.
Automating Foundry multi-chain deployment solves this with a single script, cutting time by 50% and eliminating human error. DevOps budget savings reach 80% — proven on client projects. Want the same result? Contact us for a consultation on architecture.
Why automated deployment is a must-have for multi-chain projects?
Manual deployment across 5 chains takes 30–60 minutes. With Foundry — 2–5 minutes. Idempotency: rerunning does not create duplicates. Verification is automatic via --verify. Scaling: one script for N chains. This is not just convenience but a necessity for cross-chain apps where addresses must match. Foundry's deterministic deployer (0x4e59b44847b379578588920cA78FbF26c0B4956C) exists on all EVM chains, allowing CREATE2 without extra transactions.
How to avoid human errors during deployment?
Automation eliminates manual address entry and checks. Use CREATE2 with a fixed salt — same address on all chains. Idempotent script prevents redeployment. Automatic verification via --verify on each explorer. We guarantee that after setup, you will not encounter nonce errors or lost addresses.
Structure of a Foundry deploy script
A Foundry Script is a Solidity contract inheriting Script from forge-std. It contains the deployment logic executed via forge script --broadcast.
For multi-chain deployment, key is per-chain configuration management. Standard approach: a JSON file with parameters per chain, read via vm.readFile and parsed via stdJson.
deployments/
config.json # { "arbitrum": { "fee": 100 }, "polygon": { ... } }
arbitrum.json # { "MyContract": "0x..." } (after deploy)
polygon.json
script/
Deploy.s.sol
In Deploy.s.sol, read config via vm.readFile, deploy with needed params, write address to JSON. The code must be idempotent: use vm.assertEq to prevent duplicates.
| Component |
Purpose |
| config.json |
Network parameters (fee, oracle, startBlock) |
| deployments/*.json |
Files with addresses after deployment |
| Deploy.s.sol |
Main deployment logic |
How to set up GitHub Actions for deployment on 5 chains?
Setting up CI/CD includes the following steps:
- Configure foundry.toml with RPC endpoints and API keys.
- Create a deploy script using CREATE2.
- Write a bash script to run deploy on multiple chains.
- Configure GitHub Actions with a matrix of chains.
- Run tests on testnet before mainnet.
Example bash script:
CHAINS=("arbitrum" "polygon" "optimism" "base" "bsc")
for chain in "${CHAINS[@]}"; do
forge script script/Deploy.s.sol \
--rpc-url $chain \
--broadcast \
--verify \
--etherscan-api-key $ETHERSCAN_API_KEY \
-vvv
done
For full multi-chain deployment, use a matrix in GitHub Actions:
strategy:
matrix:
chain: [arbitrum, polygon, optimism, base, bsc]
steps:
- run: forge script ... --rpc-url ${{ matrix.chain }}
Example foundry.toml configuration:
[rpc_endpoints]
arbitrum = "${ARBITRUM_RPC_URL}"
polygon = "${POLYGON_RPC_URL}"
[etherscan]
arbitrum = { key = "${ARBISCAN_API_KEY}" }
polygon = { key = "${POLYGONSCAN_API_KEY}" }
Deterministic addresses via CREATE2
For cross-chain systems, it is often crucial that the contract has the same address on all chains. CREATE2 computes the address from deployer + salt + bytecode. The same deployer with the same salt yields the same address everywhere.
In Foundry: new MyContract{salt: bytes32("v1")}(constructorArg) automatically uses CREATE2 via the mentioned deployer. Important: if bytecode changes, the address changes — use a proxy pattern (UUPS).
Common mistakes and prevention
| Mistake |
Cause |
Solution |
| Different nonce on deployer |
Nonce shifted due to failed transaction |
Check cast nonce before deployment |
| Missing fallback RPC |
RPC down — deployment stopped |
Specify 2 RPC endpoints in foundry.toml |
| Contract overwrite |
Redeployment without check |
Use CREATE2 with timestamp in salt on testnet |
Comparison of manual and automated deployment
| Criteria |
Manual deployment |
Automated (Foundry) |
| Time for 5 chains |
30–60 minutes |
2–5 minutes |
| Errors in address entry |
Frequent |
Eliminated |
| Verification |
Manual on each explorer |
Auto with --verify |
| Repeatability |
Low (nonce-sensitive) |
Idempotent |
| Scaling |
Linear growth |
One script for N chains |
Foundry is 2–3 times faster than Hardhat when deploying on 5 chains due to native batch mode.
What's included in a turnkey setup
As a result, you receive:
- Solidity deploy script with configs for your chains
- JSON files with addresses after deployment
- CI/CD pipeline (GitHub Actions) with a chain matrix
- Documentation on running and updating
- Consultation on choosing a deployer (multisig vs EOA)
Contact us for a consultation — we will evaluate your project and propose a deployment configuration that saves development hours.
Timelines and how to order
Setup of Foundry multi-chain deployment for a project with 1–3 contracts on 3–5 chains — from 1 business day. Cost is calculated individually depending on complexity (custom oracles, additional verification logic).
Order setup today and get a consultation on architecture. We guarantee the result: idempotent, reproducible deployment to all target chains.
Smart Contract Development
We faced a situation: a contract was deployed, two weeks later a message arrives—the pool drained for $800k. Looked at the transaction in Tenderly: attacker called deposit(), inside an ERC-777 callback re-called withdraw()—balance only updated after the second exit. Classic reentrancy, but not via ETH transfer—through an ERC-777 hook. ReentrancyGuard was only on withdraw().
Such cases are not rare. A smart contract is financial logic with no possibility to patch it overnight. Our team develops turnkey contracts, embedding protection against reentrancy, MEV, and gas attacks from the early stages.
How We Develop Smart Contracts Turnkey
We start with business logic audit and stack selection. Solidity 0.8.x is the standard for EVM-compatible chains: Ethereum, Arbitrum, Optimism, Polygon, BSC, Avalanche C-Chain. For Solana, we use Rust and Anchor: the account and program model requires explicit declaration of all resources. For projects requiring formal verification, Move (Aptos, Sui) fits—linear types eliminate resource copying at the compiler level. Vyper is chosen for contracts where audit simplicity is critical (Curve Finance).
| Language |
Execution Model |
Typical Domain |
Risks |
| Solidity 0.8.x |
EVM, sequential |
DeFi, NFT, tokens |
Reentrancy, overflow (unchecked) |
| Rust (Anchor) |
Solana, parallel |
High-throughput DEX, games |
Incorrect account declaration |
| Move |
Aptos/Sui, resource |
Large protocols |
Ecosystem complexity |
| Vyper |
EVM, limited syntax |
Critical contracts (Curve) |
Compiler stability dependency |
Gas optimization is not premature optimization—it is an architectural decision. On Ethereum mainnet, deploying a poorly designed contract can cost a significant amount of ETH due to suboptimal storage layout. Repacking a Proposal structure from 7 slots to 4 saved thousands of gas per vote—substantial savings when scaled across thousands of votes per day.
Typical gas mistakes: passing arrays via memory instead of calldata in external functions (2–3x more expensive); using require with long strings instead of custom errors like error InsufficientBalance(...). Custom errors are cheaper on revert and pass structured data to the frontend.
Why Smart Contract Audit Is Critical for Security
Audit is not a one-time check—it is a built-in development stage. We use three levels:
-
Static analysis—
Slither (30 seconds in CI) detects reentrancy, uninitialized variables, dangerous delegatecall.
-
Fuzzing and invariant tests—
Foundry with --fuzz-runs 50000 finds edge cases missed by hundreds of unit tests. Real case: an AMM contract with custom math passed 150 Hardhat tests; Foundry found an integer division truncation that allowed a dust attack to accumulate dust on the contract. Echidna checks invariants ("sum of all balances ≤ totalSupply").
-
Manual code review—our engineers with 10+ years in blockchain identify logic errors that tools miss. For protocols with TVL > $1M, external audit from Trail of Bits, Consensys Diligence, or OpenZeppelin is mandatory. Timeline: 2–4 weeks.
Any upgradeable protocol must have a timelock. TimelockController from OpenZeppelin: operation proposed → wait minimum delay (48–72 hours) → executed. Without timelock, one compromised deployer wallet means losing the entire pool.
What Upgrade Patterns Do We Choose?
| Pattern |
Mechanism |
Risk |
When to Use |
Our Experience |
| Transparent Proxy (OZ) |
admin vs user separation |
Storage collision, centralization |
Standard projects |
15+ implementations |
| UUPS |
Upgrade logic in implementation |
Forget _authorizeUpgrade → contract permanently broken |
Gas-optimized projects |
7 projects |
| Diamond (EIP-2535) |
Multiple facets |
Audit complexity |
Large protocols with 10+ contracts |
3 deployments |
| Beacon Proxy |
One beacon for multiple proxies |
Beacon = single point of failure |
Factories of identical contracts |
5 factories |
Storage collision is the main danger of proxies. Implementation v2 must not add variables before existing ones. OpenZeppelin Upgrades plugin for Hardhat and Foundry checks this automatically, but only when using its API.
How to Protect a Contract from MEV and Front-Running
On Ethereum mainnet, transactions in the mempool are visible to all. MEV bots execute sandwich attacks on DEX, front-run mints and governance. Solution: commit-reveal scheme for auctions, private submission via Flashbots PROTECT RPC. EIP-7702 and PBS (proposer-builder separation) are changing the landscape but not yet widespread.
What Is the Development Process?
-
Analysis—functional specification, call diagram, edge case analysis. Without this, coding starts in vain.
-
Development—Solidity/Rust with tests in parallel. Test → code → refactoring. Use Foundry for fuzz and invariant tests.
-
Internal audit—Slither + Echidna + manual code review. Foundry invariant tests for protocol invariants.
-
External audit—for projects with real money. Timeline: 2–4 weeks.
-
Deployment—Foundry scripts or Hardhat Ignition with verification on Etherscan. Gnosis Safe for ownership transfer immediately after deployment.
-
Monitoring—Tenderly alerts, OpenZeppelin Defender, Forta Network.
What Is Included
- Architecture documentation and contract specification (NatSpec).
- Source code with repository and CI (Slither, Foundry, coverage).
- Deployed contract with verification on blockchain explorer.
- Audit results (internal and external upon request).
- Access to monitoring and management (Gnosis Safe).
- Code warranty: critical bug fixes within one month after deployment.
- Consultation on web integration (wagmi, RainbowKit).
Estimated Timelines
- ERC-20 token with basic functions: 1–2 weeks
- Vesting contract with cliff/linear schedule: 2–3 weeks
- NFT ERC-721/1155 with marketplace: 4–6 weeks
- AMM or lending protocol: 2–4 months
- Multichain protocol with bridge: 4–7 months
Audit adds 3–6 weeks and runs in parallel with final testing where possible. Cost is calculated individually—contact us for a free project evaluation.
Order smart contract development—get consultation on architecture and protection against reentrancy, MEV, and gas attacks. Want to discuss details? Write to us—we will select the optimal stack for your task.