Skip to content

useAddNetwork

Adds a new network configuration to a connector.

WARNING

The addNetwork method is currently supported only by XVerse wallet. Other connectors may not implement this functionality yet.

Import

ts
import { useAddNetwork } from "@midl/react";

Example

ts
const { addNetwork, addNetworkAsync } = useAddNetwork();
addNetwork({ connectorId: 'my-connector', networkConfig: { id: 'testnet', name: 'Testnet', rpcUrl: 'https://...' } });

Parameters

NameTypeDescription
configConfig(optional) Config object to use instead of the one from context.
mutationUseMutationOptions(optional) Mutation options for react-query.

Returns

NameTypeDescription
addNetwork(variables: UseAddNetworkVariables) => voidFunction to initiate adding a network.
addNetworkAsync(variables: UseAddNetworkVariables) => Promise<void>Function to asynchronously add a network.
...restobjectAdditional mutation state from useMutation.

UseAddNetworkVariables

NameTypeDescription
connectorIdstringThe connector ID
networkConfigNetworkConfigThe network configuration