Solana Balance & Balance Updates API
In this section we will see how to monitor real-time balance changes across the Solana blockchain using our BalanceUpdates API.
Solana APIs is part of our Early Access Program (EAP), which is intended for evaluation purposes. This program allows you to test the data and its integration into your applications before full-scale implementation. Read more here
Note - Our V1 APIs do support solana and you can get balances from there. However they do not have historical balance.
Get Latest Balance Updates
The query will subscribe you to real-time updates for balance changes on the Solana blockchain, providing a continuous stream of data as new transactions are processed and recorded. You can find the query here
The balance update does not inherently include transaction fees. Therefore, to get the actual balance after all transactions and fees, you need to subtract the total transaction fees from the balance updates.
subscription {
Solana {
InstructionBalanceUpdates(limit: {count: 10}) {
Transaction {
Index
FeePayer
Fee
Signature
Result {
Success
ErrorMessage
}
}
Instruction {
InternalSeqNumber
Index
CallPath
Program {
Address
Name
Parsed
}
}
Block {
Time
Hash
Height
}
BalanceUpdate {
Account {
Address
}
Amount
Currency {
Decimals
CollectionAddress
Name
Key
IsMutable
Symbol
}
}
}
}
}
Get Balance Updates of a Particular Wallet
To focus on the balance changes of a particular Solana wallet, this query filters the data stream to include only those updates relevant to the specified address. This is especially useful for wallet owners or services tracking specific accounts.
subscription {
Solana {
InstructionBalanceUpdates(
limit: {count: 10}
where: {BalanceUpdate: {Account: {Address: {is: "68sMd16LafqLfyS7ejieyWhMsAwKgywVKvSEumvK1RUp"}}}}
) {
Transaction {
Index
FeePayer
Fee
Signature
Result {
Success
ErrorMessage
}
}
Instruction {
InternalSeqNumber
Index
CallPath
Program {
Address
Name
Parsed
}
}
Block {
Time
Hash
Height
}
BalanceUpdate {
Account {
Address
}
Amount
Currency {
Decimals
CollectionAddress
Name
Key
IsMutable
Symbol
}
}
}
}
}
Track NFT Balance Updates in Real-Time
For those interested in the NFT market, this query is tailored to track balance updates involving non-fungible tokens (NFTs) on the Solana blockchain.
You can find the query here
subscription {
Solana {
InstructionBalanceUpdates(
limit: {count: 10}
where: {BalanceUpdate: {Currency: {Fungible: false}}}
) {
Transaction {
Index
FeePayer
Fee
Signature
Result {
Success
ErrorMessage
}
}
Instruction {
InternalSeqNumber
Index
CallPath
Program {
Address
Name
Parsed
}
}
Block {
Time
Hash
Height
}
BalanceUpdate {
Account {
Address
Token {
Owner
}
}
Amount
Currency {
Decimals
CollectionAddress
Name
Key
IsMutable
Symbol
}
}
}
}
}
Latest Balance of an Address on Solana
The query will subscribe you to real-time updates for balance changes on the Solana blockchain for the address 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8
, The PreBalance
and PostBalance
functions are used here to get the balance.
You can find the query here
subscription {
Solana {
BalanceUpdates(
where: {BalanceUpdate: {Account: {Address: {is: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"}}}}
) {
BalanceUpdate {
Account {
Address
}
Amount
Currency {
Decimals
CollectionAddress
Name
Key
IsMutable
Symbol
}
PreBalance
PostBalance
}
}
}
}
Using Pre-Made Aggregates in Solana Balance Updates
When querying Solana balance updates, you can use pre-made aggregates to optimize performance. The aggregates
flag provides three options to control the use of these aggregates:
aggregates: only
: This option uses only the pre-made aggregates, which can significantly increase the speed of the response.aggregates: yes
: This option uses both pre-made aggregates and individual transaction data.aggregates: no
: This option does not use any pre-made aggregates.When using the aggregates: only option, you need to include the Owner field in the response to ensure proper aggregation and filtering.
{
Solana(aggregates: only) {
BalanceUpdates(
where: {BalanceUpdate: {Account: {Address: {is: "HEL1USMZKAL2odpNBj2oCjffnFGaYwmbGmyewGv1e2TU"}}}}
) {
BalanceUpdate {
Account {
Owner
}
Currency {
Decimals
CollectionAddress
Name
Key
IsMutable
Symbol
}
}
sum(of: BalanceUpdate_AmountInUSD)
}
}
}