eth_accounts - Ethereum
Example code for the eth_accounts JSON RPC method. Сomplete guide on how to use eth_accounts JSON RPC in GetBlock Web3 documentation.
This method returns the list of accounts owned by the client. On managed RPC endpoints like GetBlock, this always returns an empty array [] — the endpoint doesn't hold user keys. On self-hosted Geth or similar with unlocked wallet accounts, it would return the list of managed addresses.
Parameters
This method takes no parameters.
Request
curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_accounts",
"params": [],
"id": "getblock.io"
}'const axios = require('axios');
const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
jsonrpc: '2.0',
method: 'eth_accounts',
params: [],
id: 'getblock.io'
}, {
headers: { 'Content-Type': 'application/json' }
});
console.log(response.data.result);import requests
response = requests.post(
'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
headers={'Content-Type': 'application/json'},
json={
'jsonrpc': '2.0',
'method': 'eth_accounts',
'params': [],
'id': 'getblock.io'
}
)
print(response.json())Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": []
}Response Parameters
jsonrpc
string
JSON-RPC protocol version ("2.0")
id
string
Request identifier matching the request
result
array of string
Array of account addresses owned by the client — always [] on public RPC endpoints
Use Cases
Client Behavior Detection: Confirm the endpoint is a public-RPC provider (empty array) rather than a wallet-managing self-hosted node
Legacy Wallet Compatibility: Support older wallet UIs that check
eth_accountsbefore initiating a transaction (though modern wallets usewallet_requestAccountsvia injected providers)Tooling Sanity Checks: Verify the endpoint responds to standard JSON-RPC method calls
Error Handling
-32603
Internal error
Node failed to enumerate its accounts
Web3 Integration
Last updated
Was this helpful?