plugins/midnight-dapp/skills/wallet-integration/SKILL.md
Use when setting up Lace wallet connection, handling multiple user accounts, switching between testnet and mainnet, troubleshooting wallet issues, or migrating from MetaMask/Web3 patterns.
npx skillsauth add aaronbassett/midnight-knowledgebase midnight-dapp:wallet-integrationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Connect Lace wallet to your Midnight DApp for user authentication, account management, and transaction signing.
Lace wallet is a Chrome extension that injects window.midnight.mnLace into web pages. This is similar to MetaMask's window.ethereum but with Midnight-specific APIs.
Midnight uses Bech32m addresses (e.g., addr_test1qz...) instead of Ethereum's hex format (0x...).
| Document | Description | |----------|-------------| | lace-connection.md | Wallet connection lifecycle and error handling | | account-management.md | Multiple accounts and address display | | network-switching.md | Testnet vs mainnet configuration | | web3-comparison.md | MetaMask to Lace migration guide |
| Example | Description | |---------|-------------| | connect-button/ | Basic wallet connection button component | | account-switcher/ | Multi-account selection UI | | network-selector/ | Network selection dropdown |
const wallet = window.midnight?.mnLace;
if (!wallet) {
// Show "Install Lace Wallet" prompt
throw new Error('Lace wallet not installed');
}
const walletAPI = await wallet.enable();
// User sees approval popup in Lace
const state = await walletAPI.state();
console.log('Address:', state.address);
console.log('Coin Public Key:', state.coinPublicKey);
const uris = await wallet.serviceUriConfig();
// { indexerUri, indexerWsUri, proverServerUri }
function useMidnightWallet() {
const [connected, setConnected] = useState(false);
const [address, setAddress] = useState<string | null>(null);
const [error, setError] = useState<Error | null>(null);
const connect = async () => {
try {
const wallet = window.midnight?.mnLace;
if (!wallet) throw new Error('Lace not installed');
const api = await wallet.enable();
const state = await api.state();
setAddress(state.address);
setConnected(true);
} catch (e) {
setError(e as Error);
}
};
return { connected, address, error, connect };
}
function formatAddress(address: string): string {
// Bech32m addresses are long - truncate for display
if (address.length <= 20) return address;
return `${address.slice(0, 12)}...${address.slice(-8)}`;
}
proof-handling - Transaction signing flow after wallet connectiontransaction-flows - Submitting transactions via walleterror-handling - Wallet error messages and recovery/dapp-check - Validates wallet provider configuration/dapp-debug wallet - Diagnose wallet connection issuestools
Use when setting up Midnight development environment, installing Compact compiler and developer tools, configuring proof server, verifying prerequisites, or getting started with Midnight development.
tools
--- name: midnight-tooling:midnight-debugging description: Use when encountering Midnight errors like "compact: command not found", "ERR_UNSUPPORTED_DIR_IMPORT", version mismatches, proof server failures, "@midnight-ntwrk" package errors, or compilation failures. --- # Midnight Environment Debugging Expert knowledge for identifying and resolving common Midnight development toolchain issues. ## Diagnostic Approach When encountering Midnight-related errors, follow this systematic approach: 1.
tools
Use when checking Midnight version compatibility, understanding pragma language_version, verifying compiler and runtime version relationships, or troubleshooting version mismatch errors between Midnight components.
tools
Use when setting up CI/CD for Midnight projects, configuring GitHub Actions for Compact contract compilation, running TypeScript tests in CI, validating version consistency, or automating contract builds.