Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
This article examines EIP-2696, which defines a standard for communication between Ethereum providers and clients through a shared JavaScript object, enabling access to Ethereum and potentially to signing tools.
This article translates, summarizes, and supplements the material linked below.
I have also covered other EIPs.
Overview
The standard defines remote procedure calls (RPC) between an Ethereum provider, which provides access to the Ethereum blockchain, and an Ethereum client that uses that access. It assumes that both can interact through a shared JavaScript object.
The specification describes an object through which JavaScript applications can communicate with Ethereum. It defines only the transport mechanism, not valid payloads or how clients and providers discover or agree on their contents.
Details concerning how the Ethereum object is exposed and where it becomes available are left to future standards.
Motivation
In JavaScript runtimes such as Node.js, Electron, and browsers, the runtime or a runtime plugin can inject an object into the execution environment.
Runtime and plugin developers may choose to expose an Ethereum provider to JavaScript applications and scripts running within that environment. This provides indirect access to a blockchain such as Ethereum and potentially to signing tools.
Standardizing the object's shape maximizes interoperability between providers and clients.
A runtime is software that provides an environment for executing programs. A JavaScript runtime provides an environment in which JavaScript programs execute. Examples include Node.js, browser JavaScript engines such as V8, SpiderMonkey, and JavaScriptCore, and Electron.
Runtime plugins are extensions or modules that add functionality to the runtime. They allow developers to extend existing environments with additional capabilities, such as image processing, database access, or networking.
In Node.js, for example, developers can install external packages and modules through npm (Node Package Manager) and integrate them into a project. These packages can provide additional functionality within the runtime.
Likewise, Electron developers can incorporate external JavaScript modules and libraries to extend their applications.
In short, runtimes provide an execution environment, while plugins and modules extend the functionality available in that environment.
Specification
Interface
The following TypeScript interfaces define the request transport.
interface RequestArguments {
readonly method: string;
readonly params?: readonly unknown[] | object;
}
interface EthereumProvider {
request(args: RequestArguments): Promise<unknown>
}The RequestArguments interface defines request arguments through two properties: method and params. The latter is optional and can contain an array or object. The interface uses readonly property modifiers.
The EthereumProvider interface exposes a request method returning Promise<unknown>. It accepts a single argument conforming to RequestArguments.
Providers must implement this method on their EthereumProvider object.
If a provider supports JSON-RPC requests specified elsewhere, callers must supply the corresponding JSON-RPC method as RequestArguments.method and parameters matching the RPC call's params field as RequestArguments.params.
Parameters should be represented as JavaScript values matching the specified JSON-RPC types, rather than as an already serialized JSON string.
Example
The following example illustrates a JSON-RPC request and its equivalent EthereumProvider.request invocation.
First, consider the JSON-RPC request payload.
{ "jsonrpc": "2.0", "id": 1, "method": "do_work", "params": [ 5, "hello" ] }The corresponding provider invocation is as follows.
provider.request({ method: 'do_work', params: [ 5, 'hello' ] })Results
If a provider supports a JSON-RPC request, it must return a result matching the expected result definition of that request.
Example
{ "jsonrpc": "2.0", "id": 1, "result": { "color": "red", "value": 5 } }The corresponding EthereumProvider.request response is:
{ color: 'red', value: 5 }Errors
The following table describes the specified error codes.
| code | message | meaning |
|---|---|---|
4001 |
User Rejected Request | The user rejected the request. |
4100 |
Unauthorized | The requested method or account has not been authorized by the user. |
4200 |
Unsupported Method | The provider does not support the requested method. |
4900 |
Disconnected | The provider is disconnected from all chains. |
4901 |
Chain Disconnected | The provider is not connected to the requested chain. |
If a provider cannot process a request, it rejects the promise with an error. Whenever possible, the rejection should conform to the specified ProviderRpcError shape.
It is impossible to guarantee that JavaScript applications will never encounter errors such as out-of-memory or stack-overflow failures. Nevertheless, providers should make reasonable efforts to ensure promise rejections conform to the specified shape.
When an error code is defined by the table, the JSON-RPC specification, or another applicable RPC standard, the reason must match the code's established meaning. The message must be consistent with that meaning. The data field can contain additional information useful for understanding or troubleshooting the error.
Additional Notes
This transport may not be the theoretically optimal communication mechanism between applications and blockchains, but it closely follows established community practices. Migration from existing systems should therefore be relatively straightforward.
Most existing communication uses JSON-RPC, so compatibility with JSON-RPC conventions helps existing systems integrate the interface.
The standard prioritizes interoperability with established practices and facilitates migration from existing JSON-RPC-based systems.
Security
The proposal describes the Ethereum provider-client relationship as a trusted relationship. Users are assumed to trust the provider that is injected into their client or explicitly connected to it.
The provider supplies services and functionality that the client relies on. Under this trust model, a user authorizes the provider's presence or connection and trusts it to perform its role.
This describes the proposal's trust assumption; selecting a provider does not itself guarantee its security.
Citation
Micah Zoltu (@MicahZoltu), Erik Marks (@rekmarks), "EIP-2696: JavaScript request method RPC transport," Ethereum Improvement Proposals, no. 2696, June 2020. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2696.
Conclusion
EIP-2696 standardizes RPC communication between Ethereum providers and JavaScript clients through a shared object.
If you have questions, feel free to contact me on Twitter.
I also publish articles on the following platforms.


