How to get wallet related details

A cryptocurrency wallet basically is a device, physical medium, program or a service. They keep your private and/or public keys – the passwords that give you access to your cryptocurrencies – safe and accessible, allowing you to make cryptocurrency transactions (send and receive) like Bitcoin and Ethereum etc. In addition to this basic function of storing the keys, a cryptocurrency wallet more often also offers the functionality of encrypting and/or signing information.

You can easily get any information related to the crypto wallets using Bitquery’s APIs and tools. In this tutorial, we’ll take a look at how to go about the same!

To start off, you can check out our Bitquery explorer and simply put the address whose details you are looking for in the search bar at the top.

As an example in this tutorial we will be using the wallet with address “0x43cf525d63987d17052d9891587bcfb9592c3ee2” on the Ethereum mainnet network.

Balance of the Given Wallet Address

Let’s take a look at how can we calculate the balance for a particular wallet using Bitquery’s GraphQL IDE. You can run the following query with the address whose details you require and get the wallet’s balance.
The following GraphQL query would get you the balance of a wallet based on the Ethereum blockchain.

{
  ethereum{
    balance: address(
      address: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}
    ){
      balance
    }
  }
}

Get the query from here: Balance of an Ethereum Wallet address
To know about the Balance of the wallet for different currencies, you may refer to this GraphQL query:-

{
  ethereum{
    balance: address(
      address: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}
    ){
      balances{
        value
        currency{
          name
          symbol
        }
      }
    }
  }
}

The result generated by this GraphQL query is shown in this link: Balance in different currencies of 0x43cf525d63987d17052d9891587bcfb9592c3ee2

For getting the balance of a Bitcoin wallet, you need to make a separate query where the balance has to be calculated by subtracting the input value from the output value. The following GraphQL query would show you how to get the balance of a Bitcoin wallet address bc1qg28ajhqus54ljn2nrszf8n6urg9chsf36e6t4y.

To get to know more about Bitquery’s Balance API you can refer to the following link.

Bitquery’s Balance API - GraphQL Tutorials - Bitquery

Balance History

Now we’ll see how we can get the balance history for a wallet address using Bitquery’s APIs. Running the following query does the need full.

{
  ethereum {
    address(address: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}) {
      balances (
        currency: {is: "ETH"}
        date: {till: "2022-05-01"}
      ) {
        history {
          transferAmount
          value
          timestamp
        }
      }
    }
  }
}

You can use the following link to access the query: Balance History of Ethereum Wallet address 0x43cf525d63987d17052d9891587bcfb9592c3ee2

Transactions

Now we’ll try to fetch the transactions related to a particular wallet address.
The following query gives you the latest transaction made for the given wallet address on the Ethereum network:-

{
  ethereum {
    transactions(options: {limit: 10, desc: "amountInUSD"}) {
      amount
      amountInUSD: amount(in: USD)
      currency {
        symbol
      }
      to {
        address
      }
      date {
        date
      }
      sender(txSender: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}) {
        address
      }
    }
  }
}


You can also find the above query here:

Now let’s take a look at a query for the token transfers for an address along with the sender and gas amount

{
  ethereum {
    transfers(
      options: {limit: 10, desc: "amountInUSD"}
      sender: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}
      date: {}
    ) {
      amount(in: USD)
      amountInUSD: amount(in: USD)
      count
      currency {
        symbol
        tokenId
        tokenType
      }
      receiver {
        address
      }
      sender {
        address
      }
      date {
        date(format: "%Y-%m-%d")
      }
      gasValue
    }
  }
}

Dex Trades

Moving on, now we’ll take a look at the DEX trades taking place using this wallet address.
You can find graphical representations of the trades by time, trade takers, traded currencies and DEX Smart Contracts by time under the DEX trades tab. Clicking on the Open GraphQL IDE button on the bottom right corner of each section will give you queries for the same

Clicking on the Open GraphQL IDE button on the bottom right corner of each section will give you pre-written queries for the same as follows:

