{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_requestAccounts",
  "params": []
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": ["0xabc123..."]
}

Defined in EIP-1102

Requests that the user provides an Ethereum address to be identified by. This method will show a prompt to the user asking them to authorize the connection. Returns a promise that resolves to an array of accounts the user has authorized for the application.

Parameters

This method does not accept any parameters.

Returns

result
Array<string>

An array of Ethereum addresses (hexadecimal strings) that the user has authorized for the application. The array will typically contain a single address, which is the currently selected account in the wallet.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_requestAccounts",
  "params": []
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": ["0xabc123..."]
}

Error Handling

CodeMessageDescription
4001User rejected the requestThe user denied the connection request
4100Requested method not supportedThe provider does not support the eth_requestAccounts method
4200Wallet not connectedThe wallet is not available or connected

Always handle the case where the user rejects the connection request (error code 4001) gracefully in your application.