Ethers v5
createPublicProviderEthers5(providers, fallbackProviders?) → IPublicProvider
Creates a public provider from Ethers v5 providers with optional fallback support.
Parameters
Parameter
Type
Required
Description
Examples
Basic usage
import { createPublicProviderEthers5 } from '@manifoldxyz/client-sdk';
import { ethers } from 'ethers';
// Create providers for each network
const providers = {
1: new ethers.providers.JsonRpcProvider('YOUR_MAINNET_RPC_URL'),
8453: new ethers.providers.JsonRpcProvider('YOUR_BASE_RPC_URL'),
10: new ethers.providers.JsonRpcProvider('YOUR_OPTIMISM_RPC_URL')
};
// Create the public provider
const publicProvider = createPublicProviderEthers5(providers);
// Use with Manifold client
const client = createClient({ publicProvider });With fallback providers
import { createPublicProviderEthers5 } from '@manifoldxyz/client-sdk';
import { ethers } from 'ethers';
// Primary providers
const providers = {
1: [new ethers.providers.JsonRpcProvider('PRIMARY_MAINNET_RPC_URL'),
new ethers.providers.JsonRpcProvider('SECONDARY_MAINNET_RPC_URL')
],
};
// Create the public provider with fallback support
const publicProvider = createPublicProviderEthers5(providers);
// Use with Manifold client
const client = createClient({ publicProvider });Event Subscription
Subscribe to contract events in real-time using the subscribeToContractEvents method:
import { createPublicProviderEthers5 } from '@manifoldxyz/client-sdk';
import { ethers } from 'ethers';
const provider = new ethers.providers.JsonRpcProvider('YOUR_MAINNET_RPC_URL');
const publicProvider = createPublicProviderEthers5({
1: provider
});
// Subscribe to Transfer events
const unsubscribe = await publicProvider.subscribeToContractEvents({
contractAddress: '0x...',
abi: erc20Abi,
networkId: 1,
topics: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'], // Transfer event signature
callback: (log) => {
console.log('Transfer event:', log);
}
});
// Later: unsubscribe from events
unsubscribe();Last updated