PackagesMidnight SetupWallet Integration

Lace Wallet Integration

This project includes a complete Lace Beta Wallet integration for Midnight Network:

Wallet Features

FeatureDescriptionImplementation
Connect WalletConnect to Lace Beta Walletwallet.enable()
Disconnect WalletDisconnect from walletwallet.disconnect()
Get Wallet StateRetrieve wallet address and keyswallet.state()
Deploy ContractDeploy contracts through walletwallet.submitTransaction()
Join ContractJoin existing contractswallet.balanceAndProveTransaction()
Balance TransactionsBalance and prove transactionsWallet API integration

Wallet Provider Setup

// Connect to Lace Wallet
const wallet = window.midnight?.mnLace;
if (!wallet) {
  throw new Error('Please install Lace Beta Wallet for Midnight Network');
}
 
// Enable wallet and get state
const walletAPI = await wallet.enable();
const walletState = await walletAPI.state();
const uris = await wallet.serviceUriConfig();

React Wallet Hook

import { useMidnightWallet } from './hooks/useMidnightWallet';
 
function App() {
  const { 
    connectWallet, 
    disconnectWallet, 
    walletState, 
    isConnected 
  } = useMidnightWallet();
  
  return (
    <div>
      {isConnected ? (
        <button onClick={disconnectWallet}>Disconnect</button>
      ) : (
        <button onClick={connectWallet}>Connect Wallet</button>
      )}
    </div>
  );
}