Skip to content

0xMetaLabs/wagmi_web

Repository files navigation

Wagmi SDK wrapper for Flutter Web

Flutter Node WASM Compatible PRs Welcome

Overview

Wagmi Web exposes the powerful Wagmi SDK to your Flutter web projects, providing intuitive building blocks for creating Ethereum applications. This plugin enables Wallet Connect (Reown AppKit) integration, allowing seamless blockchain-based wallet connections in your Flutter web apps.

Wagmi Web Demo

Key Features

  • πŸ”— Wallet Connect Integration - Connect to 300+ wallets through Reown AppKit (formerly WalletConnect) or injected web3 exposed by Wagmi.
  • πŸš€ 100% WASM Compatible - Full support for WebAssembly compilation
  • πŸ› οΈ Comprehensive Ethereum Tools - Access to Wagmi's complete suite of Web3 utilities
  • πŸ“± Flutter Web Optimized - Seamlessly integrates with Flutter's web platform

Modal Interface

Live Examples

Try out Wagmi Web in action:

Getting started

Add wagmi_web to your pubspec.yaml:

dependencies:
  wagmi_web:

Usage

Basic Setup

import 'package:wagmi_web/wagmi.dart' as wagmi;

// Load and initialize Wagmi lib
await wagmi.init();

// Initialize AppKit (Reown AppKit)
wagmi.AppKit.init(
    'f642e3f39ba3e375f8f714f18354faa4', // Your project ID
    [wagmi.Chain.ethereum.name!, wagmi.Chain.sepolia.name!], // Supported chains
    true, // Include recommended wallets
    true, // Set as default
    wagmi.AppKitMetadata(
        name: 'Reown AppKit',
        description: 'Reown AppKit Example',
        url: 'https://reown.com',
        icons: ['https://avatars.githubusercontent.com/u/37784886'],
    ),
    false, // Email wallet
    [], // Social networks
    true, // Show wallets
    true, // Wallet features
);

// Open the wallet connection modal
wagmi.AppKit.open();

Error Management

Handle Wagmi errors effectively using the WagmiError object:

try {
    final transactionHash = await wagmi.Core.writeContract(
        parameters,
    );
} on wagmi.WagmiError catch (e, stackTrace) {
    if (e.findError(wagmi.WagmiErrors.UserRejectedRequestError) != null) {
        throw Exception('userRejected'); 
    }
    if (e.findError(wagmi.WagmiErrors.InsufficientFundsError) != null) {
        throw Exception('insufficientFunds'); 
    }
    throw Exception('${e.shortMessage}'); 
}

The error stack is accessible through the cause property, and you can use findError to check for specific error types available in the WagmiErrors enumeration.

Available Actions

Implementation Status

βœ… Implemented - Ready to use
🟠 Work In Progress - Coming soon
πŸ”΄ Not Implemented Yet - Planned for future
πŸ“„ TODO - To be managed

For detailed API documentation, visit Wagmi Actions Documentation.

Action Name Status
call βœ… Implemented
connect πŸ”΄
deployContract πŸ”΄
disconnect βœ… Implemented
estimateFeesPerGas βœ… Implemented
estimateGas βœ… Implemented
estimateMaxPriorityFeePerGas βœ… Implemented
getAccount βœ… Implemented
getBalance βœ… Implemented
getBlock βœ… Implemented
getBlockNumber βœ… Implemented
getBlockTransactionCount βœ… Implemented
getBytecode βœ… Implemented
getChainId βœ… Implemented
getChains βœ… Implemented
getClient πŸ”΄
getConnections βœ… Implemented
getConnectorClient πŸ”΄
getConnectors πŸ”΄
getEnsAddress πŸ”΄
getEnsAvatar πŸ”΄
getEnsName πŸ”΄
getEnsResolver πŸ”΄
getEnsText πŸ”΄
getFeeHistory βœ… Implemented
getGasPrice βœ… Implemented
getProof πŸ”΄
getPublicClient πŸ”΄
getStorageAt πŸ”΄
getToken βœ… Implemented
getTransaction βœ… Implemented
getTransactionConfirmations βœ… Implemented
getTransactionCount βœ… Implemented
getTransactionReceipt βœ… Implemented
getWalletClient πŸ”΄
multicall πŸ”΄
prepareTransactionRequest πŸ”΄
readContract βœ… Implemented
readContracts βœ… Implemented
reconnect βœ… Implemented
sendTransaction βœ… Implemented
signMessage βœ… Implemented
signTypedData πŸ”΄
simulateContract πŸ”΄
switchAccount βœ… Implemented
switchChain βœ… Implemented
verifyMessage βœ… Implemented
verifyTypedData πŸ”΄
waitForTransactionReceipt βœ… Implemented
watchAccount βœ… Implemented
watchAsset βœ… Implemented
watchBlockNumber πŸ”΄
watchBlocks πŸ”΄
watchChainId βœ… Implemented
watchClient πŸ”΄
watchConnections βœ… Implemented
watchConnectors πŸ”΄
watchContractEvent βœ… Implemented
watchPendingTransactions πŸ”΄
watchPublicClient πŸ”΄
writeContract βœ… Implemented

Development Environment

Prerequisites

Ensure you have the following tools installed:

  • Flutter >= 3.22.3
  • Node.js >= 18

Building & Running

JS/WASM Support

Compile TypeScript Code

Build the JavaScript code for web browser embedding:

# Install dependencies
npm install

# Build production library
npm run build

# Build & watch in development mode
npm run dev

Run Flutter Project

After building the TypeScript code, run your Flutter project normally:

flutter run -d chrome
flutter run -d chrome --wasm

Testing

TypeScript Tests

npm test

VSCode Tip: For debugging support, create your terminal using the command Debug: JavaScript Debug Terminal

Dart Tests

# Run tests
dart test -p chrome

# Run with debugging
dart test -p chrome --pause-after-load

Contributing

We welcome all contributions! Whether it's:

  • πŸ› Bug reports
  • πŸ’‘ Feature requests
  • πŸ“ Documentation improvements
  • πŸ”§ Code contributions

Please feel free to submit a Pull Request. All PRs are welcome!

License

This project is licensed under the GNU Affero General Public License.

Support

For issues, feature requests, or questions:


Made with ❀️ by 0xMetaLabs

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages