A lightweight, focused starting point for prototyping/building on the Superchain, featuring
- π foundry, supersim, super-cli
- π¨ wagmi, viem
- @eth-optimism/viem, @eth-optimism/wagmi - viem/wagmi extensions for the Superchain
- π‘ simple example app - CrossChainCounter

Get prototyping Superchain apps in under < 1 min! β€οΈβπ₯
Follow this guide to install Foundry
Click the "Use this template" button above on GitHub, or generate directly
git clone <your-new-repository-url>
cd <your-new-repository>
pnpm i
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!
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
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
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
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
sup
assumes that your foundry project has already been built. Make sure to build before attempting to deploy
pnpm build:contracts
- 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
- 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
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
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:
- Uniswap: Uniswap contracts, Uniswap frontend
- Across: Across contracts, Across frontend
- Farcaster: Farcaster contracts
- Interop recipes / guides: https://docs.optimism.io/app-developers/tutorials/interop
- Superchain Dev Console: https://console.optimism.io/
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
Files are licensed under the MIT license.