Skip to content

Commit 3e3d577

Browse files
committed
changes in solana balance queries
1 parent febca4f commit 3e3d577

1 file changed

Lines changed: 45 additions & 42 deletions

File tree

docs/Examples/Solana/transfers.md

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -101,33 +101,6 @@ query MyQuery {
101101
}
102102
```
103103

104-
## SOL Balance of an address at a specific height
105-
106-
This query calculates the SOL balance of a wallet at a specific block height by fetching all native SOL (represented by "-" in Bitquery v1) sent and received transactions up to that height. `received - sent` is the balance of the address.
107-
108-
[Run query](https://ide.bitquery.io/sol_balance-of-an-address-at-a-specific-block-height-using-transfers)
109-
110-
```
111-
{
112-
solana {
113-
sent: transfers(
114-
currency: {is : "-"}
115-
height:{lteq:370674688}
116-
senderAddress: {is: "Df8Rmm7nPZAkENidu36LdMb7A92UBV9pGagLUftPkjnq"}
117-
) {
118-
amount
119-
}
120-
recieved: transfers(
121-
currency: {is: "-"}
122-
height:{lteq:370674688}
123-
receiverAddress: {is: "Df8Rmm7nPZAkENidu36LdMb7A92UBV9pGagLUftPkjnq"}
124-
) {
125-
amount
126-
}
127-
}
128-
}
129-
```
130-
131104
## Holding Period of a Token by a Wallet
132105

133106
This query calculates how long a wallet has been holding a specific token by looking at the first and last transfer block heights for that token into the wallet. It is useful for analyzing token holding behavior, vesting, or eligibility for airdrops and loyalty programs.
@@ -319,22 +292,57 @@ query MyQuery {
319292
}
320293
```
321294

322-
## Currency Sent and Received by an address between a time period
295+
## Currency Sent and Received by an address
296+
297+
Below API will give you details on the aggreated currency sent and received by an address.
298+
Try the API [here](https://ide.bitquery.io/currency-sent-and-received-by-an-address#).
299+
300+
```
301+
query ($address: String!) {
302+
solana {
303+
transfers(
304+
any: [{receiverAddress: {is: $address}}, {senderAddress: {is: $address}}]
305+
options: {desc: "balance"}
306+
) {
307+
sum_in: amount(calculate: sum, receiverAddress: {is: $address})
308+
sum_out: amount(calculate: sum, senderAddress: {is: $address})
309+
balance: expression(get: "sum_in - sum_out")
310+
count_in: countBigInt(receiverAddress: {is: $address})
311+
count_out: countBigInt(senderAddress: {is: $address})
312+
currency {
313+
address
314+
symbol
315+
tokenType
316+
}
317+
}
318+
}
319+
}
320+
321+
```
322+
323+
```
324+
{
325+
"address": "DoPnWi3csUodvLqu6VCLWg3EJwLccky9CD4C9ejL6Zgu"
326+
}
327+
```
328+
329+
## Balance of an address on a specific date
323330

324-
Below API will give you details on the aggreated currency sent and received by an address in a timeperiod.
325-
Try the API [here](https://ide.bitquery.io/currency-sent-and-received-by-an-address-between-a-time_1).
331+
This query calculates the balance of a wallet at a specific date by fetching all transfers sent and received transactions up to that height. `received - sent` is the balance of the address.
332+
333+
[Run query](https://ide.bitquery.io/balance-on-a-specific-date#)
326334

327335
```
328-
query ($network: SolanaNetwork!, $address: String!, $from: ISO8601DateTime, $till: ISO8601DateTime, $limit: Int!, $offset: Int!) {
329-
solana(network: $network) {
336+
query ($address: String!, $date: ISO8601DateTime!) {
337+
solana {
330338
transfers(
331-
date: {since: $from, till: $till}
339+
date:{till:$date}
332340
any: [{receiverAddress: {is: $address}}, {senderAddress: {is: $address}}]
333-
options: {limit: $limit, offset: $offset, desc: ["count_in", "count_out"],
334-
asc: "currency.symbol"}
341+
options: {desc: "balance"}
335342
) {
336343
sum_in: amount(calculate: sum, receiverAddress: {is: $address})
337344
sum_out: amount(calculate: sum, senderAddress: {is: $address})
345+
balance: expression(get: "sum_in - sum_out")
338346
count_in: countBigInt(receiverAddress: {is: $address})
339347
count_out: countBigInt(senderAddress: {is: $address})
340348
currency {
@@ -349,13 +357,8 @@ query ($network: SolanaNetwork!, $address: String!, $from: ISO8601DateTime, $til
349357

350358
```
351359
{
352-
"limit": 10,
353-
"offset": 0,
354-
"network": "solana",
355-
"address": "DoPnWi3csUodvLqu6VCLWg3EJwLccky9CD4C9ejL6Zgu",
356-
"from": "2025-06-18",
357-
"till": "2025-06-25T23:59:59",
358-
"dateFormat": "%Y-%m-%d"
360+
"date":"2025-12-09",
361+
"address": "DoPnWi3csUodvLqu6VCLWg3EJwLccky9CD4C9ejL6Zgu"
359362
}
360363
```
361364

0 commit comments

Comments
 (0)