> For the complete documentation index, see [llms.txt](https://solieum.gitbook.io/solieum/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://solieum.gitbook.io/solieum/archive-wallet-bridge.md).

# archive wallet bridge

{% hint style="info" %}
Visit [walletbridge.org](https://wallet-bridge.web.app/) for the official bridge interface
{% endhint %}

## 🔄 What is a Layer 1 to Layer 2 Bridge?

A Layer 1 to Layer 2 bridge is a crucial technology that facilitates the transfer of digital assets (like tokens) between a Layer 1 blockchain (like Solana) and a Layer 2 scaling solution built on top of it. These bridges enable users to move their assets from the main blockchain to a faster, cheaper Layer 2 network, and vice versa.

![Bridge Animation](https://content.gitbook.com/content/9sknVijWtYbZXNBeIcYM/blobs/6O1e2SoI6XuXX8lKm0Ge/image.png)

## ⚙️ How it Works

{% stepper %}
{% step %}

### 🔐 Wallets and Bridges

Users need a cryptocurrency wallet to store their assets and then use a bridge protocol to move them.

Compatible wallets include:

* Phantom
* Solflare
* Solieum Wallet
* Other Solana-compatible wallets
  {% endstep %}

{% step %}

### ⬇️ Layer 1 to Layer 2 Transfer

To move tokens from a Layer 1 blockchain to a Layer 2 network, users typically lock their tokens in a smart contract on the Layer 1 blockchain, and the corresponding tokens are then minted on the Layer 2 network.

SOL → soSOL\
Solana → Solieum
{% endstep %}

{% step %}

### ⬆️ Layer 2 to Layer 1 Transfer

To move tokens back to the Layer 1 blockchain, users typically lock their tokens on the Layer 2 network and then they are minted on the Layer 1 blockchain.

soSOL → SOL\
Solieum → Solana
{% endstep %}

{% step %}

### 💬 Messenger Contracts

Communication between Layer 1 and Layer 2 is facilitated by special smart contracts called "messenger" contracts. These contracts allow for the exchange of messages and data between the two layers.

```javascript
message = {
  source: "layer1",
  destination: "layer2",
  data: { ... }
}
```

{% endstep %}
{% endstepper %}

## 🌟 Benefits of Using the Bridge

| <p>🚀<br>Increased Scalability</p>                                                                                 | <p>💸<br>Reduced Transaction Fees</p>                                                                             | <p>⚡<br>Faster Transactions</p>                                                             |
| ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| Layer 2 solutions can handle more transactions per second, reducing congestion and fees on the Layer 1 blockchain. | Layer 2 networks typically offer lower transaction fees compared to Layer 1, making transactions more affordable. | Layer 2 solutions generally offer faster transaction speeds, improving the user experience. |

## 🔧 Technical Implementation

Solieum Wallet Bridge is a secure infrastructure that enables the seamless transfer of assets between Solana (Layer 1) and Solieum (Layer 2). Below is a technical guide on how to implement and interact with the Solieum Wallet Bridge.

### Bridge Architecture

<figure><img src="https://content.gitbook.com/content/9sknVijWtYbZXNBeIcYM/blobs/Jixr7STnffZUmnHElplb/Screenshot_1.png" alt="Solieum Wallet Bridge Architecture"><figcaption><p>Solieum Wallet Bridge architecture showing the flow of assets between L1 and L2</p></figcaption></figure>

The bridge uses a hybrid approach combining:

* 🔒 Locking and minting mechanism for native assets
* 📨 Message passing for verifiable state transitions
* 🛡️ Fraud proofs for security guarantees

### Integration with dApps

To integrate the Solieum Wallet Bridge into your dApp, install the SDK:

```bash
npm install @solieum/bridge-sdk
```

### Transferring Assets from Solana to Solieum Layer 2

```typescript
import { 
  Connection, 
  Keypair, 
  PublicKey, 
  Transaction 
} from '@solana/web3.js';
import { 
  SolieumBridge, 
  BridgeOptions, 
  BridgeDirection 
} from '@solieum/bridge-sdk';

// Initialize connections to both networks
const solanaConnection = new Connection('https://api.mainnet-beta.solana.com');
const solieumConnection = new Connection('https://api.mainnet.solieum.com');

// Create a bridge instance
const bridge = new SolieumBridge({
  solanaConnection,
  solieumConnection,
  walletBridgeProgram: new PublicKey('BridG3ProgramIDXXXXXXXXXXXXXXXXXXXXXXXXX'),
});

// Bridge SOL from Solana L1 to Solieum L2
async function bridgeSOLToSolieum(
  wallet: Keypair,
  amount: number, // in lamports
  recipientOnL2: PublicKey
) {
  // Create the bridge transaction
  const bridgeTx = await bridge.createBridgeTransaction({
    direction: BridgeDirection.L1ToL2,
    sourceWallet: wallet.publicKey,
    destinationAddress: recipientOnL2,
    amount,
    token: 'SOL', // For native SOL
  });

  // Sign and send the transaction
  const signature = await bridge.sendAndConfirmBridgeTransaction(
    bridgeTx,
    [wallet]
  );

  console.log(`Bridge transaction confirmed: ${signature}`);
  console.log(`Check status at https://bridge-explorer.solieum.com/tx/${signature}`);
  
  // Wait for the assets to be available on L2 (typically 5-10 minutes)
  const receipt = await bridge.waitForBridgeCompletion(signature);
  console.log(`Assets available on L2. L2 transaction: ${receipt.l2TransactionHash}`);
  
  return receipt;
}
```

### Transferring Assets from Solieum Layer 2 to Solana

```typescript
// Bridge tokens from Solieum L2 back to Solana L1
async function bridgeFromSolieumToSolana(
  wallet: Keypair,
  amount: number,
  recipientOnL1: PublicKey,
  tokenAddress?: string // Optional for SPL tokens
) {
  // Create the bridge transaction
  const bridgeTx = await bridge.createBridgeTransaction({
    direction: BridgeDirection.L2ToL1,
    sourceWallet: wallet.publicKey,
    destinationAddress: recipientOnL1,
    amount,
    token: tokenAddress || 'SOL', // Either SPL token address or 'SOL' for native
  });

  // Sign and send the transaction
  const signature = await bridge.sendAndConfirmBridgeTransaction(
    bridgeTx,
    [wallet]
  );

  console.log(`Bridge withdrawal initiated: ${signature}`);
  
  // L2 to L1 transfers have a challenge period for security (typically 24 hours)
  console.log(`Withdrawal will be available on L1 after challenge period`);
  
  // Wait for completion (this will be a long wait)
  const receipt = await bridge.waitForBridgeCompletion(signature);
  console.log(`Assets available on L1. L1 transaction: ${receipt.l1TransactionHash}`);
  
  return receipt;
}
```

### Bridge Security Considerations

**⏱️ Challenge Period**

For L2 to L1 withdrawals, a 24-hour challenge period allows validators to dispute fraudulent transactions.

**👥 Validator Network**

A dedicated network of validators monitors bridge transactions and verifies their validity.

**🛡️ Fraud Proofs**

The bridge implements fraud proofs that allow anyone to challenge invalid state transitions.

**🔐 Multi-signature Control**

Bridge funds on L1 are controlled by a multi-signature wallet requiring multiple approvals for administrative actions.

**⚖️ Transaction Limits**

Default limits on transaction sizes help prevent large-scale attacks.

## 🚀 Get Started

Ready to bridge your assets between Solana and Solieum? Follow these steps:

{% stepper %}
{% step %}
Connect your wallet to the [Wallet Bridge](https://wallet-bridge.web.app/)
{% endstep %}

{% step %}
Select the direction (L1 to L2 or L2 to L1)
{% endstep %}

{% step %}
Enter the amount to transfer
{% endstep %}

{% step %}
Confirm the transaction in your wallet
{% endstep %}

{% step %}
Wait for confirmation (L1 to L2: \~5 minutes, L2 to L1: \~24 hours)
{% endstep %}
{% endstepper %}

[Learn More About Solieum Layer 2 Solutions →](file:///solieum/solana-rollups-rollapps-layer-2-solutions.md)
