Deploying Smart Contracts to Avalanche
Avalanche is not one chain but three: C-Chain (EVM-compatible, where smart contracts deploy), X-Chain (UTXO for native AVAX), P-Chain (validator node management). For Solidity contract deployment we work exclusively with C-Chain. Tooling is identical to Ethereum — same Hardhat, Foundry, same ABI and bytecode. Difference in RPC endpoint, chainId and nuances of gas model.
Chain Parameters
Mainnet C-Chain:
- RPC:
https://api.avax.network/ext/bc/C/rpc - Chain ID:
43114 - Explorer: snowtrace.io (Etherscan fork)
- Native token: AVAX
- Block time: ~2 seconds
Fuji Testnet:
- RPC:
https://api.avax-test.network/ext/bc/C/rpc - Chain ID:
43113 - Explorer: testnet.snowtrace.io
- Faucet: faucet.avax.network (1 AVAX per day)
Avalanche C-Chain uses EIP-1559 gas model. baseFee changes depending on congestion. Minimum baseFee in practice — 25 nAVAX. Gas significantly cheaper than Ethereum mainnet: deploying a typical ERC-20 contract costs $0.05-0.30 under normal conditions.
Foundry Configuration
In foundry.toml:
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
solc = "0.8.20"
[rpc_endpoints]
avalanche = "https://api.avax.network/ext/bc/C/rpc"
fuji = "https://api.avax-test.network/ext/bc/C/rpc"
[etherscan]
avalanche = { key = "${SNOWTRACE_API_KEY}", url = "https://api.snowtrace.io/api" }
fuji = { key = "${SNOWTRACE_API_KEY}", url = "https://api-testnet.snowtrace.io/api" }
Deployment script:
# Deploy to Fuji testnet
forge script script/Deploy.s.sol:DeployScript \
--rpc-url fuji \
--broadcast \
--verify \
-vvvv
# Deploy to mainnet
forge script script/Deploy.s.sol:DeployScript \
--rpc-url avalanche \
--broadcast \
--verify \
--ledger \ # Hardware wallet for mainnet
-vvvv
--verify verifies the contract on Snowtrace automatically after deployment. Snowtrace uses Sourcify/Etherscan API — works out of the box.
Hardhat Configuration
// hardhat.config.ts
const config: HardhatUserConfig = {
solidity: '0.8.20',
networks: {
fuji: {
url: 'https://api.avax-test.network/ext/bc/C/rpc',
chainId: 43113,
accounts: [process.env.PRIVATE_KEY!],
gasPrice: 'auto',
},
avalanche: {
url: 'https://api.avax.network/ext/bc/C/rpc',
chainId: 43114,
accounts: [process.env.PRIVATE_KEY!],
},
},
etherscan: {
apiKey: {
avalanche: process.env.SNOWTRACE_API_KEY!,
fuji: process.env.SNOWTRACE_API_KEY!,
},
customChains: [
{
network: 'avalanche',
chainId: 43114,
urls: {
apiURL: 'https://api.snowtrace.io/api',
browserURL: 'https://snowtrace.io',
},
},
{
network: 'fuji',
chainId: 43113,
urls: {
apiURL: 'https://api-testnet.snowtrace.io/api',
browserURL: 'https://testnet.snowtrace.io',
},
},
],
},
};
Deployment Pitfalls
AVAX decimals. AVAX has 18 decimals like ETH. Standard gas calculations work without changes. But code must not hardcode Ethereum gas price values — they will be incorrect on Avalanche.
Block gas limit. C-Chain gas limit: 15,000,000 gas per block — identical to Ethereum mainnet. Contracts with size close to 24KB Ethereum limit compile and deploy similarly.
RPC rate limits. Public RPC api.avax.network has rate limits. For production frontend and backend use paid nodes: Infura (supports Avalanche), Alchemy, QuickNode, or own node.
Chainlink on Avalanche. Chainlink Price Feeds, VRF v2 and Automation — all available on C-Chain mainnet. Chainlink VRF v2 on Fuji testnet also available. Chainlink contract addresses differ from Ethereum — always take from docs.chain.link/avalanche.
Avalanche Subnets
If standard C-Chain doesn't fit due to privacy, custom gas token or specific validation rules — Avalanche allows deploying own Subnets. Subnet is independent chain with its own validators, fully EVM-compatible.
Subnet deployment is separate project (genesis setup, validators, bridge to C-Chain). For running production Subnet minimum 5 validators needed, each must also validate C-Chain (Avalanche requirement).
For most projects C-Chain mainnet is sufficient. Subnet — for enterprise or gaming apps with very high TPS requirement or custom fee token.
Timeline Estimates
Deploying existing Ethereum contract to Avalanche C-Chain with verification on Snowtrace — from 4 hours (tooling setup + Fuji test + mainnet deployment). If contract uses Chainlink or other external dependencies — additional day for address correctness verification in Avalanche ecosystem.







