Lace wallet integration
이 프로젝트는 Midnight Network용 Lace Beta Wallet 통합을 기본 제공합니다.
Wallet features
| Feature | Description | Implementation |
|---|---|---|
| Connect Wallet | Lace Beta Wallet에 연결합니다 | wallet.enable() |
| Disconnect Wallet | 지갑 연결을 해제합니다 | wallet.disconnect() |
| Get Wallet State | 지갑 주소와 키를 조회합니다 | wallet.state() |
| Deploy Contract | 지갑을 통해 컨트랙트를 배포합니다 | wallet.submitTransaction() |
| Join Contract | 기존 컨트랙트에 참여합니다 | wallet.balanceAndProveTransaction() |
| Balance Transactions | 트랜잭션을 밸런싱하고 증명합니다 | Wallet API 통합 |
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>
);
}