To query the Balance of a specific Address you can use the REQUEST_ENTITY with type 31
- Size: 40
- Type: 31
- DejaVu: any Random int
unsigned char publicKey[32];: PublicKey of the Address you want to get balance
RESPOND_ENTITY
struct Entity
{
unsigned char publicKey[32];
long long incomingAmount, outgoingAmount;
unsigned int numberOfIncomingTransfers, numberOfOutgoingTransfers;
unsigned int latestIncomingTransferTick, latestOutgoingTransferTick;
};
typedef struct
{
::Entity entity;
unsigned int tick;
int spectrumIndex;
unsigned char siblings[SPECTRUM_DEPTH][32];
} RespondedEntity;publicKey: Address/IdincomingAmount: Amount of incoming $QUBIC's for given AddressoutgoingAmount: Amount of incoming $QUBIC's for given AddressnumberOfIncomingTransfers: Amount of incoming Transactions for given AddressnumberOfOutgoingTransfers: Amount of incoming Transactions for given AddresslatestIncomingTransferTick: Tick for the last incoming TransactionlatestOutgoingTransferTick: Tick for the last outgoing Transactiontick: For which Tick this Report is validspectrumIndex: Position of Entity in Spectrum
Note
To get current Balance for the given Address substract outgoingAmount from incomingAmount
Note
Keep track of tick in your application. Don't update Balance if responded tick is lower than existing.
Warning
A manipulated node may report wrong information. Only use trusted Peers!