Abyss Crypto

The Graph Basics

The Graph is a wonderful way to access a lot of great blockchain data. 'APIs for a vibrant decentralized future' is exaclty the kind of project we'd want to understand and support.
The Graph has a wonderful explorer to test your queries in https://thegraph.com/hosted-service/subgraph/uniswap/uniswap-v2 To get a list of tokens: { tokens { id symbol name } } To get a specific token: note tokens vs token { token(id:, "0x0000000000004946c0e9f43f4dee607b0ef1fa1c") { id symbol name } } { tokens(where:{id: "0x0000000000004946c0e9f43f4dee607b0ef1fa1c"}) { id symbol name } } To find/get Bitcoin (WBTC) Note: Where would I find an ID if I didn't already know where? Example, for WBTC (Bitcoin on Ethereum network) - I could go to the info page for the token: https://info.uniswap.org/#/tokens/0x2260fac5e5542a773aa44fbcfedf7c193bc2c599 and click the 0x.... ID after the symbol name. This will take you to Etherscan: https://etherscan.io/address/0x2260fac5e5542a773aa44fbcfedf7c193bc2c599 it's the contract address! { token(id:, "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"}) { id symbol name } } NO DOESN'T WORK To get a pair via ID (seearching on the site) https://info.uniswap.org/#/pools 0x99ac8ca7087fa4a2a1fb6357269965a2014abc35 { pair(id:, "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852") { token0Price, token1Price, } } To get a specific pair: WBTC / USDC Step 1. Find the IDs on Uniswap https://info.uniswap.org/#/ WBTC: 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599 find USDC id { pairs( where: {token0: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", token1: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}) { token0Price, token1Price, } } // START NOT WORKING usdc: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 eth: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 { pairs( where: {token0: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", token1: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}) { token0Price, token1Price, } } "id": "0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc", "token0": { "id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "symbol": "USDC", "name": "USD//C" }, "token1": { "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "symbol": "WETH", "name": "Wrapped Ether" } { pairs( where: { token0: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", token1: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"}) { token0Price, token1Price, } } // END NOT WORKING To get more info about a pair: { pairs(first: 5, orderBy: txCount, orderDirection: desc) { id, token0 { id, symbol, name, }, token1 { id symbol, name, }, } }