{
  ethereum(network: ethereum) {
    dexTrades(
      options: {asc: "date.date"}
      date: {since: "2022-04-28", till: "2022-05-05T23:59:59"}
      makerOrTaker: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}
    ) {
      date: date {
        date(format: "%Y-%m-%d")
      }
      trades: countBigInt
      traders: countBigInt(uniq: takers)
      contracts: countBigInt(uniq: smart_contracts)
      currencies: countBigInt(uniq: buy_currency)
    }
  }
}

The results generated by the use of this query can also be found using txsender in place of “makerortaker”:

{
  ethereum(network: ethereum) {
    dexTrades(
      options: {asc: "date.date"}
      date: {since: "2022-04-28", till: "2022-05-05T23:59:59"}
    ) {
      date: date {
        date(format: "%Y-%m-%d")
      }
      trades: countBigInt(
        txSender: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}
      )
      traders: countBigInt(uniq: takers)
      contracts: countBigInt(uniq: smart_contracts)
      currencies: countBigInt(uniq: buy_currency)
    }
  }
}

To get the latest token trade pairs of a wallet, you can use the following query

{
  ethereum(network: ethereum) {
    dexTrades(
      options: {desc: "count", limit: 10, offset: 0}
      date: {since: "2022-04-28", till: "2022-05-05T23:59:59"}
      makerOrTaker: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}
    ) {
      sellCurrency {
        symbol
        address
      }
      sellAmount
      buyCurrency {
        symbol
        address
      }
      buyAmount
      count
      median_price: price(calculate: median)
      last_price: maximum(of: block, get: price)
      dates: count(uniq: dates)
      started: minimum(of: date)
    }
  }
}

You can get the above query using this link too

Latest traders for the wallet

Now let’s take a look at the query for fetching the latest traders for the wallet

{
  ethereum(network: ethereum) {
    transactions(
      options: {desc: "amount", limit: 10, offset: 0}
      date: {since: "2022-05-14", till: "2022-05-21T23:59:59"}
      txSender: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      success
      address: to {
        address
        annotation
      }
      gasValue
      gasCurrency {
        symbol
      }
      hash
      amount(in: USD)
    }
  }
}

Smart Contract calls

In this section we’ll take a look at how we can get the details related to the smart contract calls made for a particular wallet address.

Under the Call contracts tab, you can find tabular representations for the latest Smart Contract Calls, Top Gas Cost Calls, the Smart Contracts called, Smart Contract Methods called etc. You can even find the graphical representation of the Smart contract calls by date

You can run the following query to get the latest smart contract calls

{
  ethereum(network: ethereum) {
    smartContractCalls(
      options: {desc: "block.timestamp.time", limit: 10, offset: 0}
      date: {since: "2022-04-28", till: "2022-05-05T23:59:59"}
      caller: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      smartContractMethod {
        name
        signatureHash
      }
      smartContract {
        address {
          address
          annotation
        }
        contractType
      }
      transaction {
        hash
      }
      external
      gasValue
    }
    smartContractEvents {
      count(uniq: smart_contracts)
    }
  }
}

Picture1
Bar graph between transaction hash and gas value

You can find the above query here too:

Money flow

Bitquery’s coinpath API allows you to track the flow of your cryptocurrency by representing it in easy to understand graphical forms, namely Graph and Sankey.

Graph view

Picture2

Here the figure at the centre represents the wallet address which we are investigating, the circular gears represent smart contracts and the green figures represent the senders and receivers. Each arrow represents the currency and it’s value.

We can use coinpath to get all inbound and outbound transfers from and to a wallet on multiple hops too.If we increase the Outbound depth level, the graph representation looks like this, tracking the outbound transactions upto three levels:

Picture3

The query for the above is:

