Overview
deBridge contracts use Hardhat Deploy for deterministic, upgradeable deployments across multiple networks.
Deployment Scripts
Deployment scripts are located in scripts/deploy/:
scripts/deploy/
├── 00_external.js # External dependencies
├── 01-0_DeBridgeGate.js # Main gate contract
├── 01-1_DeBridgeToken.js # Token implementation
├── 01-2_DeBridgeTokenDeployer.js # Token deployer
├── 02_SignatureVerifier.js # Signature verifier
├── 03_CallProxy.js # Call proxy
├── 04_FeeProxy.js # Fee proxy
├── 05_wethGate.js # WETH gate
├── 06_DeBridgeGateSetup.js # Gate configuration
├── 07_DeBridgeTokenDeployerSetup.js
├── 08_SignatureVerifierSetup.js
└── 09_transfer_admin_role.js # Admin role transfer
Deploying to Testnet
Configure Network
Update hardhat.config.ts with network details: networks : {
goerli : {
url : process . env . GOERLI_RPC_URL ,
accounts : [ process . env . DEPLOYER_PRIVATE_KEY ],
chainId : 5
},
bsctest : {
url : 'https://data-seed-prebsc-1-s1.binance.org:8545' ,
accounts : [ process . env . DEPLOYER_PRIVATE_KEY ],
chainId : 97
}
}
Fund Deployer Wallet
Ensure your deployer wallet has enough native tokens for gas:
Run Deployment
Deploy all contracts: yarn hardhat deploy --network goerli
Or deploy specific scripts: Deploy Specific Contracts
yarn hardhat deploy --network goerli --tags DeBridgeGate
Verify Deployment
Check deployed addresses: yarn hardhat run scripts/verify-deployment.js --network goerli
Deployment Configuration
Environment Variables
# Deployer
DEPLOYER_PRIVATE_KEY = 0x...
MULTISIG_ACCOUNT = 0x... # For admin role transfer
# Network RPCs
GOERLI_RPC_URL = https://...
BSC_TESTNET_RPC_URL = https://...
POLYGON_MUMBAI_RPC_URL = https://...
# Block Explorers
ETHERSCAN_API_KEY = ...
BSCSCAN_API_KEY = ...
POLYGONSCAN_API_KEY = ...
# Protocol Parameters
EXCESS_CONFIRMATIONS = 5
GLOBAL_FIXED_NATIVE_FEE = 1000000000000000 # 0.001 ETH in wei
GLOBAL_TRANSFER_FEE_BPS = 10 # 0.1%
Deployment Parameters
Edit deployment scripts to customize:
module . exports = async ({ getNamedAccounts , deployments }) => {
const { deploy } = deployments ;
const { deployer } = await getNamedAccounts ();
const debridgeGate = await deployments . get ( 'DeBridgeGate' );
// Set global fees
await debridgeGate . updateGlobalFee (
ethers . utils . parseEther ( '0.001' ), // Fixed fee
10 // 0.1% transfer fee
);
// Configure supported chains
await debridgeGate . updateChainSupport (
56 , // BSC
true , // Supported
true // Can receive from this chain
);
};
Upgrading Contracts
DeBridgeGate and other core contracts are upgradeable using OpenZeppelin’s transparent proxy pattern.
Upgrade Process
# Deploy new implementation
yarn hardhat run scripts/upgrade/upgrade-gate.js --network goerli
Upgrade Script Example
const { ethers , upgrades } = require ( 'hardhat' );
async function main () {
const proxyAddress = '0x...' ; // Current proxy address
const DeBridgeGateV2 = await ethers . getContractFactory ( 'DeBridgeGateV2' );
console . log ( 'Upgrading DeBridgeGate...' );
const upgraded = await upgrades . upgradeProxy ( proxyAddress , DeBridgeGateV2 );
console . log ( 'DeBridgeGate upgraded' );
console . log ( 'New implementation:' , await upgrades . erc1967 . getImplementationAddress ( upgraded . address ));
}
main (). catch (( error ) => {
console . error ( error );
process . exitCode = 1 ;
});
Always test upgrades on testnet first. Upgrades are irreversible on mainnet.
Multi-Chain Deployment
Deploy to multiple networks:
# Ethereum
yarn hardhat deploy --network mainnet --tags core
# BSC
yarn hardhat deploy --network bsc --tags core
# Polygon
yarn hardhat deploy --network polygon --tags core
# Arbitrum
yarn hardhat deploy --network arbitrum --tags core
Coordinating Multi-Chain Setup
After deploying on all chains, configure cross-chain support:
// On Ethereum
await debridgeGateEth . updateChainSupport ( 56 , true , true ); // BSC
await debridgeGateEth . updateChainSupport ( 137 , true , true ); // Polygon
// On BSC
await debridgeGateBsc . updateChainSupport ( 1 , true , true ); // Ethereum
await debridgeGateBsc . updateChainSupport ( 137 , true , true ); // Polygon
// Repeat for each chain...
Deployment Checklist
Mainnet Deployment
Mainnet deployment requires extreme caution. Triple-check all parameters and have multiple team members review.
Additional Mainnet Steps
Security Review : Have contracts audited by reputable firms
Testnet Validation : Deploy and test on all testnets for at least 1 week
Emergency Procedures : Document pause and recovery procedures
Monitoring : Set up alerting for key events and metrics
Multisig Setup : Use Gnosis Safe with multiple signers
Time Delays : Consider adding time delays for admin operations
# Final checks
yarn hardhat compile
yarn test
yarn coverage
# Deploy
yarn hardhat deploy --network mainnet
# Verify immediately
yarn hardhat run scripts/verify-all.js --network mainnet
Verification
After deployment, verify contract source code on block explorers.
yarn hardhat verify --network goerli DEPLOYED_ADDRESS "Constructor Arg 1" "Arg 2"
Go to block explorer (Etherscan, BSCscan, etc.)
Find your contract
Click “Contract” tab
Click “Verify and Publish”
Select “Solidity (Single File)”
Paste flattened source code
Enter compiler version and settings
Submit
See Contract Verification guide for detailed instructions.
Troubleshooting
Deployment fails with 'nonce too low'
Transaction nonce is out of sync. Solution :yarn hardhat clean
# Try deployment again
Insufficient funds for gas
Deployer wallet needs more native tokens. Solution : Send more ETH/BNB/MATIC to deployer address.
Contract size exceeds 24KB
Contract is too large for deployment. Solutions :
Enable optimizer with higher runs:
solidity : {
settings : {
optimizer : {
enabled : true ,
runs : 200
}
}
}
Split contract into libraries
Remove unused functions
Development Setup Configure your environment
Contract Verification Verify deployed contracts
Testing Test contracts before deployment
Architecture Understand the system design