Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
# Anchor
.anchor
.DS_Store
target
**/*.rs.bk
node_modules
test-ledger

# Node.js
node_modules
.yarn
bun.lockb

# Environment files
.env
keypairs/
.env.local
.env.*.local

# IDE
.DS_Store
/.idea/
.vscode/
*.swp
*.swo

# Keys and secrets
keypairs/
*.pem
*.key

# Build artifacts
out/
dist/
build/

# Logs
*.log
logs/

# Cache
.cache/
.temp/
6 changes: 3 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ bun run tx:wrap-token devnet-alpha

### Base Side
- **Bridge.sol**: Main contract receiving calls from Solana and managing message execution
- **Twin.sol**: Execution contract for each Solana sender pubkey
- **Twin.sol**: Execution contract for each Solana sender pubkey
- **CrossChainERC20.sol**: Mintable/burnable ERC20 for cross-chain transfers
- **CrossChainERC20Factory.sol**: Factory for deploying wrapped tokens

Expand All @@ -91,7 +91,7 @@ bun run tx:wrap-token devnet-alpha
- Requires `testnet-admin` wallet account for deployments
- Environment variables in `base/Makefile` for contract addresses

### Solana Program
### Solana Program
- Uses Anchor framework with Rust
- Requires keypair files in `keypairs/` directory
- Two environments: devnet-alpha and devnet-prod
Expand All @@ -105,6 +105,6 @@ bun run tx:wrap-token devnet-alpha
## Key Files to Understand

- `base/src/Bridge.sol` - Core Base bridge logic
- `solana/programs/bridge/src/lib.rs` - Solana program entry point
- `solana/programs/bridge/src/lib.rs` - Solana program entry point
- `base/script/Deploy.s.sol` - Base deployment script
- `solana/scripts/onchain/` - Solana transaction examples
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ A bridge between Base and blockchains outside the Ethereum ecosystem. Currently
[![GitHub pull requests by-label](https://img.shields.io/github/issues-pr-raw/base/bridge)](https://github.com/base/bridge/pulls)
[![GitHub Issues](https://img.shields.io/github/issues-raw/base/bridge.svg)](https://github.com/base/bridge/issues)

## How it Works
## How It Works

This bridge allows you to:

Expand Down
18 changes: 18 additions & 0 deletions base/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Base Bridge Environment Configuration
# Copy this file to .env and update with your values

# Environment (alpha or prod)
BRIDGE_ENVIRONMENT=alpha

# RPC URLs
BASE_RPC=https://base-sepolia.cbhq.net
# BASE_RPC=https://mainnet.base.org

# Token Recipients (bytes32 format)
SOLANA_SOL_RECEIVER=0x9827993b7b317eb6c74279d49074a13b33a3495a30637c86a7513922014ba424
USER_SPL_ATA=0x6621d2d930ef7ada6260d3e0a5679a8fe81fde41262314f2efbf9c4c828550b1
USER_REMOTE_ERC20_ATA=0x4394d16902c022f8f87c7667429bc8b2860d033e316b9f9515534505fae314e9
USER_REMOTE_ETH_ATA=0x15e9307085f98b2e64eb3dd36b7fbafea201cc2a9fcb36c8c207e99bc7b97f30

# Default bridge amount (in wei)
AMOUNT=1000000000
4 changes: 2 additions & 2 deletions base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
BASE_RPC=https://base-sepolia.cbhq.net
# BASE_RPC=https://mainnet.base.org

# Update values in this section to specify token recipients / token amount
# Update values in this section to specify token recipients and token amounts
####################################################################################################
# alpha or prod
# Environment: alpha or prod
ENV_NAME=alpha

SOLANA_SOL_RECEIVER = 0x9827993b7b317eb6c74279d49074a13b33a3495a30637c86a7513922014ba424
Expand Down
8 changes: 4 additions & 4 deletions base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The Base Bridge contracts facilitate bidirectional communication between Base an

### Core Contracts

- **Bridge**: Main contract that receives calls from Solana and manages message execution via Twin contracts. Bridge is also the entrypoint for sending messages to Solana
- **Bridge**: Main contract that receives calls from Solana and manages message execution via Twin contracts. Bridge is also the entry point for sending messages to Solana
- **Twin**: Execution contract specific to each Solana sender pubkey that processes calls from the bridge
- **CrossChainERC20**: ERC20 token implementation that can be minted/burned by the bridge for cross-chain transfers
- **CrossChainERC20Factory**: Factory contract for deploying wrapped tokens representing Solana tokens on Base
Expand Down Expand Up @@ -105,7 +105,7 @@ Custom bridging:
BRIDGE_ENVIRONMENT=alpha LOCAL_TOKEN=0x123... REMOTE_TOKEN=0x456... TO=0x789... AMOUNT=1000000 forge script BridgeTokensToSolanaScript --account testnet-admin --rpc-url $BASE_RPC --broadcast -vvvv
```

- `LOCAL_TOKEN`: address of ERC20 token on Base
- `REMOTE_TOKEN`: bytes32 representation of SPL mint pubkey on Solana (`0x069be72ab836d4eacc02525b7350a78a395da2f1253a40ebafd6630000000000` for native SOL)
- `TO`: bytes32 representation of Solana pubkey receiver (this is your Solana wallet address if bridging SOL and it should be your associated token account if bridging into an SPL token)
- `LOCAL_TOKEN`: Address of ERC20 token on Base
- `REMOTE_TOKEN`: Bytes32 representation of SPL mint pubkey on Solana (`0x069be72ab836d4eacc02525b7350a78a395da2f1253a40ebafd6630000000000` for native SOL)
- `TO`: Bytes32 representation of Solana pubkey receiver (this is your Solana wallet address if bridging SOL and it should be your associated token account if bridging into an SPL token)
- `AMOUNT`: The amount of Base tokens to bridge in wei
2 changes: 1 addition & 1 deletion base/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ optimizer = true
remappings = ["forge-std/=lib/forge-std/src/", "solady/=lib/solady/src/"]
gas_limit = "18446744073709551615"

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
# See more config options: https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
[fmt]
sort_imports = true
wrap_comments = true
2 changes: 1 addition & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bun install

## Non-Interactive Mode

All commands support non-interactive execution by providing required arguments:
All commands support non-interactive execution by providing the required arguments:

```bash
bun cli sol onchain bridge bridge-sol --cluster devnet --release prod --to 0x1234567890123456789012345678901234567890 --amount 10 --payer-kp config
Expand Down
108 changes: 108 additions & 0 deletions setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Base Bridge Setup Guide

This guide will help you set up the Base Bridge development environment.

## Prerequisites

### Required Tools

1. **Foundry** (for Base contracts)
- Install: `curl -L https://foundry.paradigm.xyz | bash && foundryup`
- Verify: `forge --version`

2. **Bun** (for Solana scripts)
- Install: `curl -bsSf https://bun.sh/install | bash`
- Verify: `bun --version`

3. **Rust & Cargo** (for Solana programs)
- Install: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
- Install Solana CLI: `sh -c "$(curl -sSfL https://release.solana.com/stable/install)"`

4. **Make** (build automation)
- Windows: Install via chocolatey `choco install make`
- macOS: `xcode-select --install`
- Linux: Usually pre-installed

## Setup Steps

### 1. Clone and Install Dependencies

```bash
# Clone the repository
git clone <repository-url>
cd bridge

# Install Base contract dependencies
cd base
make deps
cd ..

# Install Solana script dependencies
cd scripts
bun install
cd ..
```

### 2. Environment Configuration

```bash
# Copy environment template for Base
cp base/.env.example base/.env

# Edit base/.env with your configuration
# Update recipient addresses and other parameters as needed
```

### 3. Wallet Setup

```bash
# Create testnet admin wallet for Base deployments
cast wallet import testnet-admin --interactive

# Generate Solana keypair (if needed)
solana-keygen new --outfile ~/.config/solana/id.json

# Fund your Solana account on devnet
# Visit: https://solfaucet.com/
```

### 4. Build and Test

```bash
# Build Base contracts
cd base
forge build
forge test

# Build Solana programs
cd ../solana
cargo build-sbf
cargo test
```

### 5. Deploy (Testnet)

```bash
# Deploy Base contracts
cd base
make deploy

# Deploy Solana programs
cd ../scripts
bun cli sol program deploy
```

## Troubleshooting

### Common Issues

1. **Forge not found**: Ensure Foundry is installed and in your PATH
2. **Bun not found**: Restart your terminal after installing Bun
3. **Insufficient funds**: Ensure your wallets have enough testnet tokens
4. **Build failures**: Check that all dependencies are properly installed

### Getting Help

- Check the individual README files in `base/`, `solana/`, and `scripts/` directories
- Review the `CLAUDE.md` file for detailed architecture information
- Open an issue on the repository for specific problems
2 changes: 1 addition & 1 deletion solana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ cargo test

## Usage

Make sure you have a funded solana keypair in `~/.config/solana/id.json`. You can use the `solana-keygen new` command to generate a new keypair. You can use this solana faucet to fund your account on devnet: https://solfaucet.com/.
Make sure you have a funded Solana keypair in `~/.config/solana/id.json`. You can use the `solana-keygen new` command to generate a new keypair. You can use this Solana faucet to fund your account on devnet: https://solfaucet.com/.

The `scripts/` directory contains an interactive CLI for interacting with the program. See [scripts/README.md](../scripts/README.md) for detailed usage instructions and available commands.