{
  ethereum(network: ethereum) {
    inbound: coinpath(
      initialAddress: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}
      currency: {is: "ETH"}
      depth: {lteq: 1}
      options: {direction: inbound, asc: "depth", desc: "amount", limitBy: {each: "depth", limit: 10}}
      date: {since: "2022-04-28", till: "2022-05-05T23:59:59"}
    ) {
      sender {
        address
        annotation
        smartContract {
          contractType
          currency {
            symbol
            name
          }
        }
      }
      receiver {
        address
        annotation
        smartContract {
          contractType
          currency {
            symbol
            name
          }
        }
      }
      amount
      currency {
        symbol
      }
      depth
      count
    }
    outbound: coinpath(
      initialAddress: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}
      currency: {is: "ETH"}
      depth: {lteq: 3}
      options: {asc: "depth", desc: "amount", limitBy: {each: "depth", limit: 10}}
      date: {since: "2022-04-28", till: "2022-05-05T23:59:59"}
    ) {
      sender {
        address
        annotation
        smartContract {
          contractType
          currency {
            symbol
            name
          }
        }
      }
      receiver {
        address
        annotation
        smartContract {
          contractType
          currency {
            symbol
            name
          }
        }
      }
      amount
      currency {
        symbol
      }
      depth
      count
    }
  }
}

You can also access the above query here:

Sankey

Here the long rectangular strip represents the wallet address which we are investigating. The incoming arrows from the left represents the inflow of currency and the thickness of the stripes represent the amount being transferred, the outgoing strips on the right represent the outflow of currency.

The above information can also be obtained by running the following query:

**Use of Coinpath for getting inbound and outbound transfers
**
Let’s take an example of a query that shows the use of coinpath API to get inbound and outbound transfers

{
  ethereum {
    inbound: coinpath(
      initialAddress: {is: "0x43cf525d63987d17052d9891587bcfb9592c3ee2"}
      currency: {is: "ETH"}
      depth: {lteq: 1}
      options: {direction: inbound, asc: "depth", desc: "amount", limitBy: {each: "depth", limit: 10}}
      date: {since: null, till: null}
    ) {
      sender {
        address
        annotation
        smartContract {
          contractType
          currency {
            symbol
            name
          }
        }
      }
      receiver {
        address
        annotation
        smartContract {
          contractType
          currency {
            symbol
            name
          }
        }
      }
      amount
      currency {
        symbol
      }
      depth
      count
    }
    outbound: coinpath(
      initialAddress: {is: "0x0681d8db095565fe8a346fa0277bffde9c0edbbf"}
      currency: {is: "ETH"}
      depth: {lteq: 1}
      options: {asc: "depth", desc: "amount", limitBy: {each: "depth", limit: 10}}
      date: {since: null, till: null}
    ) {
      sender {
        address
        annotation
        smartContract {
          contractType
          currency {
            symbol
            name
          }
        }
      }
      receiver {
        address
        annotation
        smartContract {
          contractType
          currency {
            symbol
            name
          }
        }
      }
      amount
      currency {
        symbol
      }
      depth
      count
    }
  }
}

To learn more about Bitquery’s Coinpath API, you can refer to the following article:
Coinpath® - Blockchain Money Flow APIs - Bitquery

Conclusion

Bitquery provides support and details related to the wallet addresses of various blockchain networks. If you are looking for the same, please sign up on our Blockchain IDE and get your API keys. If you need information and details related to the wallet addresses, we would be delighted to talk to you; you can mail us at hello@bitquery.io or ping us on our Telegram channel.

Also Read

About Bitquery

Bitquery is a set of software tools that parse, index, access, search, and use information across blockchain networks in a unified way. We are crossing the ‘chain-chasm’ by delivering set of products that can work across blockchains. Our products include:

Coinpath APIs provide blockchain money flow analysis for more than 24 blockchains. With Coinpath’s APIs, you can monitor blockchain transactions, investigate crypto crimes such as bitcoin money laundering, and create crypto forensics tools. You can refer to this article to get started with Coinpath

Digital Assets API provides index information related to all major cryptocurrencies, coins, and tokens.

DEX API provides real-time deposits and transactions, trades, and other related data on different DEX protocols like Uniswap, SushiSawap, Kyber Network, Airswap, Matching Network, etc.

If you have any questions about our products, ask them on our Telegram channel or email us at hello@bitquery.io . Also, subscribe to our newsletter and stay updated about the latest in the cryptocurrency world.