This example demonstrates how to integrate the Phantom SDK's Ethereum provider with wagmi to create a seamless Web3 experience using standard Ethereum tooling.
- Custom wagmi connector for Phantom SDK
- EIP-1193 compliant Ethereum provider integration
- Sign message functionality using wagmi hooks
- Chain switching support
- Standard wagmi patterns and best practices
- Custom Connector: We created a custom wagmi connector (
phantom-connector.ts) that wraps the Phantom SDK - EIP-1193 Compliance: The Phantom SDK's
sdk.ethereumprovider is EIP-1193 compliant, making it compatible with wagmi - Standard Hooks: Use standard wagmi hooks like
useSignMessage,useConnect,useAccountetc. - Seamless Integration: The Phantom wallet appears as a standard Ethereum wallet to wagmi and other Web3 tools
wagmi hooks → Phantom Connector → Phantom SDK → Ethereum Provider (EIP-1193)
-
Install dependencies:
yarn install
-
Start the development server:
yarn start
-
Open http://localhost:3000 to view the example
src/phantom-connector.ts- Custom wagmi connector for Phantom SDKsrc/wagmi.ts- wagmi configurationsrc/WalletDemo.tsx- Demo component showcasing the integrationsrc/App.tsx- Main app with wagmi and React Query providers
- Click "Connect Phantom Wallet" to connect using the embedded Phantom wallet
- Once connected, you'll see your Ethereum address and current chain
- Enter a message and click "Sign Message" to test the integration
- The signature will be displayed, proving the wagmi integration works
- Standard Web3 Tooling: Use any wagmi-compatible library or tool
- Type Safety: Full TypeScript support with wagmi's typed hooks
- React Patterns: Familiar React hooks pattern for Web3 operations
- Ecosystem Compatibility: Works with the entire wagmi/viem ecosystem
This example can be extended to support:
- Transaction sending with
useSendTransaction - Contract interactions with
useReadContractanduseWriteContract - ENS resolution with
useEnsNameanduseEnsAddress - Any other wagmi functionality
The Phantom SDK's EIP-1193 compliant provider makes all wagmi features available out of the box!