Prerequisites
Before you begin, ensure you have the following installed:- Node.js: Version 22.18.0 or higher (version 20.17 recommended if you encounter build issues)
- Foundry: Required for building and testing Solidity contracts
- Anchor: Required if working with SVM (Solana) programs
If you encounter build issues on initial
yarn command, try downgrading to Node 20.17 using nvm use 20.17. If you’ve never used Anchor before, run avm use latest.Installation
Clone the repository and install dependencies:Build the contracts
The project supports building with both Foundry and Hardhat:Run tests
Across uses Foundry for new tests and Hardhat for legacy tests. The project is migrating to Foundry as the primary testing framework.Foundry tests (recommended)
Run all EVM tests with Foundry:Run specific tests
Hardhat tests (legacy)
Run legacy Hardhat tests:Gas analysis
Run tests with gas reporting:SVM tests
Test Solana programs:Example: Deposit flow
Here’s how a user deposits tokens on a SpokePool:contracts/SpokePool.sol
Key parameters
- depositor: Account credited with the deposit who can speed up the transfer
- recipient: Account receiving funds on the destination chain
- inputToken: Token locked on origin chain (can be native token if wrapped)
- outputToken: Token sent to recipient on destination chain
- inputAmount: Amount deposited and locked
- outputAmount: Amount relayer sends (fee = inputAmount - outputAmount)
- destinationChainId: Target chain for the transfer
- quoteTimestamp: HubPool timestamp used to determine system fees
- fillDeadline: Deadline for relayers to fill the deposit
Example: Relayer fill
Relayers fill deposits on the destination chain:contracts/SpokePool.sol
Deploy contracts
Across supports deployment via Foundry and Hardhat.Deploy with Foundry
Deploy with Hardhat
Verify contracts
Verify deployed contracts on Etherscan:Lint and format
Maintain code quality with linting:Project structure
Key contracts
- HubPool.sol (
contracts/HubPool.sol): Central L1 contract managing liquidity and root bundle validation - SpokePool.sol (
contracts/SpokePool.sol): Base contract for all L2 spoke pools - Arbitrum_SpokePool.sol: Arbitrum-specific spoke pool with custom admin verification
- Optimism_SpokePool.sol: Optimism-specific spoke pool (and OP Stack chains)
- Chain adapters (
contracts/chain-adapters/): Bridge tokens and messages to each L2
Next steps
Architecture guide
Learn about the hub-and-spoke model and protocol flow
HubPool contract
Explore the central L1 contract managing liquidity
SpokePool contract
Understand how deposits and fills work on L2s
Testing guide
Write tests for new features and adapters
Additional resources
- Audit reports: Security audit reports by OpenZeppelin
- GitHub repository: Full source code
- Deployed contracts: Check
broadcast/deployed-addresses.jsonin the repository
For detailed deployment instructions for specific chains (including ZKSync and Solana), see the README.md in the repository.