Skip to content

scroll-tech/scroll-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scroll Contracts

This directory contains the solidity code for Scroll L1 bridge and rollup contracts and L2 bridge and pre-deployed contracts.

Directory Structure

├── hardhat-test: Hardhat integration tests
├── lib: External libraries and testing tools
├── scripts: Deployment scripts
├── src
│   ├── gas-swap: Utility contract that allows gas payment in other tokens
│   ├── interfaces: Common contract interfaces
│   ├── L1: Contracts deployed on the L1 (Ethereum)
│   │   ├── gateways: Gateway router and token gateway contracts
│   │   ├── rollup: Rollup contracts for data availability and finalization
│   │   ├── IL1ScrollMessenger.sol: L1 Scroll messenger interface
│   │   └── L1ScrollMessenger.sol: L1 Scroll messenger contract
│   ├── L2: Contracts deployed on the L2 (Scroll)
│   │   ├── gateways: Gateway router and token gateway contracts
│   │   ├── predeploys: Pre-deployed contracts on L2
│   │   ├── IL2ScrollMessenger.sol: L2 Scroll messenger interface
│   │   └── L2ScrollMessenger.sol: L2 Scroll messenger contract
│   ├── libraries: Shared contract libraries
│   ├── misc: Miscellaneous contracts
│   ├── mocks: Mock contracts used in the testing
│   ├── rate-limiter: Rater limiter contract
│   └── test: Unit tests in solidity
├── foundry.toml: Foundry configuration
├── hardhat.config.ts: Hardhat configuration
├── remappings.txt: Foundry dependency mappings
...

Dependencies

Node.js

First install Node.js and npm. Run the following command to install yarn:

npm install --global yarn

Foundry

Install foundryup, the Foundry toolchain installer:

curl -L https://foundry.paradigm.xyz | bash

If you do not want to use the redirect, feel free to manually download the foundryup installation script from here.

Then, run foundryup in a new terminal session or after reloading PATH.

Other ways to install Foundry can be found here.

Hardhat

Run the following command to install Hardhat and other dependencies.

yarn install

Build

  • Run git submodule update --init --recursive to initialize git submodules.
  • Run yarn prettier:solidity to run linting in fix mode, will auto-format all solidity codes.
  • Run yarn prettier to run linting in fix mode, will auto-format all typescript codes.
  • Run yarn prepare to install the precommit linting hook.
  • Run forge build --evm-version cancun to compile contracts with foundry.
  • Run npx hardhat compile to compile with hardhat.
  • Run forge test --evm-version cancun -vvv to run foundry units tests. It will compile all contracts before running the unit tests.
  • Run npx hardhat test to run integration tests. It may not compile all contracts before running, it's better to run npx hardhat compile first.