# eth_getBalance - Ethereum Returns the balance of the account of a given address. # Parameters * DATA, 20 Bytes - Address to check for balance. * QUANTITY|TAG - Integer block number, or the string "latest", "earliest" or "pending", see the default block parameter. ``` params: ["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"]; ``` *** # Returns QUANTITY - Hex value of the current ETH balance for the given address, measured in wei. *** # Example ## Request ```curl curl https://eth-mainnet.unifra.io/v1/your-api-key \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"],"id":0}' ``` ```Text Postman URL: https://eth-mainnet.unifra.io/v1/your-api-key RequestType: POST Body: { "jsonrpc":"2.0", "method":"eth_getBalance", "params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"], "id":0 } ``` ## Result ```json { "jsonrpc": "2.0", "id": 0, "result": "0x7c2562030800" } ``` # Converting eth\_getBalance response into ETH To convert the hex string response, measured in [Wei](https://github.com/unifra20/docs/blob/main/chain-apis/ethereum-api/broken-reference/README.md) to a decimal value measured in ETH. We need to complete two steps: 1. Convert the hex response into decimal (Wei) 2. Convert the [Wei](https://github.com/unifra20/docs/blob/main/chain-apis/ethereum-api/broken-reference/README.md) decimal into ETH decimal (10^18 wei = 1 eth) Depending on what library or language you are using, there are several options here. ```python # conversion from hex string to decimal dec = int("hex strong response",16) # conversion from Wei to to ETH ethBalance = dec*(10**18)Parameters DATA, 20 Bytes - address to check for balance. QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter . params: [ '0xc94770007dda54cF92009BFF0dE90c06F603a09f', 'latest' ] Returns QUANTITY - hex value of the current ETH balance for the given address, measured in wei. Example Request curl https://eth-mainnet.unifra.io/v1/your-api-key \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"],"id":0}' URL: https://eth-mainnet.unifra.io/v1/your-api-key RequestType: POST Body: { "jsonrpc":"2.0", "method":"eth_getBalance", "params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"], "id":0 } Result { "jsonrpc": "2.0", "id": 0, "result": "0x7c2562030800" } Converting eth_getBalance response into ETH To convert the hex string response, measured in Wei to a decimal value measured in ETH we need to complete two steps: Convert the hex response into decimal (Wei) Convert the Wei decimal into ETH decimal (10^18 wei = 1 eth) Depending on what library or language you are using, there are several options here. # conversion from hex string to decimal dec = int("hex strong response",16) # conversion from Wei to to ETH ethBalance = dec*(10**18) ``` # OpenAPI definition ```json { "openapi": "3.1.0", "info": { "title": "ethereum-api", "version": "1.0" }, "servers": [ { "url": "https://eth-mainnet.unifra.io/v1" } ], "security": [ {} ], "paths": { "/{your-api-key}": { "post": { "summary": "web3_sha3 - Ethereum", "description": "Returns Keccak-256 (not the standardized SHA3-256) of the given data.", "operationId": "web3_sha3", "parameters": [ { "name": "your-api-key", "in": "path", "schema": { "type": "string" }, "required": true } ], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "jsonrpc": { "type": "string", "default": "2.0" }, "method": { "type": "string", "default": "web3_sha3" }, "params": { "type": "array", "items": { "type": "string" } }, "id": { "type": "integer", "default": 0, "format": "int32" } } } } } }, "responses": { "200": { "description": "200", "content": { "application/json": { "examples": { "Result": { "value": "{}" } }, "schema": { "type": "object", "properties": {} } } } }, "400": { "description": "400", "content": { "application/json": { "examples": { "Result": { "value": "{}" } }, "schema": { "type": "object", "properties": {} } } } } }, "deprecated": false } } }, "x-readme": { "headers": [], "explorer-enabled": true, "proxy-enabled": true }, "x-readme-fauxas": true } ```