EIP-5749: The 'window.evmproviders' object

After thinking about it I prefer a
window.postMessage() protocol with:

  1. initial handshake request answered by all extensions that support the requested chains (CAIP25 + extension name, id?, icon, session ID)
  2. every request following a standardised request body + session id (or just extension id??) → only the extension that have the right session id should answer.
    maybe something like this

Request

{
  type: "web3Request", // differentiate from other protocols that use window.postMessage
  version: "1.0.0",
  sessionId/extensionId/channelId: null, // empty in handshake request ; targets ALL extensions that want to answer
  requestBody: {
       "id": 1,
       "jsonrpc": "2.0",
       "method": "provider_authorization",
       "params": {
         "requiredNamespaces": { // I would rename these properties 
            "eip155": {
              "chains": ["eip155:1", "eip155:137"],
              "methods": ["eth_sendTransaction", "eth_signTransaction", "eth_sign", "get_balance", "personal_sign"],
            "events": ["accountsChanged", "chainChanged"]
          },
          "eip155:10": {
            "methods": ["get_balance"],
            "events": ["accountsChanged", "chainChanged"]
          },
          "cosmos": {
            ...
          }
        },
        "optionalNamespaces":{
          "eip155:42161": {
            "methods": ["eth_sendTransaction", "eth_signTransaction", "get_balance", "personal_sign"],
            "events": ["accountsChanged", "chainChanged"]
        },
        "sessionProperties": {
          "expiry": "2022-12-24T17:07:31+00:00", // better unix timestamp?
          "caip154-mandatory": "true"
        }         
      }
  }
}

Result

{
  type: "web3Response",
  version: "1.0.0",
  sessionId/extensionId: '1234565432', // each extension answer with their extension id/session id
  requestBody: {
       "id": 1,
       "jsonrpc": "2.0",
       "result": {
          // whatever goes here, like for a handshake, the extension name, id, icon, supported schemes/networks/chains
          ...
       }
  }
}

Benefits:

  • removes any injected object
  • lets dapps load any provider lib: basic one, one with modal to select extension, or whatever UX they like
  • clear direction to talk to any extension, and even have chainId/type selection possible

Question:

  • why sessions? ist a simple static channelId/extensionId enough?

(As for CAIP 25 i would rename some of the properties, to make it simpler and cleaner)

@kvhnuke @rekmarks @kdenhartog @MicahZoltu
What you guys think?

2 Likes