⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

eth_accounts

Returns a list of addresses owned by the client.

When to Use This Method

eth_accounts is used for:

  • Wallet Integration - Retrieve available accounts from connected wallets
  • Account Management - List all accounts controlled by the node
  • DApp Authentication - Verify user has accounts available
  • Multi-Account Support - Handle multiple account scenarios
info

This method typically returns an empty array [] on public RPC endpoints as they don't manage private keys. It's primarily used with local nodes or wallet-injected providers.

Parameters

This method accepts no parameters.

{
"jsonrpc": "2.0",
"method": "eth_accounts",
"params": [],
"id": 1
}

Returns

Array - Array of account addresses owned by the client.

  • Type: Array of strings
  • Format: Ethereum-compatible addresses (0x prefixed, 20 bytes)
  • Example: ["0x407d73d8a49eeb85d32cf465507dd71d507100c1"]

Implementation Examples

curl -X POST https://api-tron-jsonrpc.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_accounts",
"params": [],
"id": 1
}'

Example Response

{
"jsonrpc": "2.0",
"id": 1,
"result": []
}
note

Public RPC endpoints typically return an empty array since they don't manage private keys. To get accounts, use wallet-injected providers or local nodes with unlocked accounts.

Common Use Cases

1. Wallet Connection Check

async function checkWalletConnection() {
const accounts = await provider.send('eth_accounts', []);

if (accounts.length === 0) {
console.log('No wallet connected');
return false;
}

console.log(`Connected with account: ${accounts[0]}`);
return true;
}

2. Multi-Account Selection

async function selectAccount() {
const accounts = await provider.send('eth_accounts', []);

if (accounts.length > 1) {
// Show account selector UI
return await showAccountSelector(accounts);
}

return accounts[0];
}

3. Account Change Detection

let currentAccount = null;

async function monitorAccountChange() {
const accounts = await provider.send('eth_accounts', []);
const newAccount = accounts[0] || null;

if (newAccount !== currentAccount) {
currentAccount = newAccount;
console.log('Account changed to:', currentAccount);
// Handle account change
}
}

Error Codes

CodeMessageDescription
-32600Invalid RequestThe JSON sent is not a valid Request object
-32601Method not foundThe method eth_accounts is not available
-32602Invalid paramsInvalid method parameters
-32603Internal errorInternal JSON-RPC error