Deploy a Smart Contract
Learn how to deploy a smart contract on Unichain
This guide will walk you through the process of deploying a smart contract on the Unichain network.
Requirements
ETH on Unichain is required, see Funding a Wallet
-
The guide uses foundry for deployments. Install it by running:
curl -L https://foundry.paradigm.xyz | bash
To verify the installation:
forge --version
-
Add Unichain to your
foundry.toml
[rpc_endpoints] unichain = "https://sepolia.unichain.org"
Steps to Deploy
Due to the EVM-equivalence of Unichain, foundry commands should work as expected. The major difference is the network URL. In most cases, using --rpc-url unichain
is sufficient
-
Navigate to your smart contract project
cd path/to/your/project
-
Deploying a smart contract
Your private key should have ETH on the Unichain network. A transaction will be created, and requires a gas fee.
forge create src/{YourContract}.sol:{ContractName} --rpc-url unichain --private-key {YourPrivateKey}
-
Contract Verification
Obtain an API key from https://sepolia.uniscan.xyz
There are two options to verify your contract:
- During deployment
- After deployment
During deployment provide additional flags:
--etherscan-api-key {API_KEY} --verify
After deployment:
forge verify-contract \ --chain-id 1301 \ --num-of-optimizations 200 \ --watch \ --constructor-args $(cast abi-encode "constructor(string,string,uint256,uint256)" "ForgeUSD" "FUSD" 18 1000000000000000000000) \ --etherscan-api-key {your_etherscan_api_key} \ --compiler-version {v0.8.20+commit.a1b79de} {the_contract_address} \ src/{YourContract}.sol:{ContractName}
Additional information here or other deployment options
Example Deployment
See deploying an ERC-20 contract
Best Practices
-
Verification
Verifying during deployment is recommended, as compilation parameters are known during execution
-
Scripting
For complex deployments, such as deploying multiple related contracts, complex constructor arguments, or create & call patterns, it is recommended to use foundry's solidity scripting
Create a Pool
Learn how to create a trading pool on Unichain
Deploy a SuperchainERC20 Token (Using thirdweb)
Learn how to deploy a SuperchainERC20 token with thirdweb Modular Contracts.
Deploy a SuperchainERC20 Token
Learn how to deploy a SuperchainERC20 contract on Unichain
Building on Unichain
This section provides guides and information for developers building on Unichain.
Routing on Unichain
Learn how to access and route liquidity across Unichain using Tycho.
Building a Subgraph
Learn how to build a subgraph to query Unichain data
Using USDC on Unichain
Learn how to set up and transfer USDC on Unichain
Last updated on