Skip to main content

Deploy Smart Contracts to TeQoin L2

Deploy your Solidity smart contracts to TeQoin L2 using your favorite development framework.
What You’ll Learn:
  • Deploy with Hardhat
  • Deploy with Foundry
  • Deploy with Remix
  • Verify deployment
  • Best practices

🎯 Choose Your Tool

Hardhat

Most PopularJavaScript-based frameworkDeploy →

Foundry

Fast & ModernRust-based frameworkDeploy →

Remix

Browser-BasedNo installation neededDeploy →

🔨 Deploy with Hardhat

Hardhat is the most popular Ethereum development framework.

Prerequisites

Step 1: Create New Project

1

Initialize Project

2

Initialize Hardhat

This creates:
3

Install Dependencies

Step 2: Configure for TeQoin

1

Create .env File

Add your private key:
.env
Never commit .env to Git! Add it to .gitignore:
2

Configure hardhat.config.js

hardhat.config.js

Step 3: Write Your Contract

contracts/MyToken.sol

Step 4: Compile Contract

Step 5: Create Deployment Script

scripts/deploy.js

Step 6: Deploy to TeQoin

Contract deployed to testnet!

Step 7: Verify Deployment

Learn more about verification →

⚒️ Deploy with Foundry

Foundry is a blazing fast, modern development framework written in Rust.

Prerequisites

Step 1: Create New Project

Step 2: Configure for TeQoin

foundry.toml

Step 3: Write Your Contract

src/MyToken.sol

Step 4: Install Dependencies

Step 5: Compile Contract

Step 6: Create Deployment Script

script/Deploy.s.sol

Step 7: Deploy to TeQoin

Contract deployed and verified!

Foundry Useful Commands


🌐 Deploy with Remix

Remix is a browser-based IDE - no installation required!

Step 1: Open Remix

Visit https://remix.ethereum.org

Step 2: Create Contract

1

Create New File

  1. In the File Explorer, click ”+” to create new file
  2. Name it MyToken.sol
2

Write Contract

Step 3: Compile

1

Select Compiler

  1. Click “Solidity Compiler” tab (left sidebar)
  2. Select compiler version: 0.8.20
  3. Click “Compile MyToken.sol”
2

Verify Compilation

✅ Green checkmark appears when compilation succeeds

Step 4: Connect Wallet

1

Open Deploy Tab

Click “Deploy & Run Transactions” tab
2

Select Environment

In “ENVIRONMENT” dropdown, select:
  • “Injected Provider - MetaMask”
3

Connect MetaMask

  1. MetaMask popup appears
  2. Select account
  3. Click “Connect”
  4. Make sure you’re on TeQoin L2 network in MetaMask

Step 5: Deploy

1

Select Contract

In “CONTRACT” dropdown, select MyToken
2

Click Deploy

  1. Click orange “Deploy” button
  2. MetaMask popup appears
  3. Review transaction
  4. Click “Confirm”
3

Verify Deployment

  • Contract appears under “Deployed Contracts”
  • You can interact with it directly in Remix
  • Copy contract address for use in your dApp
Contract deployed!

💰 Deployment Costs

Estimated Gas Costs

Much cheaper than Ethereum L1 where the same deployments would cost $50-500+!

✅ Post-Deployment Checklist

1

Save Contract Address

2

Verify on Explorer

Visit https://explorer.teqoin.io/address/YOUR_ADDRESSVerify:
  • ✅ Contract created successfully
  • ✅ Transaction shows “Success”
  • ✅ Contract code is visible (after verification)
3

Test Contract Functions

Or use Foundry:
4

Verify Contract Source

Verify your contract source code on the explorer:Contract Verification Guide →

🔧 Troubleshooting

You don’t have enough ETH to pay for deployment gas.Solution:
  • For testnet: Get ETH from faucet
  • For mainnet: Bridge ETH from L1 to L2
  • Check balance: cast balance YOUR_ADDRESS --rpc-url teqoin
Your wallet’s nonce is out of sync.Solution:
  • Reset MetaMask: Settings → Advanced → Clear activity tab data
  • Or wait a few minutes and try again
The explorer indexer might be delayed.Solution:
  • Wait 1-2 minutes
  • Refresh the explorer page
  • Check the transaction hash directly
Your contract is too large (> 24KB limit).Solution:
  • Enable optimizer in compiler settings
  • Split contract into multiple contracts
  • Use libraries to reduce size
Environment variable not set correctly.Solution:

📊 Deployment Comparison


🎯 Next Steps

Verify Your Contract

Verify source code on block explorer

Integrate with Frontend

Connect your contract to a dApp

Write Tests

Test your contract thoroughly

Deploy to Mainnet

After testing, deploy to production

💡 Best Practices

Always Deploy to Testnet First
  1. Deploy to testnet
  2. Test all functions
  3. Get community feedback
  4. Audit if handling significant value
  5. Only then deploy to mainnet
Use Environment VariablesNever hardcode private keys in your code:
Keep Deployment RecordsMaintain a file with all your deployments:
deployments.txt

Contract deployed? Now verify it on the block explorer