Wagmi
createPublicProviderWagmi(params) → IPublicProvider
Creates a public provider from a Wagmi Config. This adapter lets the SDK reuse the public clients that Wagmi configures for read-only blockchain operations such as fetching balances, estimating gas, and reading contracts.
Parameters
Examples
Basic usage
import { createClient, createPublicProviderWagmi } from '@manifoldxyz/client-sdk';
import { createConfig, http } from '@wagmi/core';
import { mainnet, base } from '@wagmi/core/chains';
// Configure Wagmi with the networks you intend to support
const config = createConfig({
chains: [mainnet, base],
transports: {
[mainnet.id]: http('YOUR_MAINNET_RPC_URL'),
[base.id]: http('YOUR_BASE_RPC_URL'),
},
});
// Create the Manifold public provider
const publicProvider = createPublicProviderWagmi({ config });
// Pass into the Manifold client
const client = createClient({ publicProvider });Multi-network with fallback transports
Browser usage with Wagmi React
Event Subscription
Subscribe to contract events in real-time using the subscribeToContractEvents method:
Notes
The Wagmi config must include a transport for every chain you expect to access. If a chain is missing, calls will throw
ClientSDKErrorwithUNSUPPORTED_NETWORK.The adapter uses Wagmi's
getPublicClientunder the hood, so the config should expose a public client transport (e.g.,http,fallback).Wagmi handles provider caching; reuse the same config instance when possible to avoid creating redundant clients.
Last updated