Hiw to deploy a smart contract on Lisk

To deploy a smart contract on Lisk, you can use several popular Ethereum development tools, including Hardhat, Foundry, Remix, or thirdweb. Below are the general steps for each method, based on the official Lisk documentation:


1. Using Hardhat

Prerequisites:

  • Node.js v18+ installed.
  • Fund your wallet with ETH (for gas fees) via the Lisk Bridge or a Sepolia faucet.
  • Set up your Hardhat project and configure the Lisk network in hardhat.config.ts.

Deployment Steps:

  1. Write your smart contract (e.g., NFT.sol).

  2. Compile your contract with Hardhat.

  3. Create a deployment script (e.g., scripts/deploy.ts):

    import { ethers } from 'hardhat';
    
    async function main() {
      const nft = await ethers.deployContract('NFT');
      await nft.waitForDeployment();
      console.log('NFT Contract Deployed at ' + nft.target);
    }
    
    main().catch((error) => {
      console.error(error);
      process.exitCode = 1;
    });
    
  4. Deploy to Lisk Sepolia or Mainnet:

    npx hardhat run scripts/deploy.ts --network lisk-sepolia
    

    or

    npx hardhat run scripts/deploy.ts --network lisk
    

Deploying a smart contract with Hardhat


2. Using Foundry

Prerequisites:

  • Install Foundry and fund your wallet with ETH.
  • Write your contract (e.g., src/NFT.sol).

Deployment Command:

forge create --rpc-url https://rpc.sepolia-api.lisk.com \
--etherscan-api-key 123 \
--verify \
--verifier blockscout \
--verifier-url https://sepolia-blockscout.lisk.com/api \
--private-key <PRIVATE_KEY> \
src/NFT.sol:NFT

Replace <PRIVATE_KEY> with your wallet’s private key.

This command deploys and verifies your contract on Lisk Sepolia. For mainnet, use the mainnet RPC and BlockScout URLs.
Deploying a smart contract with Foundry


3. Using Remix

Steps:

  1. Open Remix IDE.
  2. Write or paste your Solidity contract.
  3. Compile the contract (ensure the compiler version matches your pragma).
  4. In the “Deploy & run transactions” tab, set the environment to “Injected Provider” and connect your wallet to Lisk or Lisk Sepolia.
  5. Deploy the contract and confirm the transaction in your wallet.
  6. The deployed contract address will appear in the Remix logs; you can view it on Lisk Blockscout.
    Deploying a smart contract with Remix

4. Using thirdweb

Steps:

  1. Create a project using thirdweb CLI:

    npx thirdweb create
    
  2. Choose your framework (Forge/Foundry or Hardhat), contract type, and options.

  3. Write or customize your contract.

  4. Deploy with:

    npx thirdweb deploy
    
  5. Complete deployment in the browser as prompted.
    Deploying a smart contract with thirdweb


Note:

  • Always ensure your wallet is connected to the correct Lisk network and has enough ETH for gas fees.
  • After deployment, you can verify your contract on BlockScout for transparency and interaction.

Hope this is helpful
Remember you can make corrections under here

3 Likes