Contract Deployment Tutorial

The Scroll Sepolia Testnet allows anyone to deploy a smart contract on Scroll. In this tutorial, you will learn how to deploy a contract on Scroll Sepolia using common tools for developing on Ethereum. This demo repo illustrates contract deployment with Hardhat and Foundry.

Deploy contracts with Hardhat

  1. If you haven’t already, install nodejs and yarn.

  2. Clone the repo and install dependencies:

    git clone https://github.com/scroll-tech/scroll-guides.git
    cd scroll-guides/contract-deploy-demo
    yarn install
  3. 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.

  4. Run yarn compile to compile the contract.

  5. Run yarn deploy:scrollTestnet to deploy the contract on the Scroll Sepolia Testnet.

  6. Run yarn test for hardhat tests.

Deploy contracts with Foundry

  1. Clone the repo:

    git clone https://github.com/scroll-tech/scroll-guides.git
    cd scroll-guides/contract-deploy-demo
  2. Install Foundry:

    curl -L https://foundry.paradigm.xyz | bash
    foundryup
  3. Run forge build to build the project.

  4. Deploy your contract with Foundry:

    forge create --rpc-url https://sepolia-rpc.scroll.io/ \
      --value <lock_amount> \
      --constructor-args <unlock_time> \
      --private-key <your_private_key> \
      --legacy \
      contracts/Lock.sol:Lock
    • <lock_amount> is the amount of test ETH to be locked in the contract. Try setting this to some small amount, like 0.0000001ether.
    • <unlock_time> is the Unix timestamp after which the funds locked in the contract will become available for withdrawal. Try setting this to some Unix timestamp in the future, like 1696118400 (this Unix timestamp corresponds to October 1, 2023).

    For example:

    forge create --rpc-url https://sepolia-rpc.scroll.io/ \
      --value 0.00000000002ether \
      --constructor-args 1696118400 \
      --private-key 0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1 \
      --legacy contracts/Lock.sol:Lock

Questions and Feedback

Thank you for participating in and developing on the Scroll Sepolia Testnet! If you encounter any issues, join our Discord and ask us in the #testnet-devs channel.

What's Next

Stay up-to-date on the latest Scroll Developer news
Roadmap updates, virtual and live events, ecosystem opportunities and more
Thank you for subscribing!

Resources

Follow Us