Skip to main content

Overview

NEXUS-Bitcoin brings trustless smart contract programmability to Bitcoin L1 through ZK-STARK proofs and BitVM2 fraud proofs. Deploy full WASM contracts with cross-contract calls, delegate calls, and contract deployment - all secured by Bitcoin’s proof-of-work.

Trustless Verification

NEXUS-Bitcoin is fully trustless - no federation, no multisig, no trusted third parties.

How Trustlessness is Achieved

  1. Cryptographic Proofs: Every state transition is proven via ZK-STARK proofs
  2. On-Chain Verification: BitVM2 enables proof verification on Bitcoin L1
  3. Economic Security: Provers post bonds that are slashed for invalid states
  4. Permissionless Challenges: Anyone can challenge invalid state transitions
  5. Self-Custody: Users always retain escape hatch to recover funds
┌─────────────────────────────────────────────────────────────────┐
│                    Trustless Verification Flow                   │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  1. Prover executes WASM contracts                              │
│                    │                                             │
│                    ▼                                             │
│  2. Generates ZK-STARK proof of correct execution               │
│                    │                                             │
│                    ▼                                             │
│  3. Posts state commitment to Bitcoin L1 (OP_RETURN)            │
│                    │                                             │
│                    ▼                                             │
│  4. Anyone can challenge via BitVM2 bisection game              │
│                    │                                             │
│                    ▼                                             │
│  5. Invalid proofs → Prover bond slashed on Bitcoin L1          │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Security Model

Cryptographic Soundness (ZK-STARK)

  • State transitions proven via ZK-STARK proofs
  • No trusted setup required
  • Post-quantum secure
  • Anyone can verify proofs

Economic Security (BitVM2)

  • Provers post bonds on Bitcoin L1
  • Interactive bisection games for disputes
  • Fraudulent provers lose bonds
  • Honest challengers earn rewards

Combined Model

ZK-STARK Proofs (Cryptographic) + BitVM2 Bonds (Economic)
                    =
         Trustless Verification

Full WASM Smart Contracts

NEXUS-Bitcoin supports the complete WASM smart contract system with full programmability.

Contract Capabilities

FeatureSupportDescription
WASM ExecutionFull WebAssembly runtime
Cross-Contract CallsCall any deployed contract
Delegate CallsExecute code in caller’s context
Contract DeploymentDeploy new contracts from contracts
StoragePersistent key-value storage
EventsEmit events for indexing
Reentrancy GuardsBuilt-in protection
Bitcoin SPVVerify Bitcoin transactions in contracts

Cross-Contract Calls (xcc)

Contracts can call other contracts seamlessly:
use nexus_sdk::contract_api::xcc;

// Call another contract
nexus_fn! {
    fn swap_btc_for_token(token: Address, amount: U256, min_out: U256) {
        // Call AMM router to swap
        let result = xcc::call(&AMM_ROUTER.0, "swapExactTokensForTokens", &encode_swap_args(
            amount, min_out, &[WBTC, token], &sender, deadline
        ));
        
        require!(check_result(&result), "Swap failed");
        ret::u32(1)
    }
}

Delegate Calls

Execute another contract’s code in the current contract’s storage context:
// Delegate call - runs target code with our storage
nexus_fn! {
    fn upgrade_implementation(new_impl: Address) {
        let sender = Blockchain::msg.sender();
        require!(sender == OWNER.get(&b"val".as_slice()), "Not owner");
        
        // Delegate to new implementation
        xcc::delegate_call(&new_impl.0, "initialize", &[]);
        
        IMPLEMENTATION.set(&b"val".as_slice(), new_impl);
        ret::u32(1)
    }
}

Contract Deployment from Contracts

Deploy child contracts with deterministic addresses:
// Factory pattern - deploy new contracts
nexus_fn! {
    fn createPair(tokenA: Address, tokenB: Address) {
        const PAIR_CODE: &[u8] = include_bytes!("../../pair.wasm");
        
        // CREATE2-style deterministic deployment
        let mut salt = Vec::new();
        salt.extend_from_slice(&tokenA.0);
        salt.extend_from_slice(&tokenB.0);
        
        let pair_addr = xcc::deploy(PAIR_CODE, &[], &salt);
        xcc::call(&pair_addr.0, "init_pair", &encode_init_args(&tokenA, &tokenB));
        
        PAIRS.set(&key, Address(pair_addr));
        emit("PairCreated", &[]);
        ret::address(&pair_addr)
    }
}

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                      NEXUS-Bitcoin                               │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │                    Bitcoin L1                             │   │
│  │  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐       │   │
│  │  │   Taproot   │  │    State    │  │   BitVM2    │       │   │
│  │  │   Vaults    │  │  Commits    │  │   Bonds     │       │   │
│  │  └─────────────┘  └─────────────┘  └─────────────┘       │   │
│  └──────────────────────────────────────────────────────────┘   │
│                              │                                   │
│                              ▼                                   │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │                    NEXUS Layer                            │   │
│  │  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐       │   │
│  │  │   WASM VM   │  │  Cross-     │  │   Unified   │       │   │
│  │  │  Contracts  │  │  Contract   │  │  Liquidity  │       │   │
│  │  │             │  │   Calls     │  │             │       │   │
│  │  └─────────────┘  └─────────────┘  └─────────────┘       │   │
│  └──────────────────────────────────────────────────────────┘   │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Supported Features

