Skip to main content

Deploy Contracts on Morph

The Morph Sepolia Testnet allows anyone to deploy a smart contract on Morph. In this tutorial, you will learn how to deploy a contract on Morph Sepolia using common tools for developing on Ethereum.

This demo repo illustrates contract deployment with Hardhat and Foundry.


Before you start deploying the contract, you need to request test tokens from a Sepolia faucet and use the bridge to transfer some test ETH from Sepolia to Morph Sepolia.

Or you can direct obatin Morph sepolia ETH for testing.

See our Faucet for details.

Hardhat Contract Deployment Examples

Install Dependencies

If you haven't already, install nodejs and yarn.

cd contract-deployment-demos/hardhat-demo
yarn install

This will install everything you need include hardhat for you.


Compile your contract

yarn compile


This will run the test script in test/Lock.ts

yarn test


Create a .env file following the example .env.example in the root directory. Change PRIVATE_KEY to your own account private key in the .env.

And Change the network settings in the hardhat.config.ts file with the following information:

 morphTestnet: {
url: process.env.MORPH_TESTNET_URL || "",
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],

Then run the following command to deploy the contract on the Morph Sepolia Testnet. This will run the deployment script that set the initialing parameters, you can edit the script in scripts/deploy.ts

yarn deploy:morphTestnet

Verify your contracts on Morph Explorer

To verify your contract through hardhat, you need to add the following Etherscan and Sourcify configs to your hardhat.config.js file:

module.exports = {
networks: {
morphSepolia: { ... }
etherscan: {
apiKey: {
morphTestnet: 'anything',
customChains: [
network: 'morphTestnet',
chainId: 2710,
urls: {
apiURL: ' ',
browserURL: '',

Then run the hardhat verfiy command to finish the verification

npx hardhat verify --network morphTestnet DEPLOYED_CONTRACT_ADDRESS <ConstructorParameter>

For example

npx hardhat verify --network morphTestnet 0x8025985e35f1bAFfd661717f66fC5a434417448E '0.00001'

Once succeed, you can check your contract and the deployment transaction on Morph Sepolia Explorer

Foundry Contract Deployment Examples

Install Foundry

curl -L | bash

Then go the right folder of our example:

cd contract-deployment-demos/foundry-demo


forge build


A Deployment script and use of environment variables has already been set up for you. You can view the script at script/Counter.s.sol

Rename your .env.example file to .env and fill in your private key. The RPC URL has already been filled in along with the verifier URL.

To use the variables in your .env file run the following command:

source .env

You can now deploay to Morph with the following command:

forge script script/Counter.s.sol --rpc-url $RPC_URL --broadcast --private-key $DEPLOYER_PRIVATE_KEY --legacy

Adjust as needed for your own script names.


Verification requires some flags passed to the normal verification script. You can verify using the command below:

 forge verify-contract <YourConrtactAddress Counter\
--chain 2710 \
--verifier-url $VERIFIER_URL \
--verifier blockscout --watch

Once succeed, you can check your contract and the deployment transaction on Morph Sepolia Explorer

Questions and Feedback

Thank you for participating in and developing on the Morph Sepolia Testnet! If you encounter any issues, join our Discord and find us at #dev-help channel.