blockchain-etl / ethereum-etl

Python scripts for ETL (extract, transform and load) jobs for Ethereum blocks, transactions, ERC20 / ERC721 tokens, transfers, receipts, logs, contracts, internal transactions. Data is available in Google BigQuery https://goo.gl/oY5BCQ
https://t.me/BlockchainETL
MIT License
2.96k stars 849 forks source link

Any reason why certain wallet addresses may not appear in `balances` or `token_transfers` #368

Closed chumbalayaa closed 2 years ago

chumbalayaa commented 2 years ago

Some wallet addresses we have in our dao don't appear in queries we've written, but if we choose a random address from the preview data in BigQuery then it always returns a result. Happy to provide addresses but would rather not if it's a known issue why some might not appear?

FahdW commented 2 years ago

I assume you're running Etl against maybe a full node and not an archive node? That'd be my assumption

chumbalayaa commented 2 years ago

Thanks @FahdW, is there a param to select full vs. archive? I'm just querying BigQuery directly, and my understanding was the ethereum_blockchain was 100% complete

However, when I run the following I don't get data back - even though this is Justin Beiber's wallet and the guy has tons of Eth

function main() {

    // Import the Google Cloud client library
    const {BigQuery} = require('@google-cloud/bigquery');

    async function getWalletBalances() {
        // Create a client
        const bigqueryClient = new BigQuery();

        // The SQL query to run
        const sqlQuery = `SELECT eth_balance
            FROM \`bigquery-public-data.crypto_ethereum.balances\`
            WHERE address = '0xE21DC18513e3e68a52F9fcDaCfD56948d43a11c6'`;

        console.log(sqlQuery);
        const options = {
        query: 
            sqlQuery,
            // Location must match that of the dataset(s) referenced in the query.
            location: 'US',
            params: {
            },
        };

        // Run the query
        const [rows] = await bigqueryClient.query(options);

        console.log('Rows:');
        rows.forEach(row => console.log(row));
    }

    getWalletBalances();
  }

main();
harsha-defy commented 2 years ago

Most likely because the public data set has not been updated in the recent times maybe?

medvedev1088 commented 2 years ago

You should be querying bigquery-public-data.crypto_ethereum instead of bigquery-public-data.ethereum_blockchain. The latter one is not being updated. Also the addresses should be lower-cased. Hope it helps

medvedev1088 commented 2 years ago
select *
from bigquery-public-data.crypto_ethereum.balances
where address = lower('0xE21DC18513e3e68a52F9fcDaCfD56948d43a11c6')