BigQuery/ Ethereum dataset - how to write the code

后端 未结 1 1361
悲&欢浪女
悲&欢浪女 2021-01-25 11:39

For the ethereum dataset, anyone could tell me how should I write in BigQuery if I\'d know the last month transactions of a particular contract? For example, if i would know how

相关标签:
1条回答
  • 2021-01-25 12:08

    You just simply took the address that exists only in one table and not in another - thus JOIN excludes it from result

    You can use LEFT JOIN instead of JOIN in case if address of your interest is in one (first) table but not in another (second)

    As in below example

    #standardSQL
    SELECT
      from_address,
      to_address,
      value,
      transaction_hash
    FROM
      `bigquery-public-data.crypto_ethereum.token_transfers` AS token_trs
    LEfT JOIN
      `bigquery-public-data.crypto_ethereum.contracts` AS contracts
    ON
      (contracts.address = token_trs.token_address)
    WHERE
      token_trs.token_address = '0x41dbecc1cdc5517c6f76f6a6e836adbee2754de3'   
    

    In case if you for some reason need JOIN to work - run first below query to obtain the address that is present in both tables

    #standardSQL
    SELECT contracts.address
    FROM `bigquery-public-data.crypto_ethereum.token_transfers` AS token_trs
    JOIN `bigquery-public-data.crypto_ethereum.contracts` AS contracts
    ON contracts.address = token_trs.token_address
    LIMIT 10   
    

    Take any address from result and run your original query with it

    For example:

    #standardSQL
    SELECT
      from_address,
      to_address,
      value,
      transaction_hash
    FROM
      `bigquery-public-data.crypto_ethereum.token_transfers` AS token_trs
    JOIN
      `bigquery-public-data.crypto_ethereum.contracts` AS contracts
    ON
      (contracts.address = token_trs.token_address)
    WHERE
      contracts.address = '0x298683bd77f17bca4f3fb37b5bf02f82ee81d3ef'
    

    Note: I see extra spaces in your address value - most likely copy paste issue but wanted to mention

    0 讨论(0)
提交回复
热议问题