Monad Wallet & Integration
⚠️ CRITICAL: Safe Multisig Required - No Exceptions
Any transaction other than deploying a Safe multisig must be proposed to the user via the deployed multisig.
Security rules:
- NEVER ask for user's private key (critical violation)
- Use the agent wallet (encrypted keystore at
~/.monskills/keystore) - NEVER export or store private keys in plaintext
Check if the agent has generated a wallet before. If the keystore directory ~/.monskills/keystore exists and contains a keystore file, the wallet already exists.
Creating a wallet
Foundry is required. Check if installed:
foundryup --version
Generating a new wallet
mkdir -p ~/.monskills/keystore && cast wallet new ~/.monskills/keystore --unsafe-password ""
To retrieve the address later:
cast wallet list --dir ~/.monskills/keystore
Decrypting the private key for scripts
cast wallet decrypt-keystore --keystore-dir ~/.monskills/keystore <KEYSTORE_FILENAME> --unsafe-password ""
Fund the wallet on Monad testnet via faucet before deployment.
Skill URL: https://monskills.vercel.app/wallet/SKILL.md
Wallet Integration (merged)
name: wallet-integration description: How to integrate wallet connection into a Next.js app on Monad using RainbowKit with Wagmi and viem.
Integrate wallet connection into a Next.js frontend using RainbowKit with Wagmi and viem.
Monad is natively supported by Wagmi — import monad and monadTestnet from wagmi/chains.
Optional prerequisite
Store WalletConnect project ID as NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID environment variable.
Installation
npm install @rainbow-me/rainbowkit wagmi viem@2.x @tanstack/react-query
Setup
1. Configure RainbowKit
config/index.ts:
import { getDefaultConfig } from '@rainbow-me/rainbowkit'
import { monad, monadTestnet } from 'wagmi/chains'
import { http } from 'wagmi'
const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID
export const config = getDefaultConfig({
appName: 'My App',
projectId,
chains: [monad, monadTestnet],
transports: {
[monad.id]: http('https://rpc.monad.xyz'),
[monadTestnet.id]: http('https://testnet-rpc.monad.xyz'),
},
ssr: true,
})
2. Create providers
providers.tsx:
'use client'
import '@rainbow-me/rainbowkit/styles.css'
import { RainbowKitProvider } from '@rainbow-me/rainbowkit'
import { WagmiProvider } from 'wagmi'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { config } from '@/config'
import type { ReactNode } from 'react'
const queryClient = new QueryClient()
export default function Providers({ children }: { children: ReactNode }) {
return (
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
<RainbowKitProvider>
{children}
</RainbowKitProvider>
</QueryClientProvider>
</WagmiProvider>
)
}
3. Update layout
import Providers from '@/providers'
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<Providers>{children}</Providers>
</body>
</html>
)
}
4. Next.js scripts (add --webpack flag)
{
"scripts": {
"dev": "next dev --webpack",
"build": "next build --webpack"
}
}
Connect Button
import { ConnectButton } from '@rainbow-me/rainbowkit'
export default function Header() {
return <ConnectButton />
}
Reference
Full RainbowKit docs: https://rainbowkit.com/docs/installation
Skill URL: https://monskills.vercel.app/wallet-integration/SKILL.md