In the web application I am working on , I need to find the current price of an ERC20 token listed on etherscan . How can this be done using code or some etherscan api ? Any help is appreciated.
[Ethereum] API or code to find the current price of a ERC20 compliant token listed on Etherscan
etheretherscan
Related Solutions
Etherscan's FAQ page answers your first question in the "Token Tracker Listings" section. Here is what it says:
Any compatible ERC20 tokens on the Ethereum blockchain can be publicly and transparently tracked via https://etherscan.io/token-search
In addition to the above ERC20 token tracker, we also have a selected list of tokens at https://etherscan.io/tokens. The decision to list these tokens here are based on the following criteria, but not limited to :
- Token Popularity and Demand (important)
- Supported by a large exchange (i.e Poloniex, Kraken, Coinbase)
- Has a unique proposition/utility
- Visible website, about us, team page, company mailing address, official support channels like reddit, twitter, slack, facebook.
- Fully ERC20 compliant (https://github.com/ethereum/EIPs/issues/20)
- Is NOT a ponzi, pyramid, mlm or other similiar schemes
You may request for a token to be added on the https://etherscan.io/tokens page by filling up the following form https://docs.google.com/forms/d/e/1FAIpQLSe9t2VBwje7zO_xMKT3bO92H8nrzsQJCu2KeFU3PLgAjRONLA/viewform , however the ultimate decision will be at our own discretion.
Here's json result from your api call:
{
jsonrpc: "2.0",
id: 1,
result: {
blockHash: "0x8fe66b0c15a1c1155338bb5628db55f05cfe72d1194931134b4721cd07e9eda7",
blockNumber: "0x416850",
from: "0x167a9333bf582556f35bd4d16a7e80e191aa6476",
gas: "0x13880",
gasPrice: "0x4e3b29200",
hash: "0x03430ecdf52d37a8d3645fa9b19c072ec367edbd0d4eba3cc1c7f7c5e7dcc7d2",
input: "0xa9059cbb0000000000000000000000007a2641bb2fb31ccd33ba5488c886c3bc4714ec6b000000000000000000000000000000000000000000000054ca7578dcf8bb7aa0",
nonce: "0x15a82",
to: "0x9a642d6b3368ddc662ca244badf32cda716005bc",
transactionIndex: "0x2a",
value: "0x0",
v: "0x25",
r: "0x790a06d5773006ecbc719354d966d100470e6267a68d3446ca0ebfd8df4452b5",
s: "0x4e58eb2997a3c8add1386a47a71ac5bb915a2a53343883ea1ea4d8e69a6be486"
}
}
Please take care of the input field:
First 4 bytes is method hash:
a9059cbb
Next 32 bytes is target address:
0000000000000000000000007a2641bb2fb31ccd33ba5488c886c3bc4714ec6b
Last 32 bytes is value of ERC20 tokens transferred:
000000000000000000000000000000000000000000000054ca7578dcf8bb7aa0
0x54ca7578dcf8bb7aa0 = 1.5641152016500001e+21
Best Answer
To be honest it depends on exchanges. Different exchanges will have different trade value and It depending on demand. Unfortunately there is no common value for token. Usually there will be 1-5 some times 15% price different because it depending on country/exchange/local law/exchange commission etc..,
Yes there will be api is available. Refer below link's
https://api.coinmarketcap.com/v1/ticker/
https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=EOS,USD,EUR