Where are the `window.ethereum` docs?
Asked Answered
D

1

6

I'm calling window.ethereum and there are all these functions but it's confusing what they accept and the types. My understanding is that MetaMask injects something into window.ethereum... so I assume all the methods are from MetaMask? If so, are all the methods different for Coinbase wallet then?

  1. Where are the docs for window.ethereum?
  2. Are there any types associated with this?

My console when I console.log(window.ethereum);

coinbase - window.ethereum 
w {_events: {…}, _eventsCount: 4, _maxListeners: undefined, _filterPolyfill: e.FilterPolyfill, _subscriptionManager: e.SubscriptionManager, …}
close: ƒ ()
enable: ƒ ()
genericRequest: ƒ ()
getChainId: ƒ ()
hasMadeFirstChainChangedEmission: false
isCoinbaseWallet: true
request: ƒ ()
scanQRCode: ƒ ()
send: ƒ ()
sendAsync: ƒ ()
setAppInfo: ƒ ()
setProviderInfo: ƒ ()
updateProviderInfo: ƒ ()
_addresses: ['0xmyAddress']
_eventListener: undefined
_events: {chainChanged: Array(2), accountsChanged: Array(2), connect: ƒ, message: ƒ}
_eventsCount: 4
_filterPolyfill: e.FilterPolyfill {logFilters: Map(0), blockFilters: Set(0), pendingTransactionFilters: Set(0), cursors: Map(0), timeouts: Map(0), …}
_jsonRpcUrlFromOpts: "https://mainnet-infura.wallet.coinbase.com"
_maxListeners: undefined
_overrideIsMetaMask: false
_relay: S {appName: 'localhost:3000', appLogoUrl: 'http://localhost:3000/favicon.ico', subscriptions: t, accountsCallback: ƒ, chainCallback: ƒ, …}
_relayEventManager: e.WalletSDKRelayEventManager {_nextRequestId: 0, callbacks: Map(0)}
_relayProvider: async ƒ I()
_send: ƒ ()
_sendAsync: ƒ ()
_setAddresses: ƒ ()
_storage: e.ScopedLocalStorage {scope: '-walletlink:https://www.walletlink.org'}
_subscriptionManager: e.SubscriptionManager {events: o, subscriptionMiddleware: ƒ}
chainId: (...)
connected: (...)
host: (...)
isChainOverridden: (...)
isMetaMask: (...)
isWalletLink: (...)
jsonRpcUrl: (...)
networkVersion: (...)
selectedAddress: (...)
[[Prototype]]: o

For example:

  1. I can't find setProviderInfo in the Ethereum docs
  2. I can't find setProviderInfo in the Metamask docs either
  3. Just to show I'm not lazy... Coinbase wallet docs are here
Donelladonelle answered 18/4, 2022 at 23:50 Comment(0)
S
3

window.ethereum is described in EIP-1193.

EIP-1193 specification.

Sandlin answered 19/4, 2022 at 7:48 Comment(2)
Thanks. This is helpful but I can't seem to find the methods there. Would you be able to provide some more context by any chance? Are these methods from Metamask, or are they somehow just undocumented, or should I be looking elsewhere? For example, the setProviderInfo method.Donelladonelle
MetaMask is closed source software. Unfortunately you need to contact their customer support to ask for documentation.Sandlin

© 2022 - 2024 — McMap. All rights reserved.