FeatureStatusDescription
Smart ContractsWASM contracts with full programmability
Taproot VaultsP2TR addresses with escape hatch
State CommitsOn-chain state commitments
Fraud ProofsBitVM2 interactive bisection
SPV ProofsBitcoin transaction verification
Cross-Contract Callsxcc and delegate calls
BRC-20 BridgeBridge BRC-20 tokens to NEXUS
BTC/ZEC Swaps🔄 V2Via intent exchange
BTC/DOGE Swaps🔄 V2Via intent exchange
Unified Liquidity🔄 V2Cross-chain pools
Runes Bridge🔄Coming soon
Ordinals🔄Coming soon

Cross-Chain Swaps (V2)

Cross-chain swaps between BTC/ZEC/DOGE will be available in V2 via intent exchange.

BTC → DOGE (V2)

// V2: Intent-based cross-chain swap
const intent = await client.createSwapIntent({
  fromChain: 'bitcoin',
  toChain: 'dogecoin',
  fromAmount: btcAmount,
  minToAmount: minDogeOut,
  recipient: dogeAddress
});

// Intent matched and executed by solvers
await client.waitForIntentFulfillment(intent.id);
V1 supports BTC deposits, withdrawals, and smart contracts. Unified liquidity with ZEC/DOGE via intent exchange is coming in V2.

Deposit Flow

  1. Derive Vault Address
    const vault = await client.getVaultAddress();
    console.log('Deposit BTC to:', vault.vaultAddress);
    
  2. Send Bitcoin
    bitcoin-cli sendtoaddress <VAULT_ADDRESS> 0.01
    
  3. Wait for Confirmations (6 blocks)
  4. Receive vSAT on L2
    const balance = await client.getBalance();
    // Balance credited automatically
    

Withdrawal Flow

  1. Request Withdrawal
    await client.requestWithdrawal(btcAddress, amount);
    
  2. Wait for Processing (batched for efficiency)
  3. Receive BTC on L1

State Commitments

NEXUS posts state commitments to Bitcoin every N blocks:
Bitcoin Block 100: State Root 0xabc...
Bitcoin Block 200: State Root 0xdef...
Bitcoin Block 300: State Root 0x123...
Anyone can verify the state by:
  1. Downloading state from NEXUS nodes
  2. Computing state root
  3. Comparing with on-chain commitment

BitVM2 Challenge System

If a prover posts an invalid state:
1. Challenger initiates challenge (posts bond)
2. Bisection game narrows to single step
3. Disputed step verified on-chain
4. Loser's bond transferred to winner

Configuration

[bitcoin]
rpc_url = "http://localhost:8332"
rpc_user = "user"
rpc_password = "password"
network = "regtest"  # mainnet, testnet, signet, regtest

[bitcoin.vault]
escape_timelock = 2016  # ~2 weeks in blocks

[bitcoin.state_commit]
interval_blocks = 100
bond_amount_sats = 100000

Comparison with Alternatives

FeatureNEXUS-BitcoinSparkOpNetArch
Security ModelZK + BitVM2FederatedOptimisticBitVM
Smart ContractsWASMLimitedEVMWASM
TrustlessPartial
Cross-Chain🔄 V2
Unified Liquidity🔄 V2

Roadmap

V1 (Current)

  • ✅ Full WASM smart contracts
  • ✅ Cross-contract calls & delegate calls
  • ✅ Taproot vaults with escape hatch
  • ✅ ZK-STARK + BitVM2 verification
  • ✅ BRC-20 bridge

V2 (Planned)

  • 🔄 Unified liquidity with ZEC/DOGE via intent exchange
  • 🔄 Cross-chain swaps (BTC/ZEC/DOGE)
  • 🔄 Runes bridge
  • 🔄 Ordinals support