Skip to content

A lightweight, focused starting point for prototyping/building on the Superchain

License

Notifications You must be signed in to change notification settings

ethereum-optimism/superchain-starter

Repository files navigation

Superchain Starter Kit

A lightweight, focused starting point for prototyping/building on the Superchain, featuring

Screenshot 2025-02-17 at 8 09 02β€―PM

πŸš€ Getting started

Get prototyping Superchain apps in under < 1 min! ❀️‍πŸ”₯

Prerequisites: Foundry & Node

Follow this guide to install Foundry

1. Create a new repository using this template:

Click the "Use this template" button above on GitHub, or generate directly

2. Clone your new repository

git clone <your-new-repository-url>
cd <your-new-repository>

3. Install dependencies

pnpm i

4. Get started

pnpm dev

This command will:

  • Start a local Superchain network (1 L1 chain and 2 L2 chains) using supersim
  • Launch the frontend development server at (http://localhost:5173)
  • Deploy the smart contracts to your local network

Start building on the Superchain!

Deploying contracts

The starter kit uses super-cli (or sup) to streamline contract deployment across the Superchain ecosystem. sup works great with Foundry projects while eliminating common multichain friction points:

  • πŸ”„ Foundry Compatible: Seamlessly works with your existing Foundry setup and artifacts
  • ⛓️ Multi-Chain: Deploy to multiple chains with a single command and pre-configured RPCs
  • β›½ Gasless Deployments: Instead of having to bridge to n chains
  • 🎯 Interactive mode: No more complex command-line arguments

Alternatively, if you want to use Forge scripts directly, follow the multichain deployment example at contracts/script/Deploy.s.sol

Deploying

Once you're ready to deploy, start sup in interactive mode

pnpm sup

Then you can follow the steps to deploy to supersim or the interop-alpha devnet

πŸš€ Deploy Create2 Wizard

 βœ“  Enter Foundry Project Path ./contracts/
 βœ“  Select Contract CrossChainCounter.sol
 βœ“  Configure Constructor Arguments
 βœ“  Configure Salt ethers phoenix
 βœ“  Select Network interop-alpha
 βœ“  Select Chains interop-alpha-0, interop-alpha-1
 >  Verify Contract

Press ← to go back

 Do you want to verify the contract on the block explorer? Y/n

Non-interactive mode

You can also skip the interactive mode entirely by passing the necessary arguments

pnpm sup deploy create2 --chains supersiml2a,supersiml2b --salt ethers phoenix --forge-artifact-path contracts/out/CrossChainCounter.sol/CrossChainCounter.json --network supersim --private-key 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a

--prepare mode

To "prepare" a command without running it, run sup with the prepare mode. This will print the command instead of running it. Then you can run the prepared command directly to run immediately in non-interactive mode.

pnpm sup --prepare

Make sure to build before deploying

sup assumes that your foundry project has already been built. Make sure to build before attempting to deploy

pnpm build:contracts

πŸ‘€ Overview

Example app

CrossChainCounter contract

  • Simple Hello world for Superchain Interop
  • Unlike the single chain Counter, this one can only be incremented via cross-chain messages
  • Learn more about this contract here

Tools

  • supersim: Local test environment with 1 L1 and multiple L2 chains, includes pre-deployed Superchain contracts
  • sup (super-cli): Deploy and verify contracts across multiple chains, with sponsored transactions
  • foundry: Blazing fast smart contract development framework
  • wagmi / viem: Best in class Typescript library for the EVM,
  • vite / tailwind / shadcn: Frontend development tools and UI components

πŸ“ Directory structure

This starter kit is organized to get you building on the Superchain as quickly as possible. Solidity code goes in /contracts, and the typescript frontend goes in /src

superchain-starter/
β”œβ”€β”€ contracts/                   # Smart contract code (Foundry)
β”œβ”€β”€ src/                        # Frontend code (vite, tailwind, shadcn, wagmi, viem)
β”‚   └── App.tsx                # Main application component
β”œβ”€β”€ public/                     # Static assets for the frontend
β”œβ”€β”€ supersim-logs/             # Local supersim logs
β”œβ”€β”€ package.json               # Project dependencies and scripts
└── mprocs.yaml               # Run multiple commands using mprocs

A note on project structure

While this structure is great for getting started and building proof of concepts, it's worth noting that many production applications eventually migrate to separate repositories for contracts and frontend code.

For reference, here are some examples of this separation in production applications:

πŸ“š More resources

😎 Moooaaar examples

Want to see more? Here are more example crosschain apps for inspiration / patterns!

  • ⚑ Crosschain Flash Loan
    • Dependent cross-chain messages (compose multiple cross-domain messages)
    • Using SuperchainTokenBridge for cross-chain ERC20 transfers
    • Multichain lending vaults using L2ToL2CrossDomainMessenger
  • πŸ’Έ Multisend
    • How to set up cross-chain callbacks (contract calling itself on another chain)
    • Using SuperchainWETH for cross-chain ETH transfers
    • Dependent cross-chain messages (compose multiple cross-domain messages)
  • πŸͺ™ SuperchainERC20
    • Using ERC-7802 interface for SuperchainERC20 tokens
    • How to upgrade existing ERC20s into SuperchainERC20
    • Minting supply on only one chain
    • Deterministic address deployment on all chains
  • πŸ“ CrossChainPingPong
    • Simple example of passing state between multiple chains using cross domain messenger
    • How to set up cross-chain callbacks (contract calling itself on another chain)
  • πŸ•ΉοΈ CrossChainTicTacToe
    • Allows players to play each other from any chain without cross-chain calls, instead relying on cross-chain event reading
    • Creating horizontally scalable apps with interop

βš–οΈ License

Files are licensed under the MIT license.

License information

About

A lightweight, focused starting point for prototyping/building on the Superchain

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published