Skip to main content

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

1

Configure Network

Update hardhat.config.ts with network details:
hardhat.config.ts
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
    }
}
2

Fund Deployer Wallet

Ensure your deployer wallet has enough native tokens for gas:
3

Run Deployment

Deploy all contracts:
Deploy to Goerli
yarn hardhat deploy --network goerli
Or deploy specific scripts:
Deploy Specific Contracts
yarn hardhat deploy --network goerli --tags DeBridgeGate
4

Verify Deployment

Check deployed addresses:
yarn hardhat run scripts/verify-deployment.js --network goerli

Deployment Configuration

Environment Variables

.env
# 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:
06_DeBridgeGateSetup.js
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

upgrade-gate.js
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:
Deploy Across Chains
# 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:
configure-chains.js
// 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

1

Pre-Deployment

  • Contracts audited
  • Tests passing with 100% coverage
  • Network configuration verified
  • Deployer wallet funded
  • Multisig wallet configured
2

Deployment

  • Deploy external dependencies (WETH, etc.)
  • Deploy core contracts
  • Deploy periphery contracts
  • Configure contract parameters
  • Transfer admin role to multisig
3

Post-Deployment

  • Verify contracts on block explorers
  • Test basic functionality
  • Configure oracle network
  • Enable supported chains
  • Add initial asset support
  • Monitor first transactions

Mainnet Deployment

Mainnet deployment requires extreme caution. Triple-check all parameters and have multiple team members review.

Additional Mainnet Steps

  1. Security Review: Have contracts audited by reputable firms
  2. Testnet Validation: Deploy and test on all testnets for at least 1 week
  3. Emergency Procedures: Document pause and recovery procedures
  4. Monitoring: Set up alerting for key events and metrics
  5. Multisig Setup: Use Gnosis Safe with multiple signers
  6. Time Delays: Consider adding time delays for admin operations
Mainnet Deployment
# 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"
See Contract Verification guide for detailed instructions.

Troubleshooting

Transaction nonce is out of sync.Solution:
yarn hardhat clean
# Try deployment again
Deployer wallet needs more native tokens.Solution: Send more ETH/BNB/MATIC to deployer address.
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

Build docs developers (and LLMs) love