Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting ETH FIAT conversion rates via Web3

Am I missing something or is this information not available via web3 in the browser even if the ETH USD rate is displayed in Metamask.

Cannot find anything in the docu.

is the standard practice to use a cross-crypto API?

like image 953
codervince Avatar asked Sep 05 '25 22:09

codervince


1 Answers

Ethereum Protocol Doesn't Care About Ether/Fiat Exchange:

The fiat price of Ether is not recorded on the Ethereum network, nor is it handled by the Ethereum protocol. The only reason MetaMask show this information is because it is a useful feature for users, but they get this information from exchanges that trade Ether for fiat.

Sources of Exchange Data:

Because Ether is traded on the free market there is no central organisation dictating the price. The best thing you can do to find the "current price" is to query the APIs of exchanges (https://poloniex.com/exchange, https://www.kraken.com/) and/or market tracking sites (https://coinmarketcap.com/). You can interrogate these APIs and use the rates presented as your guide for the Ether/Fiat exchange rate.

https://api.coinmarketcap.com/v1/ticker/ethereum

[
    {
        "id": "ethereum", 
        "name": "Ethereum", 
        "symbol": "ETH", 
        "rank": "2", 
        "price_usd": "211.824", 
        "price_btc": "0.0930788", 
        "24h_volume_usd": "1191280000.0", 
        "market_cap_usd": "19499368103.0", 
        "available_supply": "92054574.0", 
        "total_supply": "92054574.0", 
        "percent_change_1h": "-0.51", 
        "percent_change_24h": "21.85", 
        "percent_change_7d": "20.51", 
        "last_updated": "1496138662"
    }
]

Please note :

Exchanges will tend to have different prices depending on their user's activity, most the time the price won't vary much but they can do. That's why market tracking sites are more accurate as they give weighted averages.

like image 140
Samuel Hawksby-Robinson Avatar answered Sep 11 '25 04:09

Samuel Hawksby-Robinson