Interface MetaMaskProvider

interface MetaMaskProvider {
    _metamask: { isUnlocked(): Promise<boolean> };
    chainId: string;
    isMetaMask: true;
    networkVersion: string;
    request: MakeRequestMethod<
        "wallet_watchAsset",
        [[WatchAssetParams], boolean],
    > & MakeRequestMethod<"eth_requestAccounts", [undefined | [], string[]]> & MakeRequestMethod<
        "wallet_addEthereumChain",
        [[AddEthereumChainParameter], null],
    > & MakeRequestMethod<
        "wallet_switchEthereumChain",
        [[SwitchEthereumChainParameter], null],
    > & MakeRequestMethod<
        "wallet_getPermissions",
        [undefined | [], Web3WalletPermission[]],
    > & MakeRequestMethod<
        "wallet_requestPermissions",
        [RequestedPermissions[], Web3WalletPermission[]],
    > & MakeRequestMethod<
        "wallet_registerOnboarding",
        [undefined | [], boolean],
    > & MakeRequestMethod<
        "wallet_scanQRCode",
        [undefined | [] | [string], string],
    >;
    selectedAddress: string;
    enable(): Promise<string[]>;
    isConnected(): boolean;
    on(event: "connect", listener: (info: ProviderConnectInfo) => void): this;
    on(event: "disconnect", listener: (error: ProviderRpcError) => void): this;
    on(event: "close", listener: (error: Error) => void): this;
    on(event: "chainChanged", listener: (chainId: string) => void): this;
    on(event: "networkChanged", listener: (networkId: string) => void): this;
    on(
        event: "accountsChanged",
        listener: (accounts: `0x${string}`[]) => void,
    ): this;
    on(event: "message", listener: (message: ProviderMessage) => void): this;
    on(
        event: "notification",
        listener: (payload: ProviderMessage) => void,
    ): this;
    on(event: string, listener: (...args: unknown[]) => void): this;
    send(payload: JsonRpcRequest, callback: JsonRpcCallback): void;
    send(method: string, params?: unknown[]): Promise<JsonRpcResponse>;
    send(payload: JsonRpcRequest): unknown;
    sendAsync(payload: JsonRpcRequest, callback: JsonRpcCallback): void;
}

Hierarchy (View Summary)

Properties

_metamask: { isUnlocked(): Promise<boolean> }

Type declaration

  • isUnlocked:function
    • Experimental

      Returns Promise<boolean>

chainId: string
isMetaMask: true
networkVersion: string
request: MakeRequestMethod<"wallet_watchAsset", [[WatchAssetParams], boolean]> & MakeRequestMethod<
    "eth_requestAccounts",
    [undefined | [], string[]],
> & MakeRequestMethod<
    "wallet_addEthereumChain",
    [[AddEthereumChainParameter], null],
> & MakeRequestMethod<
    "wallet_switchEthereumChain",
    [[SwitchEthereumChainParameter], null],
> & MakeRequestMethod<
    "wallet_getPermissions",
    [undefined | [], Web3WalletPermission[]],
> & MakeRequestMethod<
    "wallet_requestPermissions",
    [RequestedPermissions[], Web3WalletPermission[]],
> & MakeRequestMethod<
    "wallet_registerOnboarding",
    [undefined | [], boolean],
> & MakeRequestMethod<
    "wallet_scanQRCode",
    [undefined | [] | [string], string],
>
selectedAddress: string

Methods

  • Returns Promise<string[]>

  • Returns boolean

  • Parameters

    Returns this

  • Parameters

    Returns this

  • Parameters

    • event: "close"
    • listener: (error: Error) => void

    Returns this

  • Parameters

    • event: "chainChanged"
    • listener: (chainId: string) => void

    Returns this

  • Parameters

    • event: "networkChanged"
    • listener: (networkId: string) => void

    Returns this

  • Parameters

    • event: "accountsChanged"
    • listener: (accounts: `0x${string}`[]) => void

    Returns this

  • Parameters

    Returns this

  • Parameters

    Returns this

  • Parameters

    • event: string
    • listener: (...args: unknown[]) => void

    Returns this