A secure and efficient bidirectional cross-chain bridge that enables seamless asset transfers between Solana and Ethereum (Sepolia testnet). Users can:
- Lock SOL on Solana and receive BTK tokens on Sepolia
- Lock BTK tokens on Sepolia and receive SOL on Solana
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ Solana โโโโโบโ Indexer โโโโโบโ Sepolia โ
โ Program โ โ (Node.js) โ โ Contract โ
โ โ โ โ โ โ
โ lock() SOL โโโโโถโ Bidirectionalโโโโโถโ release() โ
โ release() โโโโโโ Monitoring & โโโโโโ lock() BTK โ
โ emit events โ โ Processing โ โ emit events โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
- Solana Program (Rust/Anchor): Handles SOL locking/releasing and event emission
- Bidirectional Indexer: Monitors events from both chains and triggers cross-chain actions
- EVM Contract (Solidity): Manages BTK token locking/releasing with owner controls
- ๐ Bidirectional Bridge: Both SolanaโSepolia and SepoliaโSolana
- ๐ Secure Locking: SOL and BTK transfers with admin validation
- ๐ก Event Monitoring: Real-time monitoring of both blockchain events
- ๐ Owner Controls: EVM contract with
onlyOwnermodifier - ๐ซ Double-Spend Protection: Transaction hash tracking on both chains
- โก Automated Processing: Seamless cross-chain execution
- ๐งช Comprehensive Testing: Full test coverage for all components
- ๐ฏ 1:1 Conversion: 1 SOL = 1 BTK ratio
- Node.js 18+
- Rust & Anchor CLI
- Solana CLI
- Hardhat
- MetaMask with Sepolia testnet
git clone https://github.com/satyam455/bridge.git
cd bridge
# Install dependencies
cd bridge && yarn install
cd contracts && npm install
cd ../indexer && npm install
cd ../scripts && npm installCreate .env files:
indexer/.env:
ADMIN_PRIVATE_KEY=your_sepolia_private_key
EVM_CONTRACT_ADDRESS=0xE40eaa9DdDA5126d3C7a3BDA27D216e69bd67d97
BRIDGE_TOKEN_ADDRESS=0x683dB3BD882864C9c12E93747050EC6d093B1A72
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY- Program ID:
6TosvM79pTn5ZmCyYUMuSeDcWjESY4bT7wmdyEArKia5 - Bridge State PDA:
6kdLNtKYgdn9JJhCGBiyHFBmth6gPsnqX2cL5YYH7beW - Network: Devnet
- Explorer: View on Solana Explorer
- Bridge Contract:
0xE40eaa9DdDA5126d3C7a3BDA27D216e69bd67d97 - Bridge Token (BTK):
0x683dB3BD882864C9c12E93747050EC6d093B1A72 - Admin Address:
0xB4d1cC3386a83c70972E9f9095dDB9D494BF7EAE
cd bridge
node scripts/test-bridge.js initcd indexer
npm startKeep this running - it monitors both chains and processes bridge requests.
# Lock SOL on Solana to receive BTK on Sepolia
node scripts/test-bridge.js lock 0.1 0xYourSepoliaAddressProcess:
- SOL locked on Solana
- Event emitted and detected by indexer
- BTK tokens released on Sepolia
- Add BTK token to MetaMask to see balance
# Lock BTK on Sepolia to receive SOL on Solana
node scripts/test-reverse-bridge.js lock 0.1 9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWMProcess:
- BTK tokens locked on Sepolia
- Event emitted and detected by indexer
- SOL released on Solana
- Check your Solana wallet balance
- Switch to Sepolia network
- Import custom token:
- Address:
0x683dB3BD882864C9c12E93747050EC6d093B1A72 - Symbol:
BTK - Decimals:
18
- Address:
# Check Sepolia balances
cd contracts
node scripts/check-balances.js
# Check bridge status
node scripts/test-bridge.js status
node scripts/test-reverse-bridge.js status# 1. Start indexer (keep running)
cd indexer && npm start
# 2. In another terminal, lock SOL
cd ../
node scripts/test-bridge.js lock 0.1 0xYourSepoliaAddress
# 3. Wait for indexer to process (watch logs)
# 4. Check your BTK balance on Sepolia
cd contracts && node scripts/check-balances.js# 1. Make sure you have BTK tokens (bridge some SOL first)
# 2. Lock BTK tokens for Solana
node scripts/test-reverse-bridge.js lock 0.05 YourSolanaAddress
# 3. Wait for indexer to process
# 4. Check your SOL balance on Solana
solana balance YourSolanaAddresscd bridge
anchor testcd contracts
npx hardhat test# Test both directions
node scripts/test-bridge.js lock 0.01 0xYourAddress
node scripts/test-reverse-bridge.js lock 0.01 YourSolanaAddressbridge/
โโโ bridge/ # Anchor workspace
โ โโโ programs/bridge/ # Solana program (Rust)
โ โโโ tests/ # Solana tests
โ โโโ target/ # Build artifacts
โโโ contracts/ # EVM contracts
โ โโโ contracts/ # Solidity contracts
โ โโโ scripts/ # Deployment scripts
โ โโโ test/ # EVM tests
โโโ indexer/ # Bidirectional event monitoring service
โ โโโ indexer.js # Main indexer logic
โ โโโ package.json # Dependencies
โโโ scripts/ # Testing utilities
โโโ test-bridge.js # SolanaโSepolia bridge testing
โโโ test-reverse-bridge.js # SepoliaโSolana bridge testing
# Build Solana program
cd bridge && anchor build
# Compile EVM contracts
cd contracts && npx hardhat compile# Start local Solana validator
solana-test-validator
# Deploy to local (modify scripts for localhost)
anchor deploy
npx hardhat run scripts/deploy.js --network localhost- Amount Validation: Maximum 1 SOL/BTK per transaction
- Address Validation: Ethereum and Solana address format verification
- Owner Controls: Only admin can release tokens/SOL
- Reentrancy Protection: OpenZeppelin ReentrancyGuard
- Double-Spend Prevention: Transaction hash tracking on both chains
- Event Emission: Full transaction transparency
- Bidirectional Tracking: Separate processing maps for each direction
- Minimum Lock: 0.001 SOL/BTK
- Maximum Lock: 1 SOL/BTK per transaction
- Conversion Rate: 1 SOL = 1 BTK (1:1 ratio)
- Supported Directions: Both SolanaโSepolia
- Testnet Only: This bridge operates on Devnet (Solana) and Sepolia (Ethereum)
- Indexer Required: The bidirectional indexer must be running for both directions
- BTK Tokens: Add BTK token to MetaMask to see your balance
- Admin Key: Keep your admin private key secure and never share it
- Gas Fees: Ensure sufficient ETH for Sepolia transactions, SOL for Solana transactions
- Bidirectional: Both directions are supported with the same conversion rate
| Direction | Lock | Receive | Command |
|---|---|---|---|
| Solana โ Sepolia | SOL | BTK | test-bridge.js lock |
| Sepolia โ Solana | BTK | SOL | test-reverse-bridge.js lock |
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License.
Built with โค๏ธ by satyam455