Is there a way to get the value of a crypto in another one with uniswap - ethereum

Im a beginner in the blockchain/crypto world and I was wondering if there is a way to get the value of a crypto in another one on uniswap (like in the image where we can see that on uniswap 1 ETH = 2997 1INCH). , like using the SDK or the Router ecc.. If you have any suggestion please help me.
I tried using the uniswap sdk and the smart contracts periphery contracts but i couldn't find nothing that could help me

Yes. You can get the price of a cryptocurrency as it is traded in Uniswap.
For Uniswp v2 like exchanges, the price can be calculated as a ratio of reverse0 / reserve1
The related smart contract call is pair.getReserves
For more complete example, you can read the source code of get_current_mid_price() function here
For Uniswap v3, it is there are similar helper functions in Uniswap perihelia contracts

Related

Accessing API with Apps Scripts, but IP restricted from US region

I'm trying to access the Binance API from a Google Sheet using a Apps Script function. Unfortunately api.binance.com is restricted from the US and responds with a 451 and api.binance.us does not have the data I require.
Is it possible make the Sheet/script execute the request from a different region?
Alternatively, is there a way to proxy the request via another region? Web proxies don't seem to offer a way to achieve this.
I would recommend looking for an alternative API you can use before you attempt this. You can use proxies (free proxies are not recommended as they are known for reading your traffic) in the region you want (outside of the US in your case) which will only help if the binance API uses your IP address to find your region. If they somehow accept the region as a header or use your timezone to determine your region, you will have to spoof those values.
The solution I'm going with is using a market data service like Coin Market Cap or CoinGecko.

How can I get all the NFT contract address via opensea API?

I just want to get all the contract address of all NFTs that are in the market, in particular I want to get the contract address for all ERC-721 tokens. From the opensea API documents, it seems that i can only get all the contract address of a specific owner..
Thank in advance!
You can query https://docs.opensea.io/reference/retrieving-collections to get all the collections by not passing in the asset_owner param. However, this API can only return 50K items and not more than that 😟.

How can I get "Event Name & Method Name" via Polygonscan API?

Currently, the company which I am working in, they want to make a statistics system for P2E games which have (or will have) ERC-20 tokens based on Polygon.
I have to accumulate the logs came from blockchain networks and game servers to know how much tokens players earn/spend, and the productivity of each contents/activities.
So, I need to get "The event name & method name" from polygonscan API. unfortunately, Polygonscan API just offer "Transfer Logs" only instead of offering all of logs.
https://docs.polygonscan.com/api-endpoints/accounts#get-a-list-of-erc-20-token-transfer-events-by-address
I found this api will return results with "Input" column. but it has just "deprecated" as value. is there any way to get what I want?
I choose "ethereum" as tags instead of "polygon" if I disturb you, I apologize this. I think ethereum has similar system with polygon because Polygon is based on Ethereum. and, the "Polygon" tags, as you know, it is for "3D rendering" not for crypto coins.

Get Binance USDT trc-20 trades (ETH/USDT)?

I have a route in nodejs project that returns recent trades from public Binance api route - GET /api/v3/trades.
And my current task is - make this route to return trades from TRON network that were completed in Binance (ETH/TETHER USDT).
After some research I have come to the conclusion that isn't possible and trading pairs on Binance are "network-agnostic".
Am I right or could someone explain this to me?

How to compute cost of Google API calls?

Like everyone else, I received an email saying that I need to activate billing to continue using the Google Maps API, and so I did. Now I try to understand what the cost my API usage will be – and I’m lost.
On Google Cloud Platform API / API and services I can see that there are 1 635 Maps Elevation API calls and 1157 Maps Java Script API calls at noon today.
At the same time, under IAM and administration / Quotas I see : 123 / 2500 requests per day.
What is the relation between the 1635+1157 API calls and the 123 requests?
I used 63 842 Elevation API calls and 36 023 Maps Java Script calls during the last 30 days – according to the price sheet google cloud price sheet.
This would cost 63842*5/1000+36023/1000*7 $ = 571 $ - yet the price shown is $0 for now.
It’s a free website - if I have to pay this kind of money it will be down next month…
Sorry if this is not the right place to ask, but I do this as a hobby. Thanks.
Just a little summary, now that the new cost scheme is in effect:
The Google Cloud Platform API / API and services section is the reference for computing API usage cost
The IAM and administration / Quotas section ‘may take more time to update’ (according to Google support) and was off by a factor of 10 in my case. I could never figure out the details (maybe something about the time zone ?), but I understand that you are not supposed to use it to check usage on a daily basis (use 1. For that)
Even if the mail from Google says API usage will ‘probably continue to be free’ in your case, now is a good time to check (half way through the first month): in my case, the actual cost would have roughly been 500 $ (-$ 200 free offer).
My solution to the problem on my free website was to remove the google maps from it. :-(
Thanks to all who tried to help.